我正在尝试将SQLServer中的数据提取到HDFS中。我正在使用使用lastmodified和merge-key策略的Sqoop增量方法。
以下是我的sqoop命令:
sqoop job --create job_name -- import \
--driver net.sourceforge.jtds.jdbc.Driver
--connect "my_connection_string(working for other sqoop jobs)" \
--username uname \
--password-file /path/to/hdfs/dir \
--table source_table \
--incremental lastmodified \
--check-column 'update_date_time_column' \
--split-by 'primary_key' --merge-key 'primary_key' \
--fields-terminated-by '\001' \
--target-dir 'hdfs_path'
--as-parquetfile
-m 20
我进行了一些搜索,发现了完全相同的错误,并尝试了以下链接中给出的解决方案:
https://community.hortonworks.com/questions/225880/sqoop-incremental-import-last-modified-error.html
根据链接,问题可能出在日期和时间上。因此,我添加了以下参数,
--map-column-java update_date_time_column=String
这不能解决问题:(
注意:FORFORM FOR update_date_time_column是MM / DD / YYYY HH:MM:SS AM / PM
我得到以下错误跟踪:
19/06/03 03:46:02 ERROR manager.SqlManager: SQL exception accessing current timestamp: java.sql.SQLException: Incorrect syntax near ')'.
java.sql.SQLException: Incorrect syntax near ')'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1304)
at org.apache.sqoop.manager.SqlManager.getCurrentDbTimestamp(SqlManager.java:986)
at org.apache.sqoop.tool.ImportTool.initIncrementalConstraints(ImportTool.java:334)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:504)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)
at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:244)
at org.apache.sqoop.tool.JobTool.run(JobTool.java:299)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
19/06/03 03:46:02 ERROR tool.ImportTool: Import failed: java.io.IOException: Could not get current time from database
at org.apache.sqoop.tool.ImportTool.initIncrementalConstraints(ImportTool.java:336)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:504)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)
at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:244)
at org.apache.sqoop.tool.JobTool.run(JobTool.java:299)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252
我是第一次提取表格。因此没有--last-value。
感谢帮助。