我可以使用sqoop将RDBMS表数据(表没有主键)导入hive吗?如果是,那么请你给sqoop import命令.
我已尝试使用sqoop import general命令,但失败了.
Pra*_*ode 18
如果您的表没有定义主键,那么您必须提供-m 1导入数据的选项,或者您必须提供--split-by带有某些列名的参数,否则它会给出错误:
ERROR tool.ImportTool: Error during import: No primary key could be found for table <table_name>. Please specify one with --split-by or perform a sequential import with '-m 1'
Run Code Online (Sandbox Code Playgroud)
然后你的sqoop命令看起来像
sqoop import \
--connect jdbc:mysql://localhost/test_db \
--username root \
--password **** \
--table user \
--target-dir /user/root/user_data \
--columns "first_name, last_name, created_date"
-m 1
Run Code Online (Sandbox Code Playgroud)
要么
sqoop import \
--connect jdbc:mysql://localhost/test_db \
--username root \
--password **** \
--table user \
--target-dir /user/root/user_data \
--columns "first_name, last_name, created_date"
--split-by created_date
Run Code Online (Sandbox Code Playgroud)