使用 apache drill 查询嵌入式 json 时出错
Error in querying embedded json using apache drill
donutTest.json(在我的本地系统 /home/dev):
{
"id":"0001",
"type":"donut",
"name":"Cake",
"batter":{
"id":"1001",
"type":"Regular"
},
"topping":[
{ "id":"5001", "type":"None"},
{ "id":"5002", "type":"Glazed"}
]
}
这个查询工作正常。
select topping[0].id as topping_id, topping[3].type as topping_type from dfs.`/home/dev/donutTest.json`;
但是当我尝试时:
select batter.id as batter_id, batter.type as batter_type from dfs.`/home/dev/donutTest.json`;
显示错误。
Table 'batter' not found
topping[0]
和batter
都是内嵌文档还是报错
尝试使用 table 别名,然后在 select 语句中引用它。
select donut.batter.id as batter_id, donut.batter.type as batter_type from dfs.`/home/dev/donutTest.json` as donut;
这样 Drill 就会引用实际的 table 别名,然后是下面的嵌套结构。
donutTest.json(在我的本地系统 /home/dev):
{
"id":"0001",
"type":"donut",
"name":"Cake",
"batter":{
"id":"1001",
"type":"Regular"
},
"topping":[
{ "id":"5001", "type":"None"},
{ "id":"5002", "type":"Glazed"}
]
}
这个查询工作正常。
select topping[0].id as topping_id, topping[3].type as topping_type from dfs.`/home/dev/donutTest.json`;
但是当我尝试时:
select batter.id as batter_id, batter.type as batter_type from dfs.`/home/dev/donutTest.json`;
显示错误。
Table 'batter' not found
topping[0]
和batter
都是内嵌文档还是报错
尝试使用 table 别名,然后在 select 语句中引用它。
select donut.batter.id as batter_id, donut.batter.type as batter_type from dfs.`/home/dev/donutTest.json` as donut;
这样 Drill 就会引用实际的 table 别名,然后是下面的嵌套结构。