Wednesday, November 18, 2015

Sqoop Import Eroor due to 'must contain '$CONDITIONS' in WHERE clause'

Sqoop import as parquet files fail with the following exceptions
$sqoop import --connect jdbc:mysql://127.0.0.1:3306/mysql --username root  --query 'select * from user where  $CONDITION'  --target-dir  /user/mapr/import-dir --as-parquetfile  -m 1

ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: Query [select * from user where 1=1 $CONDITION] must contain '$CONDITIONS' in WHERE clause
at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:300)
 at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1833)
ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter
 at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1651)
 at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:107)
 at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:478)
The right way to do it is
sqoop import --connect jdbc:mysql://127.0.0.1:3306/metastore --username root  --query "select * from TBLS where \$CONDITIONS"   --target-dir  /user/mapr/import_dir --as-parquetfile  -m 1
Post a Comment