配置单元复杂数据类型查询 [英] Hive complex data type querying
本文介绍了配置单元复杂数据类型查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查询源表中的数据,但无法正确查看结果。
源表结构
c1 string,
c2 string,
c3 string,
temp1 struct
<
s1 : string,
s2 : string,
s3 : string,
temp2 : array<struct<as1 string,as2 :string>>
>
我有JSON格式的数据。
我的JSON数据格式如下
{"c1":"123","c2":"XYZ","c3":"IIK",
"temp1":{"s1":"low","s2":"45","s3":"yes"},
"temp2":[{"as1":"16-05-1992","as2":"fail"}]
}
根据我的表结构,我应该在结构中包含数组(结构)。但我拥有的数据并不是这样的。我有分别的结构和数组(结构)。现在,当我查询这个表时,我如期得到了列c1、c2、c3、s1、s2的所有记录,但我没有得到as1和as2列,而是在输出中得到了temp2本身为NULL。
我是不是错过了什么。我应该有像struct<array<struct>>
这样的数据,还是可以将struct
和array<struct>
分开,json serde会在阅读时注意
推荐答案
根据您的数据示例,应该是struct
和array<struct>
:
c1 string,
c2 string,
c3 string,
temp1 struct
<
s1 : string,
s2 : string,
s3 : string
>,
temp2 : array<struct<as1 string,as2 :string>>
单个JSON对象应在一行中,不支持多行JSON:
{"c1":"123","c2":"XYZ","c3":"IIK","temp1":"s1":"low","s2":"45","s3":"yes"},"temp2":[{"as1":"16-05-1992","as2":"fail"}]}
这篇关于配置单元复杂数据类型查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文