运行以下语句时出现错误Unrecognized argument --hive-partition-key
:
sqoop import
--connect 'jdbc:sqlserver://192.168.56.1;database=xyz_dms_cust_100;username-hadoop;password=hadoop'
--table e_purchase_category
--hive_import
--delete-target-dir
--hive-table purchase_category_p
--hive-partition-key "creation_date"
--hive-partition-value "2015-02-02"
已存在分区表。
Hive分区键(在您的示例中为creation_date
)在使用hive-import
时不应成为数据库表的一部分。当您尝试在具有分区的配置单元中创建表时,您不会在表架构中包括分区列。同样适用于sqoop hive-import
。
基于您的sqoop命令,我想您的SQLServer表中存在creation_date
列。如果是,则可能会出现此错误
ERROR tool.ImportTool: Imported Failed:
Partition key creation_date cannot be a column to import.
要解决此问题,我有两种解决方法:
示例:
您也可以尝试通过不同的步骤完成任务:sqoop import --connect jdbc:mysql://localhost:3306/hadoopexamples --query 'select City.ID, City.Name, City.District, City.Population from City where $CONDITIONS' --target-dir /user/XXXX/City --delete-target-dir --hive-import --hive-table City --hive-partition-key "CountryCode" --hive-partition-value "USA" --fields-terminated-by ',' -m 1
另一种方法:
INSERT OVERWRITE TABLE city_partition
PARTITION (CountryCode='USA')
SELECT id, name, district, population FROM city;
sqoop import --connect jdbc:mysql://localhost/akash
--username root
--P
--table mytest
--where "dob='2019-12-28'"
--columns "id,name,salary"
--target-dir /user/cloudera/
--m 1 --hive-table mytest
--hive-import
--hive-overwrite
--hive-partition-key dob
--hive-partition-value '2019-12-28'