【发布时间】:2021-07-13 17:03:22
【问题描述】:
我有一个包含结构数组的表。有没有办法使用 like 运算符过滤此列中的记录?
hive> desc location;
location_list array<struct<city:string,state:string>>
hive> select * from location;
row1 : [{"city":"Hudson","state":"NY"},{"city":"San Jose","state":"CA"},{"city":"Albany","state":"NY"}]
row2 : [{"city":"San Jose","state":"CA"},{"city":"San Diego","state":"CA"}]
我正在尝试运行类似这样的查询,以仅过滤那些具有“NY”状态的记录。
hive> select * from location where location_list like '%"NY"%';
FAILED: SemanticException [Error 10014]: Line 1:29 Wrong arguments ''%"NY"%'': No matching method for class org.apache.hadoop.hive.ql.udf.UDFLike with (array<struct<city:string,state:string>>, string). Possible choices: _FUNC_(string, string)
注意:我可以通过对这个结构列进行横向视图和分解来做到这一点。但尽量避免它,因为我需要将此表与另一个不接受横向视图的表连接起来。
【问题讨论】:
标签: sql arrays struct hive hiveql