Getting an IO Exception when submitting sqoop import command

Hi Experts,

I am getting an IO Exception error saying, “Encountered IOException running import job: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://quickstart.cloudera:8020/user/cloudera/departments already exists”.
Earlier when I tried a day before doing import for the first time it was working fine, but today its not working fine.

Here’s the sqoop import command I am using(this if from github a/c):
sqoop import \

–connect “jdbc:mysql://quickstart.cloudera:3306/retail_db”
–table departments
–hive-home /user/hive/warehouse
–hive-table departments_test
–outdir java_files
Please let me know what is going wrong here.

There is dir in cloudera user space where Hive stages data during Hive import.
FileAlreadyExistsException: Output directory hdfs://quickstart.cloudera:8020/user/cloudera/departments already exists".
Delete this dir rerun. It will work.

Thanks! But could you explain what is the logic behind that directory. Does it use the same directory irrespective of the import location?

The directory is determined based on the user(user’s home directory) the sqoop command is being run and the table name. In this case the job was run by cloudera user and table name is departments. Hence the directory is hdfs://quickstart.cloudera:8020/user/cloudera/departments. You can sepcify a different directory with --target-dir option…

Thank you so much for the explanation!