sparkSQL之读取不同数据源的数据

object DataSourceTest2 {
  //读取不同的数据源
  def main(args: Array[String]): Unit = {

    val spark: SparkSession = SparkSession.builder().master("local[*]").appName("w").getOrCreate()
    val sc: SparkContext = spark.sparkContext
    sc.setLogLevel("WARN")

    spark.read.json("E:\\ideal_workspace\\spark\\day01\\output\\json").show
    spark.read.csv("E:\\ideal_workspace\\spark\\day01\\output\\csv").toDF("id","name","AGE").show
    spark.read.parquet("E:\\ideal_workspace\\spark\\day01\\output\\parquet").show()

    val prop = new Properties()
    prop.setProperty("user","root")
    prop.setProperty("passqord","root")
    //spark.read.jdbc(" ","person",prop)

    spark.stop()
    sc.stop()
    
  }


}

你可能感兴趣的:(大数据)