Hive - 从嵌套的Json中提取数据

时间:2017-03-20 14:48:39

标签: json amazon-web-services hive amazon-athena

我有一张名为newdata的表

create external table newdata
(
data string
)
location 'something'

select data from string limit 1

{ "user": { "name": "default", "education": { "schoome": "abc", "college": "def" } } 

我需要将此结果显示为

|用户|名字|学校|学院|

| -------- | --------- | ---------- | ----------- |

1 个答案:

答案 0 :(得分:0)

select  json_extract_scalar (data,'$.user.name')              as name
       ,json_extract_scalar (data,'$.user.education.school')  as school
       ,json_extract_scalar (data,'$.user.education.college') as college

from    newdata