为什么在Hive中基于hbase表创建内部表时出错?

时间:2016-05-12 15:26:22

标签: hive hbase

我有一个hbase表,我想把它映射到一个hive表。问题是当我在配置单元中使用外部表时,它将完成,但是当我想在配置单元中创建内部表时,它会引发异常:

message:Table yourtable *already exists within HBase*; use CREATE EXTERNAL TABLE instead to register it in Hive

使用的命令:

CREATE TABLE A
(key string, date_time timestamp)   
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
WITH SERDEPROPERTIES ( "hbase.columns.mapping" = "
               :key,
               :timestamp
                )
TBLPROPERTIES("hbase.table.name" = "yourtable"); 

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您可能正在使用的Hive版本不支持您可能正在使用的标记。

CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name    -- (Note: TEMPORARY available in Hive 0.14.0 and later)
  [(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]
  [SKEWED BY (col_name, col_name, ...)                  -- (Note: Available in Hive 0.10.0 and later)]
     ON ((col_value, col_value, ...), (col_value, col_value, ...), ...)
     [STORED AS DIRECTORIES]
  [
   [ROW FORMAT row_format] 
   [STORED AS file_format]
     | STORED BY 'storage.handler.class.name' [WITH SERDEPROPERTIES (...)]  -- (Note: Available in Hive 0.6.0 and later)
  ]
  [LOCATION hdfs_path]
  [TBLPROPERTIES (property_name=property_value, ...)]   -- (Note: Available in Hive 0.6.0 and later)
  [AS select_statement];   -- (Note: Available in Hive 0.5.0 and later; not supported for external tables)

参考:Create Table syntax

答案 1 :(得分:0)

Hive和HBase都使用相同的Metastore来存储表元数据。您遇到的问题是,在创建新的Hive托管(内部)表以指向HBase表时,Metastore拒绝创建具有相同名称的新HBase表,因为HBase表已存在。使用protected void btnHidden_Click(object sender, EventArgs e) { //Do Dropdown Stuff } ,您可以让Metastore只注册一个新的hive外部表,同时保持相同的现有HBase表。