Sqoop --target-dir & ---warehouse-dir
Sqoop store imported data by 2 way:
When we import record from RDBMS to HDFS using Sqoop then Sqoop use two way to store imported record on HDFS. 1. --target-dir directory path here 2. --warehouse-dir directory path here Import data using --target-dir in Sqoop: By using --target-dir path of directory, Sqoop create a directory which work as table name (directory path) with imported files. Example -1: Sqoop import --connect jdbc:mysql://localhost/sales --username root --password password --table students --target-dir /user/YT/tarData --where country_name = ‘India’ -m 1 This import statement stored all those students in target directory location, who belongs to India.Import data using --warehouse-dir in Sqoop:
Sqoop create a directory which works as database directory and table name directory automatically created with imported files with in warehouse dir . So warehouse directory work like database directory for importing table.
Example:
Sqoop import
--connect jdbc:mysql://localhost/sales
--username root
--password sqoop_password
--table students
-m 1
--warehouse-dir /salesDB
--where country_name = ‘India’
--field-terminated-by ‘\t’
It create a salesDB directory at root (along with user) and put students directory with in salesDB.
~]$ hadoop fs –lsr /salesDB
Output of the above command will be as follow:
Found 3 items
drw-r--r-- 3 YT 0 2020-04-11 23:15 /salesDB/students-rw-r--r-- 3 YT 0 2020-04-10 23:11 /salesDB/students/_SUCCESS-rw-r--r-- 3 YT 110 2020-04-10 23:11 /salesDB/students/part-m-00000
Comments
Post a Comment