Support Questions

Find answers, ask questions, and share your expertise

In Sqoop import is there an option to overwrite or delete existing data in an hcatalog table

avatar
Expert Contributor

Hello,

My requirement is to overwrite (or delete prior to the import) the existing data in an hcatalog table during sqoop import.

It appears hive-overwrite and delete-target-dir arguments don't work for this purpose.

Any suggestions on how to do this.

Thanks.

2 REPLIES 2

avatar

@Raj B

If you are using HCatalog with Sqoop, then Sqoop Hive options that are not supported with HCatalog jobs includes (link😞

  • --hive-import
  • --hive-overwrite

Approach is to use hive-import instead of -hcatalog. For example,

sqoop import --connect jdbc:mysql://localhost/test --username root --password 'hr' --table sample --hive-import --hive-overwrite --hive-table sqoophive -m 1 --fields-terminated-by '\t' --lines-terminated-by '\n'

avatar
Contributor

Unfortunately "--hive-overwrite" option destroy hive table structure and re-create it after that which is not acceptable way.

The only way is:

1. hive> truncate table sample;

2. sqoop import --connect jdbc:mysql://yourhost/test --username test --password test01 --table sample --hcatalog-table sample