sqoop导入数据至hdfs错误 You have an error in your SQL syntax;

sqoop导入数据至hdfs错误 You have an error in your SQL syntax;,第1张

sqoop导入数据至hdfs错误 You have an error in your SQL syntax;
21/11/19 10:14:37 ERROR manager.SqlManager: Error executing statement: 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 'and   (1 = 0)' at line 36
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 'and   (1 = 0)' at line 36
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
	at com.mysql.jdbc.Util.getInstance(Util.java:386)
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2820)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2159)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2326)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:776)
	at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:785)
	at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:288)
	at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:259)
	at org.apache.sqoop.manager.SqlManager.getColumnTypesForQuery(SqlManager.java:252)
	at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:343)
	at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1879)
	at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1672)
	at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
	at org.apache.sqoop.tool.importTool.importTable(importTool.java:524)
	at org.apache.sqoop.tool.importTool.run(importTool.java:655)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:151)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
	at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:187)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:241)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:250)
	at org.apache.sqoop.Sqoop.main(Sqoop.java:259)
21/11/19 10:14:37 ERROR tool.importTool: import failed: java.io.IOException: No columns to generate for ClassWriter
	at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1678)
	at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:106)
	at org.apache.sqoop.tool.importTool.importTable(importTool.java:524)
	at org.apache.sqoop.tool.importTool.run(importTool.java:655)
	at org.apache.sqoop.Sqoop.run(Sqoop.java:151)
	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
	at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:187)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:241)
	at org.apache.sqoop.Sqoop.runTool(Sqoop.java:250)
	at org.apache.sqoop.Sqoop.main(Sqoop.java:259)


sqoop脚本倒了个小全量表报错
执行sql类似

select * from 小表

检查了数据库连接账户密码等基本问题后,还是报错

后来检查参数配置后发现 有个参数 --query “$2 and $CONDITIONS”
在执行的sql后面加了条件 and 1= 0

所以不得将上述执行sql改为类似

select * from 小表 where 1=1

然后就导入成功

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5574770.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存