Please import data in a non-existing table, means while importing create hive table named hadoopexam.departments_new
Please import data in a non-existing table, means while importing create hive table named hadoopexam.departments_new
Answer: Solution:
Step 1: Go to hive interface and create database.
hive
create database hadoopexam;
Step 2. Use the database created in above step and then create table in it. use hadoopexam; show tables;
Step 3: Create table in it.
create table departments (department_id int, department_name string);
show tables;
desc departments;
desc formatted departments;
Step 4: Please check following directory must not exist else it will give error, hdfs dfs -Is /user/cloudera/departments
If directory already exists, make sure it is not useful and than delete the same.
This is the staging directory where Sqoop store the intermediate data before pushing in hive table.
hadoop fs -rm -R departments
Step 5: Now import data in existing table
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 hadoopexam.departments
Step 6: Check whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments;
desc formatted departments;
Step 7: Import data in non-existing tables in hive and create table while importing.
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 hadoopexam.departments_new
-create-hive-table
Step 8: Check-whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments_new;
desc formatted departments_new;
Latest CCA175 Dumps Valid Version with 96 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund