<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Could not get current time from database in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294224#M217136</link>
    <description>&lt;P&gt;Glad things are moving forward for you, Heri.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examining your sqoop command, I notice the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;--&lt;SPAN&gt;check-column EventTime &lt;/SPAN&gt;&lt;/EM&gt;tells sqoop to check this column as the timestamp column for select logic&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;--incremental lastmodified&lt;/EM&gt; tells sqoop that your source SQL table can have both records added to it AND records updated in it. Sqoop assumes that when a record is updated or added its EventTime is set to current timestamp.&lt;/LI&gt;&lt;LI&gt;When you run this job for the first time, sqoop will pickup ALL records available (initial load). It will then print out a &lt;EM&gt;--last-value&lt;/EM&gt; timestampX.&amp;nbsp; This timestamp is the cutoff point for the next run of the job (i.e. next time you run the job with &lt;EM&gt;--exec incjob&lt;/EM&gt;, it will set &lt;EM&gt;--last-value timestampX&lt;/EM&gt;)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, to answer your question, it looks like sqoop is treating your job as an incremental load on the first run:&amp;nbsp;&lt;SPAN&gt;[EventTime] &amp;lt; '2020-04-17 08:51:00.54'. When this job is kicked off again, it should pickup records from where it left off automatically.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you want, you can provide a manual --last-value timestamp for the initial load, but make sure you don't use it on subsequent incremental loads.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;For more details, please review sections 7.2.7 and 11.4 of &lt;A href="https://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html" target="_self"&gt;Sqoop Documentation&lt;/A&gt; &amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;If this is helpful, don't forget to give kudos and accept the solution. Thank you!&lt;/P&gt;</description>
    <pubDate>Fri, 17 Apr 2020 16:35:43 GMT</pubDate>
    <dc:creator>aakulov</dc:creator>
    <dc:date>2020-04-17T16:35:43Z</dc:date>
    <item>
      <title>Could not get current time from database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/293861#M216918</link>
      <description>&lt;P&gt;I'm trying to run an incremental import job on SQL Server:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sqoop job --create incjob \&lt;BR /&gt;-- import \&lt;BR /&gt;--connect 'jdbc:jtds:sqlserver://SQLQP002:1433;useNTLMv2=true;domain=JNL_NT;databaseName=TC31Reporting' \&lt;BR /&gt;--driver net.sourceforge.jtds.jdbc.Driver \&lt;BR /&gt;--username lrm0613 \&lt;BR /&gt;-P \&lt;BR /&gt;--table JobHistory \&lt;BR /&gt;--incremental lastmodified \&lt;BR /&gt;--check-column JobId \&lt;BR /&gt;--hcatalog-database dataengsandbox \&lt;BR /&gt;--hcatalog-table JobHistory \&lt;BR /&gt;-m 1 \&lt;BR /&gt;--merge-key JobId&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;When I run the job, I get the following error:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$ sqoop job --exec incjob&lt;BR /&gt;Warning: /opt/cloudera/parcels/CDH-5.14.2-1.cdh5.14.2.p0.3/bin/../lib/sqoop/../accumulo does not exist! Accumulo imports will fail.&lt;BR /&gt;Please set $ACCUMULO_HOME to the root of your Accumulo installation.&lt;BR /&gt;20/04/13 15:58:43 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.14.2&lt;BR /&gt;Enter password:&lt;BR /&gt;20/04/13 15:58:48 WARN tool.BaseSqoopTool: Input field/record delimiter options are not used in HCatalog jobs unless the format is text. It is better to use --hive-import in those cases. For text formats&lt;BR /&gt;20/04/13 15:58:48 WARN tool.BaseSqoopTool: Output field/record delimiter options are not useful in HCatalog jobs for most of the output types except text based formats is text. It is better to use --hive-import in those cases. For non text formats,&lt;BR /&gt;20/04/13 15:58:48 WARN sqoop.ConnFactory: Parameter --driver is set to an explicit driver however appropriate connection manager is not being set (via --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which connection manager should be used next time.&lt;BR /&gt;20/04/13 15:58:48 INFO manager.SqlManager: Using default fetchSize of 1000&lt;BR /&gt;20/04/13 15:58:48 INFO tool.CodeGenTool: Beginning code generation&lt;BR /&gt;20/04/13 15:58:48 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM JobHistory AS t WHERE 1=0&lt;BR /&gt;20/04/13 15:58:48 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM JobHistory AS t WHERE 1=0&lt;BR /&gt;20/04/13 15:58:48 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce&lt;BR /&gt;Note: /tmp/sqoop-lrm0613/compile/f11a4812c94c4f349a579536733c37cb/JobHistory.java uses or overrides a deprecated API.&lt;BR /&gt;Note: Recompile with -Xlint:deprecation for details.&lt;BR /&gt;20/04/13 15:58:52 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-lrm0613/compile/f11a4812c94c4f349a579536733c37cb/JobHistory.jar&lt;BR /&gt;20/04/13 15:58:53 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM JobHistory AS t WHERE 1=0&lt;BR /&gt;20/04/13 15:58:53 ERROR manager.SqlManager: SQL exception accessing current timestamp: net.sourceforge.jtds.jdbc.AQSQLException: Id 102, Level 15, State 1, Line 1&lt;BR /&gt;Incorrect syntax near ')'.&lt;BR /&gt;net.sourceforge.jtds.jdbc.AQSQLException: Id 102, Level 15, State 1, Line 1&lt;BR /&gt;Incorrect syntax near ')'.&lt;BR /&gt;at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:377)&lt;BR /&gt;at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)&lt;BR /&gt;at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2335)&lt;BR /&gt;at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:653)&lt;BR /&gt;at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)&lt;BR /&gt;at net.sourceforge.jtds.jdbc.JtdsStatement.executeQuery(JtdsStatement.java:1304)&lt;BR /&gt;at org.apache.sqoop.manager.SqlManager.getCurrentDbTimestamp(SqlManager.java:987)&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.initIncrementalConstraints(ImportTool.java:334)&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:504)&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)&lt;BR /&gt;at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:244)&lt;BR /&gt;at org.apache.sqoop.tool.JobTool.run(JobTool.java:299)&lt;BR /&gt;at org.apache.sqoop.Sqoop.run(Sqoop.java:147)&lt;BR /&gt;at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)&lt;BR /&gt;at org.apache.sqoop.Sqoop.main(Sqoop.java:252)&lt;BR /&gt;20/04/13 15:58:53 ERROR tool.ImportTool: Import failed: java.io.IOException: &lt;STRONG&gt;Could not get current time from database&lt;/STRONG&gt;&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.initIncrementalConstraints(ImportTool.java:336)&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:504)&lt;BR /&gt;at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)&lt;BR /&gt;at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:244)&lt;BR /&gt;at org.apache.sqoop.tool.JobTool.run(JobTool.java:299)&lt;BR /&gt;at org.apache.sqoop.Sqoop.run(Sqoop.java:147)&lt;BR /&gt;at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)&lt;BR /&gt;at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)&lt;BR /&gt;at org.apache.sqoop.Sqoop.main(Sqoop.java:252)&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 20:13:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/293861#M216918</guid>
      <dc:creator>Heri</dc:creator>
      <dc:date>2020-04-13T20:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Could not get current time from database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294014#M216996</link>
      <description>&lt;P&gt;From the log I see that sqoop ignored your specified jTDS JDBC driver and fell back to generic JDBC manager that may have conflicting syntax for getting timestamp from the database. To make sure sqoop uses your driver of choice, add the following parameter:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;--connection-manager org.apache.sqoop.manager.SQLServerManager &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another thing I noticed in your command is you are using &lt;STRONG&gt;--incremental lastmodified&lt;/STRONG&gt; with &lt;STRONG&gt;--check-column JobId&lt;/STRONG&gt;. This is asking sqoop to check timestamp in column &lt;EM&gt;JobId&lt;/EM&gt;, which I don't think is your intention. For more on this topic check seciont 7.2.9 in &lt;A href="https://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html" target="_self"&gt;sqoop documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 23:12:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294014#M216996</guid>
      <dc:creator>aakulov</dc:creator>
      <dc:date>2020-04-14T23:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Could not get current time from database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294213#M217131</link>
      <description>&lt;P&gt;Thanks a lot for your answer aakulov!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I changed the command to the following format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;qoop job \&lt;BR /&gt;-Dhadoop.security.credential.provider.path=jceks://hdfs/user/lrm0613/mydb2.jceks \&lt;BR /&gt;-Dsqoop.export.records.per.statement=1 \&lt;BR /&gt;--create incjob \&lt;BR /&gt;-- import \&lt;BR /&gt;--connect 'jdbc:jtds:sqlserver://SQLQP002:1433;useNTLMv2=true;domain=JNL_NT;databaseName=TC31Reporting' \&lt;BR /&gt;--username lrm0613 \&lt;BR /&gt;--password-alias sqlserver2.password \&lt;BR /&gt;--query 'select * from JobHistory where $CONDITIONS' \&lt;BR /&gt;--incremental lastmodified \&lt;BR /&gt;--check-column EventTime \&lt;BR /&gt;--hcatalog-database dataengsandbox \&lt;BR /&gt;--hcatalog-table JobHistory \&lt;BR /&gt;-m 1 \&lt;BR /&gt;--merge-key EventTime&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works now, however, I found that the query that it internally runs is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from JobHistory where [EventTime] &amp;lt; '2020-04-17 08:51:00.54' AND (1 = 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;8:51 is the time where I ran it, but not the time since the last row was inserted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will it then lose the rows inserted between the last time I ran it and now?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 12:56:19 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294213#M217131</guid>
      <dc:creator>Heri</dc:creator>
      <dc:date>2020-04-17T12:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Could not get current time from database</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294224#M217136</link>
      <description>&lt;P&gt;Glad things are moving forward for you, Heri.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Examining your sqoop command, I notice the following:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;--&lt;SPAN&gt;check-column EventTime &lt;/SPAN&gt;&lt;/EM&gt;tells sqoop to check this column as the timestamp column for select logic&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;--incremental lastmodified&lt;/EM&gt; tells sqoop that your source SQL table can have both records added to it AND records updated in it. Sqoop assumes that when a record is updated or added its EventTime is set to current timestamp.&lt;/LI&gt;&lt;LI&gt;When you run this job for the first time, sqoop will pickup ALL records available (initial load). It will then print out a &lt;EM&gt;--last-value&lt;/EM&gt; timestampX.&amp;nbsp; This timestamp is the cutoff point for the next run of the job (i.e. next time you run the job with &lt;EM&gt;--exec incjob&lt;/EM&gt;, it will set &lt;EM&gt;--last-value timestampX&lt;/EM&gt;)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, to answer your question, it looks like sqoop is treating your job as an incremental load on the first run:&amp;nbsp;&lt;SPAN&gt;[EventTime] &amp;lt; '2020-04-17 08:51:00.54'. When this job is kicked off again, it should pickup records from where it left off automatically.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you want, you can provide a manual --last-value timestamp for the initial load, but make sure you don't use it on subsequent incremental loads.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;For more details, please review sections 7.2.7 and 11.4 of &lt;A href="https://sqoop.apache.org/docs/1.4.2/SqoopUserGuide.html" target="_self"&gt;Sqoop Documentation&lt;/A&gt; &amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;If this is helpful, don't forget to give kudos and accept the solution. Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Apr 2020 16:35:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Could-not-get-current-time-from-database/m-p/294224#M217136</guid>
      <dc:creator>aakulov</dc:creator>
      <dc:date>2020-04-17T16:35:43Z</dc:date>
    </item>
  </channel>
</rss>

