gpt4 book ai didi

arrays - Hive JSON数据 explode 选项不 explode 数组

转载 作者:行者123 更新时间:2023-12-02 21:01:07 24 4
gpt4 key购买 nike

我正在将Json数据插入Hive。这是格式-

A1 Array <
struct <
product array <
struct <
dim1 array < struct <> >
dim2 array < struct <> >
>
>
>>

在from table子句中,我使用explode作为:
Lateral view outer explode(A1.product) t1 as prod Lateral view outer explode(prod.dim1) t2 as prod_d1 Lateral view outer explode(prod.dim2) t3 as prod_d2

样本数据 :
A1["product":[{"productsku":"p_dmf_qs:click: page load","v2productname":"Quality Score - click: page load","v2productcategory":"DMF","productvariant":"(not set)","productbrand":"xxxx","productrevenue":"1000","localproductrevenue":null,"productprice":"100","productquantity":"1","productrefundamount":null,"productlistname":"(not set)","dim1":[],"dim2":[]}]]

当我在select语句中将t2和t3分别称为prod_d1和prod_d2时,我在结果中得到一个结构,而不是数组。
请帮我。它是一个嵌套结构。如果我没有第一个乘积数组,则可以轻松地将其称为A1.dim1和A1.dim2作为两个爆炸函数。请帮我。

最佳答案

select  t2.dim1,t2.dim2
...
Lateral view outer inline (A1) t1
Lateral view outer inline (t1.product) t2

关于arrays - Hive JSON数据 explode 选项不 explode 数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43180702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com