Can directly import data from RDBMS to Hive(Internal or external table)
-mysql
create table emp1(id int primary key,ename varchar(30) ,deptid int,job varchar(30),mgr varchar(30),hiredate date ,sal varchar(30),ts timestamp default current_timestamp on update current_timestamp);
--Hive
CREATE TABLE IF NOT EXISTS emp1 (id bigint,ename string ,deptid bigint,job string,mgr string,hiredate date ,sal string,ts timestamp ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
CREATE TABLE IF NOT EXISTS dept (deptid bigint, dname string,loc string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
sqoop job --create emp1 -- import --connect jdbc:mysql://localhost:3306/test --username root --password root --table emp1 --incremental lastmodified -check-column ts --merge-key id --fields-terminated-by "," --hive-import --hive-overwrite --hive-table test.emp1 -m 1
Copyright ©2022 coderraj.com. All Rights Reserved.