Database Reference
In-Depth Information
Select b.studentid, b.studentdata from studentdata a
lateral view
json_tuple(a.jstring,'StudentId','StudentData') b
as studentid, studentdata;
Figure 9.14 shows the query output.
Figure 9.14 Parsing JSON data
Notice that this query did not parse out the nested JSON data from each
row. To query the nested data, you need to add an additional lateral view:
Select b.studentid, c.name, c.major from studentdata a
lateral view
json_tuple(a.jstring,'StudentId','StudentData') b
as studentid, studentdata
lateral view json_tuple(b.studentdata,'Name','Major')
c as name, major;
Figure 9.15 shows the output with the nested JSON data parsed out into
separate columns.
Figure 9.15 Parsing out nested data
Now that you have expanded out the nested data, you can analyze the data
using reduce functions such as counting the number of students in each
major.
 
 
 
 
Search WWH ::




Custom Search