Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution

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

Contributor

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

Accepted Solutions

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

@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.

6 REPLIES 6

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

@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.

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

Rising Star

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

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

Contributor

@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

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

Rising Star

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

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

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

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

Contributor

Thank you @Nandish B Naidu..!!

The solution worked.

Don't have an account?
Coming from Hortonworks? Activate your account here