2016-04-24 73 views

回答

0

可以注册JavaRDD prdd作为表,然后在SQL语句中使用

`数据帧schemaPeople = sqlContext.createDataFrame(prdd,Person.class); schemaPeople.registerTempTable(“people”);

// SQL可以在已注册为表的RDD上运行。

数据帧青少年= sqlContext.sql(“SELECT SUM(年龄),SUM(工资)FROM一群人的名字)

// SQL查询的结果是DataFrames支持所有的正常RDD operations.`

了解更多:http://spark.apache.org/docs/latest/sql-programming-guide.html#running-sql-queries-programmatically

+2

请帮助我了解,如果我用这个代码,然后我使用的数据帧,但我想用数据集来实现它我失去了什么? – coder