In your case, the table has only one row, whose contents is “data”, which is an array. You need something like |SELECT data[0].name FROM json_table| to access the |name| field.

On 9/29/14 11:08 PM, vdiwakar.malladi wrote:

Hello,

I'm exploring SparkSQL and I'm facing issue while using the queries. Any
help on this is appreciated.

I have the following schema once loaded as RDD.

root
  |-- data: array (nullable = true)
  |    |-- element: struct (containsNull = false)
  |    |    |-- age: integer (nullable = true)
  |    |    |-- name: string (nullable = true)


my people.json is as follows.

{"data": [{"name":"Michael"}, {"name":"Andy", "age":30}, {"name":"Justin",
"age":19}]}

when I'm querying "select name from people where age>=13"; I'm getting the
following exception.

org.apache.spark.sql.catalyst.errors.package$TreeNodeException: Unresolved
attributes: 'element.name, tree:
Project ['name]
  Filter ('age >= 13)
   Subquery people

My question is how to access name, age from root node to query the same.

Thanks in advance.





--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/Unresolved-attributes-SparkSQL-on-the-schemaRDD-tp15339.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org

Reply via email to