Exam4Training

Now import data from mysql table departments to this hive table. Please make sure that data should be visible using below hive command, select" from departments_hive

Now import data from mysql table departments to this hive table. Please make sure that data should be visible using below hive command, select" from departments_hive

Answer: Solution:

Step 1: Create hive table as said.

hive

show tables;

create table departments_hive(department_id int, department_name string);

Step 2: The important here is, when we create a table without delimiter fields. Then default delimiter for hive is ^A ( 01). Hence, while importing data we have to provide proper delimiter.

sqoop import

-connect jdbc:mysql://quickstart:3306/retail_db

~username=retail_dba

-password=cloudera

–table departments

–hive-home /user/hive/warehouse

-hive-import

-hive-overwrite

–hive-table departments_hive

–fields-terminated-by ‘