0

我有一个 Wrapped Array,并且只想在使用LATERAL VIEW EXPLODE查询时获得相应的值结构

样本结构:

列名:数组

WrappedArray([null,theVal,valTags,[123,null,null,null,null,null],false], [null,theVar,varTags,[abc,null,null,null,null,null],false])

架构是

array<struct<id:string,name:string,type:string,value:struct<member0:string,member1:bigint,member2:int,member3:double,member4:float,member5:boolean>,shouldIndex:boolean>>

我的查询:

SELECT DISTINCT theName, allValues
FROM table 
LATERAL VIEW EXPLODE(column.name) theTab1 AS theName
LATERAL VIEW EXPLODE(column.value.member0) theTab2 AS allValues
WHERE theName = 'theVal'

我的结果:

___________________________
|**theName**|**allValues**|
___________________________
|theVal     |     123     |
___________________________
| theVal    |     abc     |
___________________________

我需要:

___________________________
|**theName**|**allValues**|
___________________________
|theVal     |     123     |
___________________________

如何修复我的查询以获得上述结果?

4

1 回答 1

0

不需要在结构顶部进行额外的爆炸。你应该能够像这样执行

SELECT DISTINCT theName, column.value.member0
FROM table 
LATERAL VIEW EXPLODE(column.name) theTab1 AS theName
WHERE theName = 'theVal'
于 2018-09-26T08:00:11.523 回答