SHARE
TWEET

Untitled

a guest Jun 19th, 2017 42 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // On Hive Window
  2.  
  3. use problem5;
  4.  
  5. insert into table products_hive
  6.   values (1380,4,'something 1380','something 2',8.00,'not avaialble',3,'NOT APPLICABLE');
  7. insert into table products_hive
  8.   values (1381,4,'something 1380','something 2',8.00,'not avaialble',3,'NOT APPLICABLE');
  9.  
  10. // On MYSQL window
  11. create table products_external (
  12.   product_id int(11) primary Key,
  13.   product_grade int(11),
  14.   product_category_id int(11),
  15.   product_name varchar(100),
  16.   product_description varchar(100),
  17.   product_price float,
  18.   product_impage varchar(500),
  19.   product_sentiment varchar(100)
  20. );
  21.  
  22. // On Terminal
  23.  
  24. sqoop export \
  25.   --username "retail_dba" \
  26.   --password "cloudera" \
  27.   --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" \
  28.   --export-dir /user/hive/warehouse/problem5.db/products_hive/ \
  29.   --fields-terminated-by '\001' \
  30.   --input-null-non-string "null" \
  31.   --input-null-string "null" \
  32.   --update-mode allowinsert \
  33.   --update-key product_id \
  34.   --columns "product_id,product_category_id,product_name,product_description,product_price,product_impage,product_grade,product_sentiment" \
  35.   --table products_external;
  36.  
  37. // On Hive Window
  38.  
  39. insert into table products_hive
  40.   values (1382,4,'something 1380','something 2',8.00,'not avaialble',3,'NOT APPLICABLE');
  41. insert into table products_hive
  42.   values (1383,4,'something 1380','something 2',8.00,'not avaialble',3,'NOT APPLICABLE');
  43.  
  44. // On Terminal Window:
  45.  
  46. sqoop export \
  47.   --username "retail_dba" \
  48.   --password "cloudera" \
  49.   --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" \
  50.   --export-dir /user/hive/warehouse/problem5.db/products_hive/ \
  51.   --fields-terminated-by '\001' \
  52.   --input-null-non-string "null" \
  53.   --input-null-string "null" \
  54.   --update-mode allowinsert \
  55.   --update-key product_id \
  56.   --columns "product_id,product_category_id,product_name,product_description,product_price,product_impage,product_grade,product_sentiment" \
  57.   --table products_external;
  58.  
  59. // To Validate
  60. //  On Hive
  61. select count(*) from problem5.products_hive;
  62. // on MySQL
  63. select count(*) from products_replica;
RAW Paste Data
Top