SparkSql
package spark_sql
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{DataFrame, Dataset, Row, SparkSession}
case class Emp(name: String, age: Long)
object spark_sql_json extends App {
val ss: SparkSession = SparkSession.builder().master("local[*]").appName("sql").getOrCreate()
import ss.implicits._
val df: DataFrame = ss.read.json("datas/a.json").toDF()
println("df")
df.show()
val ds: Dataset[Emp] = df.as[Emp]
println("ds")
ds.show()
val df_rdd: RDD[Row] = df.rdd
val rdd: RDD[Emp] = ds.rdd
println("ds.rdd")
rdd.collect().foreach(println)
println("rdd.toDS")
rdd.toDS()
ss.stop()
}