Can I combine two or more columns while importing or exporting suppose i have 3 columns in DBMS ID, FIRST_NAME, LAST_NAME and i want to load it as ID,NAME only two columns. So how can I do that?
Asked
Active
Viewed 850 times
2 Answers
3
Try the below option
sqoop import --connect <db server> --username <user> --password <password> --query "select ID,CONCAT(FIRST_NAME,LAST_NAME) from table" --target-dir <hdfs directory>
Since you have'nt mentioned your database and table name I have written in generic form.

srinivasan Hariharan
- 355
- 1
- 10
-
thanks for reply i have tried it, but its giving only 0's in that column – Sumeet Jun 05 '14 at 04:07
-
Which DBMS you are using?. please provide the query for further analysis. Before running the query with sqoop run the query directly on database and check the query output. – srinivasan Hariharan Jun 05 '14 at 07:36
-
i am using MySQL it giving me same output all 0's in the same column i wrote select ID, fName+lName from employee; from termonal in ubuntu still it gives 0's in fName+lName column – Sumeet Jun 05 '14 at 11:29
-
Since you have not mentioned about your Database I gave generic concat syntax, But I beleive my answer is correct. Does it solved your problem?. – srinivasan Hariharan Jun 05 '14 at 13:33
0
thanks srinivasan got the solution
sqoop import --connect <db server> --username <user> --password <password> --query "select ID,concat(FIRST_NAME,LAST_NAME) from table" --target-dir <hdfs directory>

Sumeet
- 43
- 5