Hive - 从嵌套 Json 中提取数据
Hive - Extract data from nested Json
我 table 调用了 newdata
create external table newdata
(
data string
)
location 'something'
select data from string limit 1
{ "user": { "name": "default", "education": { "schoome": "abc", "college": "def" } }
我需要将此结果显示为
|用户 |姓名 |学校 |大学|
|--------|--------|--------|----------|
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
我 table 调用了 newdata
create external table newdata
(
data string
)
location 'something'
select data from string limit 1
{ "user": { "name": "default", "education": { "schoome": "abc", "college": "def" } }
我需要将此结果显示为
|用户 |姓名 |学校 |大学|
|--------|--------|--------|----------|
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