创建DataFrames
有了一个SQLContext,应用程序就可以从一个已存在的RDD,一个Hive表,或数据源,来创建DataFrames。
例如,以下基本一个JSON文件的内容创建了一个DataFrames:
val sc: SparkContext // An existing SparkContext.
val sqlContext = new org.apache.spark.sql.SQLContext(sc)
val df = sqlContext.read.json("examples/src/main/resources/people.json")
// Displays the content of the DataFrame to stdout
df.show()