如何从 map(string,string) 字段中获取特定值?

how to obtain a particular value from a map(string,string) field?

我有一个 table 包含以下两列

event_detail 列的格式为 map(string,string)

我想获取event_detail

中有值(B)的访客数

查询行where event_detail["value(B)"] is not null:

select visitor_number
  from table
where event_detail["value(B)"] is not null

演示:

创建测试 table:

hive> create table test_t(visitor_number int,event_detail map<string,string>);
OK

加载数据:

hive> insert into test_t select 123, map("value(B)","Bye") union all  select 123, map("value(G)","Jet");
OK

Select 行值 (B):

hive> select visitor_number from test_t where event_detail["value(B)"] is not null;
OK
123