8

Is it possible to overwrite HDFS directory automatically instead of overwriting it every time manually while Sqoop import? (Do we have any option like "--overwrite" like we have for hive import "--hive-overwrite")

Abhinav Singh
  • 109
  • 1
  • 2
  • 10

2 Answers2

16

Use --delete-target-dir

​It will delete <HDFS-target-dir> provided in command before writing data to this directory.

Dev
  • 13,492
  • 19
  • 81
  • 174
6

Use this: --delete-target-dir

This will work for overwriting the hdfs directory using sqoop syntax:

$ sqoop import --connect jdbc:mysql://localhost/dbname --username username -P --table tablename --delete-target-dir --target-dir '/targetdirectorypath' -m 1

E.g:

$ sqoop import --connect jdbc:mysql://localhost/abc --username root -P --table empsqooptargetdel --delete-target-dir --target-dir '/tmp/sqooptargetdirdelete' -m 1

This command will refresh the corresponding hdfs directory or hive table data with updated/fresh data, every time this command is run.

Arya McCarthy
  • 8,554
  • 4
  • 34
  • 56
adarikrishna
  • 80
  • 1
  • 4