Java 解析sparksql中的嵌套json
我在Java 解析sparksql中的嵌套json,java,tomcat,apache-spark,apache-spark-sql,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)
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");
但似乎有一个错误
写一个是什么?你用c点的是什么?下面是您应该执行的操作val variable=sqlContext.sql(“从表“+”中选择ProductInfo.Name,Reviews.totalas rating,其中rating=5.0”);你们用c点什么?下面是您应该执行的操作val variable=sqlContext.sql(“从表“+”中选择ProductInfo.Name,Reviews.totalas rating,其中rating=5.0”);