在sparksql中解析嵌套的json

时间:2016-04-09 23:47:25

标签: java tomcat apache-spark apache-spark-sql

我在JavaSchemaRDD

中有这种嵌套的架构格式
   root
   |-- ProductInfo: struct (nullable = true)
   |    |-- Features: string (nullable = true)
   |    |-- ImgURL: string (nullable = true)
   |    |-- Name: string (nullable = true)
   |    |-- Price: string (nullable = true)
   |    |-- ProductID: string (nullable = true)
   |-- Reviews: array (nullable = true)
   |    |-- element: struct (containsNull = false)
   |    |    |-- Author: string (nullable = true)
   |    |    |-- Content: string (nullable = true)
   |    |    |-- Date: string (nullable = true)
   |    |    |-- Overall: string (nullable = true)
   |    |    |-- ReviewID: string (nullable = true)
   |    |    |-- Title: string (nullable = true)
   |-- _corrupt_record: string (nullable = true)

我想根据产品的总体评级选择产品名称。

我写的如下

JavaSchemaRDD variable = sqlContext.sql("SELECT ProductInfo.Name FROM Table" + "WHERE Reviews.element.Overall=5.0" + "ORDER BY c"); 

但似乎有一个错误。

什么是写作?

0 个答案:

没有答案