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 ‘01’

Step 3: Check-the data in directory.

hdfs dfs -Is /user/hive/warehouse/departments_hive

hdfs dfs -cat/user/hive/warehouse/departmentshive/part’

Check data in hive table.

Select * from departments_hive;

Latest CCA175 Dumps Valid Version with 96 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments