Koushik Chandra
Koushik Chandra

Reputation: 1491

How to import easily RDBMS data into HIVE partition tables

I have tables in my RDBMS. Now I have chosen 3rd column of that table as the partition column for my HIVE table.

Now how can I easily import my RDBMS table's data into HIVE table (considering the partition column)?

Upvotes: 0

Views: 6231

Answers (3)

Loganathan .R
Loganathan .R

Reputation: 21

For the dynamic partition you can use like

sqoop import \  
--connect "jdbc:mysql://quickstart.cloudera:3306/prac" \  
--username root \  
--password cloudera \  
--table <mysql -tablename> \  
--hcatalog-database <hive-databasename> \  
--hcatalog-table <hive-table name> \  

Upvotes: 0

mangesh shende
mangesh shende

Reputation: 21

it works only for static partitions. refer the below sqoop script for more details :

sqoop import 
--connect "jdbc:mysql://quickstart.cloudera:3306/prac" 
--username root 
--password cloudera 
--hive-import 
--query "select id,name,ts from student where city='Mumbai' and \$CONDITIONS" 
--hive-table prac.student 
--hive-partition-key city 
--hive-partition-value 'Mumbai'
--target-dir /user/mangesh/sqoop_import/student_temp5 
--split-by id 

Upvotes: 2

WestCoastProjects
WestCoastProjects

Reputation: 63022

Importing rdbms into hive may be achieved using sqoop.

Here is relevant info for importing into paritioned tables:

http://sqoop.apache.org/docs/1.4.4/SqoopUserGuide.html#_importing_data_into_hive

You can tell a Sqoop job to import data for Hive into a particular partition by specifying the --hive-partition-key and --hive-partition-value arguments. The partition value must be a string. Please see the Hive documentation for more details on partitioning.

Upvotes: 0

Related Questions