sqoop报错之 ERROR tool.ImportTool: Import failed: Partition key orddate cannot be a column to import.
出错原句为:
sqoop import \ --connect jdbc:mysql://192.168.56.111:3306/test \ --driver com.mysql.jdbc.Driver \ --query "select * from orders where orddate = '2020-11-10' and \$CONDITIONS" \ --username root \ --password root \ --delete-target-dir \ --hive-import \ --hive-database default \ --hive-table orderinfos \ --hive-partition-key 'orddate' \ --hive-partition-value '20201110' \ --target-dir /mytmp/orderinfos \ -m 1
原因:
orddate column is present in your SQLServer table.
+-------+------------+
| ordid | orddate |
+-------+------------+
| 1 | 2020-11-10 |
+-------+------------+
修改字段名字: alter table orders change orddate orderdate date not null ;
sqoop import \ --connect jdbc:mysql://192.168.56.111:3306/test \ --driver com.mysql.jdbc.Driver \ --query "select * from orders where orderdate = '2020-11-10' and \$CONDITIONS" \ --username root \ --password root \ --delete-target-dir \ --hive-import \ --hive-database default \ --hive-table orderinfos \ --hive-partition-key 'orddate' \ --hive-partition-value '20201110' \ --target-dir /mytmp/orderinfos \ -m 1