配置单元-从嵌套的json中提取数据

eoxn13cs  于 2021-06-26  发布在  Hive
关注(0)|答案(3)|浏览(344)

我有一个叫做newdata的表

create external table newdata
(
data string
)
location 'something'
``` `select data from string limit 1` ```
{ "user": { "name": "default", "education": { "schoome": "abc", "college": "def" } }

我需要把这个结果显示为
|用户|名称|学校|学院|
|--------|---------|

lnvxswe2

lnvxswe21#

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

相关问题