Сохраняет SampleBean как JSON строка
val conf = new SparkConf()
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.set("spark.kryo.registrationRequired", "true")
.registerKryoClasses(Array(classOf[SampleBean], classOf[InternalRow]
, classOf[Array[InternalRow]]
, classOf[WriteTaskResult]
, classOf[FileCommitProtocol.TaskCommitMessage]
, classOf[ExecutedWriteSummary],
classOf[BasicWriteTaskStats]))
val spark = SparkSession.builder.master("local[*]")
.config(conf)
.getOrCreate
import spark.implicits._
val df = List(SampleBean("A", "B")).toDF()
df.write.mode(SaveMode.Overwrite).json("src/main/resources/kryoTest")
df.printSchema()
читает данные просто JSON
val sparkNew = Constant.getSparkSess
val dfNew = sparkNew.read.json("src/main/resources/serialisedJavaObj.json").toDF()
dfNew.printSchema()