2
votes

I am importing mysql table to HBase using sqoop. Normally, HBase's row key is not consisted just by one column, it normally is a combination among two or three columns + the timestamp, e.g. row key = ${col1}${col2}${timestamp}.

I can't get it working using sqoop, just wondering does sqoop --hbase-row-key allow me to do something like --hbase-row-key=col1, col2, tiemstamp during the import, then my HBase row key will end up with three fields combination?

3

3 Answers

2
votes

I found the answer myself:

composite keys were added in sqoop 1.4.4: http://sqoop.apache.org/docs/1.4.4/SqoopUserGuide.html#idp3672480

1
votes

This command seems to import a composite key into hbase

sqoop \
import --verbose \
--connect "yourDatabase" \
--username yourUser \
--password-file yourPassword.password \
--table originTable \
--hbase-create-table \ 
--hbase-table destinationTable \
--column-family yourFamily \
--hbase-row-key keyExample1,keyExample2 

However this command has 2 problems in my opinion. As some people has pointed out the new key column is just a concatenation with underscore as separation of the --hbase-row-key defined. Besides the original columns that were specified as row-key are deleted from the imported data and just the composite key is inserted on the new table.

0
votes

does the composite keys and combine with delimiter, such as :

row key = col1_col2_col3