...
No Format |
---|
CREATE TABLE hbase_table_1(key int, value string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ( "hbase.columns.mapping" = ":key,cf:" ); FAILED: Error in metadata: java.lang.RuntimeException: MetaException(message:org.apache.hadoop.hive.serde2.SerDeException org.apache.hadoop.hive.hbase.HBaseSerDe: hbase column family 'cf:' should be mapped to map<string,?> but is mapped to string) |
Example with
...
Binary Columns
Relying on the default value of hbase.table.default.storage.type
:
...
No Format |
---|
CREATE TABLE hbase_table_1 (key int, value string, foobar double) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ( "hbase.columns.mapping" = ":key,cf:val#s,cf:foo", "hbase.table.default.storage.type" = "binary" ); |
Simple Composite Row
...
Keys
...
Info | ||
---|---|---|
|
...
As of Hive 0.13.0 |
Hive can read and write delimited composite keys to HBase by mapping the HBase row key to a hive Hive struct, and using the ROW FORMAT DELIMITED...COLLECTION ITEMS TERMINATED BY. Example:
Code Block |
---|
-- Create a table with a composite row key consisting of two string fields, delimited by '~' CREATE EXTERNAL TABLE delimited_example(key struct<f1:string, f2:string>, value string) ROW FORMAT DELIMITED COLLECTION ITEMS TERMINATED BY '~' STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ( 'hbase.columns.mapping'=':key,f:c1'); |
Complex Composite Row Keys and
...
HBaseKeyFactory
Info | |
---|---|
As of Hive 0.14.0 with HIVE-6411 (0.13.0 also supports complex composite keys, but using a different interface–see | |
server | ASF JIRA | key | HIVE-2599 for that interface)
For more complex use cases, hive Hive allows users to specify an HBaseKeyFactory which defines the mapping of a key to fields in a hive Hive struct. This can be configured using the property "hbase.composite.key.factory" in the SERDEPROPERTIES option:
...
"hbase.composite.key.factory" should be the fully qualified class name of a class implementing HBaseKeyFactory. See SampleHBaseKeyFactory2 for a fixed length example in the same package. This class must be on your classpath in order for the above example to work. TODO: place these in an accessible place; they're currently only in test code.
...