过滤配置单元中的多个数组字段 table

Filtering on multiple array fields in a hive table

我有一个配置单元 table "Records" 具有以下结构:

recordid int
addresses array<map<string,string>>
knownnames array<map<string,string>>

addresses 数组包含地址的标准部分(门牌号、街道名称、城市、州),并且可能包含多个这些元素(如果一条记录有多个地址)。 knownnames 数组包含名字、中间名和姓氏,并且可能包含每个名称的多个(如果记录有别名)。

如何在我的 "records" table 中查询所有在 CA 中有任何地址且姓氏为 "Smith" 的记录?

我试过分解两个数组,但看起来配置单元不喜欢在 where 子句中包含来自 2 个不同数组的元素....

既然你完全改变了我不确定的问题;我得测试一下。

select recordid, cities, last_names
from (
  select recordid, cities
    , knownname.last_name as last_names
  from (
    select recordid, knownnames
      , address.city as cities
    from db.table
    lateral view explode(addresses) exptbl1 as address ) x
  lateral view explode(knownnames) exptbl2 as knownname
  where cities='CA' ) y
where last_names='Smith'