DevPerson
DevPerson

Reputation: 137

Import data from mysql using JOIN in Sqoop

When I try to import data from mysql database using sqoop

sqoop import --connect jdbc:mysql://100.107.57.141/mysql --username test -P --query 'SELECT FirstName, Education, Car_Details FROM emp e JOIN emp_test_new etn on e.id=etn.id) WHERE $CONDITIONS' --split-by id  --target-dir /home/join

I am getting below error:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') WHERE (1 = 0)' at line 1

17/08/05 12:04:25 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter

Upvotes: 0

Views: 737

Answers (2)

priya
priya

Reputation: 1

 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter.

use the below command for the above error:

 --driver com.mysql.jdbc.Driver

Upvotes: 0

Sandeep Singh
Sandeep Singh

Reputation: 7990

You are missing ( near JOIN ON condition.

Correct sytnatx:

sqoop import --connect jdbc:mysql://100.107.57.141/mysql --username test -P \
--query "SELECT e.FirstName, e.Education, e.Car_Details \
FROM emp e JOIN emp_test_new etn ON (e.id == etn.id) \
WHERE $CONDITIONS' --split-by id  --target-dir /home/join

Upvotes: 0

Related Questions