Hive外连HBase表

Hive外连HBase表

CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name
[(col_name data_type [COMMENT col_comment], ...)]
[COMMENT table_comment]
[PARTITIONED BY (col_name data_type
[COMMENT col_comment], ...)]
[CLUSTERED BY (col_name, col_name, ...)
[SORTED BY (col_name [ASC|DESC], ...)]
INTO num_buckets BUCKETS]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION hdfs_path]

连接HBase中已存在的表

CREATE EXTERNAL TABLE table_name(id int, value string)

STORED BY 'org.apache.Hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")

TBLPROPERTIES ("hbase.table.name" = "xyz");

红色地方根据实际情况修改,绿色地方对应HBase表,其中cf1代表列簇名,val代表列名,:key代表HBase的row赋予第一个字段,即上面例子中的红色标注的id。

相关推荐