Import Table From Sqoop to Hive Without Data

The below command helps in creating a table in Hive based on the MySQL table’s definition. 

sqoop create-hive-table
–connect=jdbc:mysql://localhost/retail_db
–username=root
–password=cloudera
–table employees
–hive-table emp;

sqoop_cmd
This will just create the table structure in Hive as “Emp” based on MySQL’s Employees table’s structure and no data will be imported. 

mysql_emp_scr

hive_emp_scr

If you look at the above screens, the data types are converted automatically. The varchar became string and the decimal became “double” in Hive. 

Before implementing, make sure the table “Employees” exists in MySQL retail_db database and the table “Emp” does not exists in Hive. By default, the table will be imported in “default” database in Hive.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s