Search code examples
sqoophortonworks-data-platform

Sqoop Import failed : Please specify one with --split-by or perform a sequential import with '-m 1' Error even after setting mapper = 1


I am importing a table from SQL Server to Hive.

sqoop import \
--connect "jdbc:sqlserver://<server-name>:<port-no>;database=<database-name>" \
--username <user-name> \
-P \
--table <table-name> \
-- --schema <schema-name> \
--hive-import \
--hive-database <hive-database-name> \
--hive-table <hive-table-name> \
--target-dir /tmp \
-m 1

The table does not have primary key so I have added -m 1 (to run one mapper), but I am still getiing error to set '-m 1'.

ERROR tool.ImportTool: Import failed: No primary key could be found for table. Please specify one with --split-by or perform a sequential import with '-m 1'.

I am working on a 3 node cluster and version details are:

Distribution : Hortonrowks HDP3.0

Sqoop : 1.4

Hive : 3.1


Solution

  • You have to use only one dash with m param: -m 1 (not --m 1) and move -- --schema <schema-name> to the end of command since the Sqoop CLI has the following structure:

    sqoop TOOL PROPERTY_ARGS SQOOP_ARGS [-- EXTRA_ARGS]