SparkSql

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()
}


上一篇:# ** Warning: (vsim-3534) [FOFIR] - Failed to open file "../matlab/rom_mult_4bit.mif" for


下一篇:modelsim和vivado仿真不一致——噩梦debug