您是否面临任何具体问题?查询对我来说看起来不错。
key表示您正在使用该字段作为表键。请记住,hive 表中的每个字段都可以映射到其中之一:
- 表键(使用 :key 作为选择器)
- 列族 (cf:)(Hive 中的 MAP 字段
- 柱子
回应您的评论:
hive> CREATE EXTERNAL TABLE hbase_table_2(key int, name string)
> STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
> WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:name")
> TBLPROPERTIES("hbase.table.name" = "nancy");
OK
Time taken: 5.106 seconds
hive> select * from hbase_table_2;
OK
Time taken: 0.077 seconds
hive> INSERT OVERWRITE TABLE hbase_table_2 SELECT * FROM demo WHERE id=1;
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_201308011237_0003, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201308011237_0003
Kill Command = /Users/miqbal1/hadoop-eco/hadoop-1.1.2/libexec/../bin/hadoop job -kill job_201308011237_0003
Hadoop job information for Stage-0: number of mappers: 1; number of reducers: 0
2013-08-01 16:29:21,832 Stage-0 map = 0%, reduce = 0%
2013-08-01 16:29:23,843 Stage-0 map = 100%, reduce = 0%
2013-08-01 16:29:24,849 Stage-0 map = 100%, reduce = 100%
Ended Job = job_201308011237_0003
1 Rows loaded to hbase_table_2
MapReduce Jobs Launched:
Job 0: Map: 1 HDFS Read: 256 HDFS Write: 0 SUCCESS
Total MapReduce CPU Time Spent: 0 msec
OK
Time taken: 8.392 seconds
hive>
这是我的 HBase 表:
hbase(main):017:0> scan 'nancy'
ROW COLUMN+CELL
1 column=cf:name, timestamp=1375354762803, value=tariq
1 row(s) in 0.0300 seconds