Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Sqoop Import-all-tables not working with target-dir option.

avatar
Rising Star

While trying to use import-all-tables if i specify the target-dir , i'm getting the below error.

$ sqoop import-all-tables --connect jdbc:mysql://localhost/db --username root --target-dir 'alltables/data' -m 1 

17/08/14 14:08:07 ERROR tool.BaseSqoopTool: Error parsing arguments for import-all-tables:

17/08/14 14:08:07 ERROR tool.BaseSqoopTool: Unrecognized argument: --target-dir 

17/08/14 14:08:07 ERROR tool.BaseSqoopTool: Unrecognized argument: alltables/data 

17/08/14 14:08:07 ERROR tool.BaseSqoopTool: Unrecognized argument: -m 

17/08/14 14:08:07 ERROR tool.BaseSqoopTool: Unrecognized argument: 1

Appreciate any help.!!

1 ACCEPTED SOLUTION

avatar

@Ramya

Please follow this official documentation of Sqoop.

--target-dir is not a valid option when using import-all-tables. Thus you cannot use this.

View solution in original post

6 REPLIES 6

avatar

@Ramya

Please follow this official documentation of Sqoop.

--target-dir is not a valid option when using import-all-tables. Thus you cannot use this.

avatar
Expert Contributor

Checking the official documentation link here. they suggest that each table will create automatically a separate folder for the outcome to store the data in the default HDFS path for the user who perform the operation.

$ sqoop import-all-tables --connect jdbc:mysql://db.foo.com/corp

$ hadoop fs -ls
Found 4 items
drwxr-xr-x   - someuser somegrp       0 2010-04-27 17:15 /user/someuser/EMPLOYEES
drwxr-xr-x   - someuser somegrp       0 2010-04-27 17:15 /user/someuser/PAYCHECKS
drwxr-xr-x   - someuser somegrp       0 2010-04-27 17:15 /user/someuser/DEPARTMENTS
drwxr-xr-x   - someuser somegrp       0 2010-04-27 17:15 /user/someuser/OFFICE_SUPPLIES

avatar
Rising Star

@Andres Urrego

Thank you..!!

Yes. But when we are using only 'Import' instead of 'Import-all-tables', we can specify where to store the table, instead of the default HDFS path using --target-dir .

As per below code, the data is imported to the target directory specified.

sqoop import --connect jdbc:mysql://localhost/my_db --table EMP --username root --target-dir 'sqoopdata/emp' -m 1

avatar
Expert Contributor

yes exactly you right but this is only in import as --export-dir for export operation 🙂 this how that works

avatar
New Contributor

Hi Ramya

To import all tables in particular directory, Use --warehouse-dir <directory> instead of --target-dir <directory>

example:

sqoop import --connect jdbc:mysql://localhost/test --table test1 --username xxxxx -P --warehouse-dir /home/user/Desktop/sqoopdump -m 1

avatar
Rising Star

Thank you @Nandish B Naidu..!!

The solution worked.