how to mapping phoenix table for hive

原文出处:

https://community.hortonworks.com/questions/1558/bestoptimized-way-to-move-data-from-phoenix-to-hiv.html

see a simple example below:


  1. PHOENIX:
  2. CREATE TABLE TEST(
  3. ID VARCHAR not null,
  4. TEXT VARCHAR
  5. CONSTRAINT PK PRIMARY KEY (ID)
  6. ) ;
  7.  
  8. HIVE:
  9. CREATE EXTERNAL TABLE TEST(ID int, TEXT string)
  10. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  11. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,0:TEXT")
  12. TBLPROPERTIES ("hbase.table.name" = "TEST");


A more complex example, with composite key and numeric data types:


  1. PHOENIX:
  2. CREATE TABLE TEST2(
  3. ID1 VARCHAR NOT NULL,
  4. ID2 VARCHAR NOT NULL,
  5. NUM DOUBLE,
  6. TEXT VARCHAR
  7. CONSTRAINT PK PRIMARY KEY (ID1, ID2)
  8. );
  9.  
  10. HIVE:
  11. CREATE EXTERNAL TABLE TEST2(KEY STRUCT<ID1:STRING, ID2:STRING>, NUM DOUBLE, TEXT STRING)
  12. ROW FORMAT DELIMITED
  13. COLLECTION ITEMS TERMINATED BY '\u0000'
  14. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
  15. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,0:NUM,0:TEXT",
  16. "hbase.table.default.storage.type" = "binary")
  17. TBLPROPERTIES ("hbase.table.name" = "TEST2");

你可能感兴趣的:(how to mapping phoenix table for hive)