Support Questions

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

Running a sqoop job with a --target-dir destination and a --hive-import clause does not create table in the target destination folder

avatar
Explorer

I am running a sqoop job which has a --query statement. This mandates a --target-dir clause, however when I provide a path say /user/xyz/sqoop_import/database/table1. However this path is not honored and instead the data is stored as a hive table in the warehouse folder hdfs://namenode:8020/apps/hive/warehouse/play.

Here is the Sqoop Job run:

sqoop import \

--connect "jdbc:sqlserver://xx.aa.dd.aa;databaseName=XYZ" \

--connection-manager org.apache.sqoop.manager.SQLServerManager \

--username XXXX \

--password XXXX \

--num-mappers 20 \

--query "select ID,name,x,y,z from TABLE1 where DT between '2018/01/01' and '2018/01/31' AND \$CONDITIONS" \

--split-by id \

--relaxed-isolation \

--target-dir /user/XXXX/sqoop_import/XYZ/2018/TABLE1 \

--fetch-size=100000 \ --hive-import \ --hive-table TABLE1 \

--hive-partition-key Reportdate \

--hive-partition-value Reportdate \

--as-parquetfile \

--compress \

--compression-codec org.apache.hadoop.io.compress.SnappyCodec;

1 REPLY 1

avatar
Master Guru

@Cody kamat

While running hive import target-dir argument value controls where the data needs to store temporarily before loading into Hive table, but target-dir doesn't create hive table in that location.

If you want to import to specific directory then use target-dir without hive-import argument and create hive table on top of HDFS directory.

(or)

Create Hive external table pointing to your target-dir then in sqoop import remove --create-hive-table argument and --target-dir.

For more info refer to this HCC thread regarding the same issue.