将配置单元hqlMap< string,string>转换为sql记录键值

pcww981p  于 2021-06-25  发布在  Hive
关注(0)|答案(1)|浏览(267)

我在 hive 里有以下情况。我有一个Map,叫做“out”,我运行这个查询。

select distinct coalesce(out["a"],aa_out["b"]) b, 'id' b_name
  from TABLE

我在sql中有完全相同的数据,只是这次我的数据显示为:

out RECORD  REPEATED    
out. key    STRING  NULLABLE    
out. value  STRING  NULLABLE

我想用sql编写完全相同的查询。但是,我不知道如何在sql中有效地使用键值记录实现相同的hive[]Map表示法。
任何想法(大查询)

t5zmwmid

t5zmwmid1#

SELECT distinct out_expanded.value b, 'id' b_name, from TABLE, 
UNNEST(out) as out_expanded 
WHERE coalesce(out_expanded.key = 'a', out_expanded.key = 'b');

相关问题