When i try to fetch the nested JSON data by using Spark-SQL query:
SparkContext sc = new SparkContext(new SparkConf().setAppName("sql").setMaster("local"));
SQLContext sqlContext = new SQLContext(sc);
DataFrame df = sqlContext.read().json("path_to_s3_bucket").cache();
df.registerTempTable("table_name");
DataFrame d=sqlContext.sql("Select address.state as state from table_name");
I am getting th following exception
Exception in thread "main" org.apache.spark.sql.AnalysisException: Can't extract value from address
My Json data is like:-
"address":{"city":"xyz","state":"abc","country":"pqr"}
Please help in resolving the issue.
Your json is invalid. It should be: {"address":{"city":"xyz","state":"abc","country":"pqr"}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.