如果我有多个相似的表,例如:
表A:"users",列:user_name, user_id, user_address, etc etc
表B:"customers"列:customer_name, customer_id, customer_address, etc etc
表C:"employee"列:employee_name, employee_id, employe_address, etc etc
是否可能使用Sqoop将三个表导入到一个HBase或Hive表中?所以在导入之后,我有一个HBase表包含了表A,B,C中的所有记录?
发布于 2013-12-23 20:34:11
如果这些表有某种程度的关联,这是绝对可能的。Sqoop中可以使用一个自由形式的查询来实现这一点。在这种情况下,自由形式的查询将是一个联接。例如,当导入到Hive时:
sqoop import --connect jdbc:mysql:///mydb --username hue --password hue --query "SELECT * FROM users JOIN customers ON users.id=customers.user_id JOIN employee ON users.id = employee.user_id WHERE \$CONDITIONS" --split-by oozie_job.id --target-dir "/tmp/hue" --hive-import --hive-table hive-table同样,对Hbase而言:
sqoop import --connect jdbc:mysql:///mydb --username hue --password hue --query "SELECT * FROM users JOIN customers ON users.id=customers.user_id JOIN employee ON users.id = employee.user_id WHERE \$CONDITIONS" --split-by oozie_job.id --hbase-table hue --column-family c1所有这些的关键要素是所提供的SQL语句:
SELECT * FROM users JOIN customers ON users.id=customers.user_id JOIN employee ON users.id = employee.user_id WHERE \$CONDITIONS有关自由表单查询的更多信息,请查看imports。
https://stackoverflow.com/questions/18053240
复制相似问题