我使用Hive创建了以下HBase表,如下所示:
CREATE TABLE HBWeather (key struct<USAF:INT, WBAN:INT, `Date`:STRING>, TEMP INT)
ROW FORMAT DELIMITED
COLLECTION ITEMS TERMINATED BY '~'
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ('hbase.columns.mapping'=':key,T:Temp')
TBLPROPERTIES("hbase.table.name"="HBWeather", "hbase.mapred.output.outputtable"="HBWeather");
然后用数据填充:
Insert overwrite table HBWeather select NAMED_STRUCT('USAF',USAF, 'WBAN',WBAN,'Date', `Date`) key, TEMP from weather;
运行以下命令会返回预期结果:
select * from hbweather limited 10;
现在我的问题是,当我的键是struct时,如何按特定键过滤?例如,如果我想找到TEMF,其中USAF是400010,wban是99999,而date = &#39; 200906280000&#39;,如何编写?... 在对struct类型的键进行过滤时where子句的外观如何?
答案 0 :(得分:0)
select * from hbweather where key.usaf=400010 and key.wban=99999 and key.`date`='199906280000' limit 10;