This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.iceberg.{PartitionSpec, Schema, Table, TableProperties} | |
import org.apache.iceberg.catalog.TableIdentifier | |
import org.apache.iceberg.hadoop.HadoopCatalog | |
import org.apache.iceberg.types.Types | |
val hadoopCatalog = new HadoopCatalog(spark.sparkContext.hadoopConfiguration, "/Playground/iceberg-trial/warehouse-spark3.0.1") | |
val structSchema = Types.StructType.of( | |
Types.NestedField.optional(161, "a", Types.StringType.get()), | |
Types.NestedField.optional(162, "b", Types.IntegerType.get())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.heartsavior.spark.trial; | |
import org.apache.spark.api.java.function.MapFunction; | |
import org.apache.spark.api.java.function.MapGroupsWithStateFunction; | |
import org.apache.spark.sql.Dataset; | |
import org.apache.spark.sql.Encoders; | |
import org.apache.spark.sql.SparkSession; | |
import org.apache.spark.sql.streaming.StreamingQuery; | |
import org.apache.spark.sql.streaming.StreamingQueryException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.heartsavior.spark | |
import java.sql.Timestamp | |
import java.util.Calendar | |
import org.apache.spark.sql.SparkSession | |
import org.apache.spark.sql.execution.streaming.MemoryStream | |
import org.apache.spark.sql.streaming.{GroupState, GroupStateTimeout, OutputMode, Trigger} | |
import scala.util.Random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.heartsavior.flink | |
import java.util | |
import java.util.{Calendar, Collections} | |
import org.apache.flink.api.common.ExecutionConfig | |
import org.apache.flink.api.common.typeutils.TypeSerializer | |
import org.apache.flink.api.common.typeutils.base.TypeSerializerSingleton | |
import org.apache.flink.api.scala._ | |
import org.apache.flink.core.memory.{DataInputView, DataOutputView} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{File, PrintWriter} | |
import org.apache.spark.internal.Logging | |
import org.apache.spark.sql.functions.{from_json, struct, to_json} | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.DataFrame | |
import org.apache.spark.sql.streaming.StreamingQueryListener | |
import spark.implicits._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{File, PrintWriter} | |
import org.apache.commons.logging.LogFactory | |
import org.apache.spark.sql.functions.{from_json, struct, to_json} | |
import org.apache.spark.sql.types._ | |
import org.apache.spark.sql.DataFrame | |
import org.apache.spark.sql.streaming.StreamingQueryListener |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run the code in spark-shell | |
// e.g.: ./bin/spark-shell --master "local[3]" --packages org.apache.spark:spark-sql-kafka-0-10_2.12:3.0.0-SNAPSHOT | |
val branch = "master" // change this when changing version of "spark-sql-kafka" | |
val attempt = "1" // change this according to the attempt No. | |
// :paste | |
import java.io.{File, PrintWriter} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class SessionInfo(sessionStartTimestampMs: Long, | |
sessionEndTimestampMs: Long, | |
numEvents: Int) { | |
/** Duration of the session, between the first and last events + session gap */ | |
def durationMs: Long = sessionEndTimestampMs - sessionStartTimestampMs | |
} | |
case class SessionUpdate(id: String, | |
sessionStartTimestampSecs: Long, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class SessionInfo(sessionStartTimestampMs: Long, | |
sessionEndTimestampMs: Long, | |
numEvents: Int) { | |
/** Duration of the session, between the first and last events + session gap */ | |
def durationMs: Long = sessionEndTimestampMs - sessionStartTimestampMs | |
} | |
case class SessionUpdate(id: String, | |
sessionStartTimestampSecs: Long, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.heartsavior.spark.trial | |
import org.apache.kafka.common.serialization.StringDeserializer | |
import org.apache.spark.SparkConf | |
import org.apache.spark.sql.SparkSession | |
import org.apache.spark.streaming.kafka010.KafkaUtils | |
import org.apache.spark.streaming.{Seconds, StreamingContext} | |
import org.apache.spark.streaming.kafka010._ | |
import org.apache.spark.streaming.kafka010.LocationStrategies.PreferConsistent | |
import org.apache.spark.streaming.kafka010.ConsumerStrategies.Subscribe |
NewerOlder