千家信息网

Hive外连HBase表

发表于:2025-01-31 作者:千家信息网编辑
千家信息网最后更新 2025年01月31日,CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name[(col_name data_type [COMMENT col_comment], ...)][
千家信息网最后更新 2025年01月31日Hive外连HBase表
  1. CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name
  2. [(col_name data_type [COMMENT col_comment], ...)]
  3. [COMMENT table_comment]
  4. [PARTITIONED BY (col_name data_type
  5. [COMMENT col_comment], ...)]
  6. [CLUSTERED BY (col_name, col_name, ...)
  7. [SORTED BY (col_name [ASC|DESC], ...)]
  8. INTO num_buckets BUCKETS]
  9. [ROW FORMAT row_format]
  10. [STORED AS file_format]
  11. [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。

0