简体   繁体   English

Sqoop 导入错误 Error: java.io.IOException: SQLException in nextKeyValue

[英]Sqoop import error Error: java.io.IOException: SQLException in nextKeyValue

I have written a script to perform an incremental import of data from oracle table to HDFS directory.我编写了一个脚本来执行从 oracle 表到 HDFS 目录的数据增量导入。 I use the following sqoop command to do the import :我使用以下 sqoop 命令进行导入:

    sqoop -- import \
   --connect $JDBCconnectionString  \
   --username $dbUserName \
   --password-file $passwordLocal \
   --query 'select * from dmt_sim.dim_product WHERE $CONDITIONS' \
   --split-by "PRODUCT_TITLE" \
   --incremental append \
   --check-column "KEY" \
   --last-value "1" \
   --append \
   --fields-terminated-by '\t' \
   --target-dir /user/ksrinivasan/dmn_product

The values for the variables $JDBCconnectionString,$dbUserName, $passwordLocal is substituted during run so the connection to the oracle database and getting the boundary values all succeeds but when the job is started it throws an error.变量 $JDBCconnectionString,$dbUserName, $passwordLocal 的值在运行期间被替换,因此到 oracle 数据库的连接和获取边界值都成功,但是当作业启动时会引发错误。

16/01/25 06:19:29 INFO mapreduce.Job: Job job_1452256584707_106782 running in uber mode : false
06:19:36            16/01/25 06:19:29 INFO mapreduce.Job:  map 0% reduce 0%
06:20:07            16/01/25 06:20:00 INFO mapreduce.Job: Task Id : attempt_1452256584707_106782_m_000000_0, Status : FAILED
06:20:07            Error: java.io.IOException: SQLException in nextKeyValue
06:20:07                at org.apache.sqoop.mapreduce.db.DBRecordReader.nextKeyValue(DBRecordReader.java:277)
06:20:07                at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.nextKeyValue(MapTask.java:553)
06:20:07                at org.apache.hadoop.mapreduce.task.MapContextImpl.nextKeyValue(MapContextImpl.java:80)
06:20:07                at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.nextKeyValue(WrappedMapper.java:91)
06:20:07                at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
06:20:07                at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
06:20:07                at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:784)
06:20:07                at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
06:20:07                at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163)
06:20:07                at java.security.AccessController.doPrivileged(Native Method)
06:20:07                at javax.security.auth.Subject.doAs(Subject.java:415)
06:20:07                at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
06:20:07                at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
06:20:07            Caused by: java.sql.SQLSyntaxErrorException: ORA-00907: missing right parenthesis
06:20:07            
06:20:07                at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
06:20:07                at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
06:20:07                at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
06:20:07                at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
06:20:07                at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
06:20:07                at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
06:20:07                at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
06:20:07                at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:884)
06:20:07                at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1167)
06:20:07                at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1289)
06:20:07                at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3584)
06:20:07                at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
06:20:07                at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
06:20:07                at org.apache.sqoop.mapreduce.db.DBRecordReader.executeQuery(DBRecordReader.java:111)
06:20:07                at org.apache.sqoop.mapreduce.db.DBRecordReader.nextKeyValue(DBRecordReader.java:235)
06:20:07                ... 12 more
06:20:07            

So it nice if someone else has faced the same problem and they have some insight about how to debug this kinda issues ???因此,如果其他人遇到同样的问题并且他们对如何调试此类问题有一些见解,那就太好了???

nextKeyValue 中的 SQLException 这意味着在您执行时,源 KEY 列中没有最后一个值“1”。

Check for all the possible column's values as null and specially check for date column that may have date as '0000-00-00' and you were using in select clause of dmt_sim.dim_product.检查所有可能的列值是否为空,并特别检查日期列可能日期为“0000-00-00”并且您在 dmt_sim.dim_product 的选择子句中使用。

Identify the columns and apply if condition in select to replace null or date with something else(that you would able to recognized).识别列并应用 select 中的 if 条件以将 null 或 date 替换为其他内容(您将能够识别)。

It´s because the column used to split is not a numeric ("PRODUCT_TITLE").这是因为用于拆分的列不是数字(“PRODUCT_TITLE”)。

When Sqoop translate the query fails at give the intervals "PRODUCT_TITLE" >= xx <= yy当 Sqoop 翻译时,查询在给定间隔“PRODUCT_TITLE”>= xx <= yy 时失败

trait with a numeric field.带有数字字段的特征。

When execute the sentences include --verbose 2> file_log.log (it´s to see if the split sentences are correct)执行语句时包括 --verbose 2> file_log.log (它是查看拆分语句是否正确)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM