Created 02-08-2019 02:58 PM
I am trying to import data from mysql to hdfs. While importing, I need all the string fields to have double quotes and non-string fields with no double quotes.
sqoop import \
--connect jdbc:mysql://<hostname>:3306/retail_db \
--username <user> \
--password <password> \
--target-dir /user/nikhilvemula/sqoop_import/retail_db/orders_test \
--num-mappers 1 \
--query "SELECT * FROM orders WHERE \$CONDITIONS and order_date LIKE '2014-01-%'" \
--enclosed-by '"' \
--null-string '\\N' \
--null-non-string '\\N' \
--delete-target-dir
Expected: 25876,2014-01-01 00:00:00.0,3414,"PENDING_PAYMENT"
Actual result I got: "25876","2014-01-01 00:00:00.0","3414","PENDING_PAYMENT"
Created 02-08-2019 02:58 PM
Kindly help me out
Created 02-19-2019 06:40 AM
Hello,
Your requirement can be fulfilled in two ways.
1. Using the below query.
--query "select order_id, order_date, order_customer_id, concat('\"', order_status, '\"') from orders WHERE \$CONDITIONS and order_date LIKE '2014-01-%'"
2. You can further process your actual output in spark and get your expected output.
Thanks