<?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 ... '2018-01-31T19:01:09+00:00', which cannot be converted to a timestamp.&amp;quot; (PutSQL) in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/207343#M76731</link>
    <description>&lt;P&gt;Hi Hortonworks!&lt;/P&gt;&lt;P&gt;I'm facing issues with the &lt;STRONG&gt;insertion of timestamps in to a PostgreSQL database using PutSQL.&lt;/STRONG&gt; More specifically when trying to insert a date in the format '2018-01-31T19:01:09+00:00' in to a &lt;STRONG&gt;timestamptz&lt;/STRONG&gt; column I get the following error message:&lt;/P&gt;&lt;PRE&gt;2018-04-01 19:29:40,091 ERROR [Timer-Driven Process Thread-5] o.apache.nifi.processors.standard.PutSQL PutSQL[id=7997503a-0162-1000-ee81-a0361cad5e0c] Failed to update database for StandardFlowFileRecord[uuid=d02e8b39-e564-4c37-a08a-dab8931e9890,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1522615075930-15, container=default, section=15], offset=11492, length=163],offset=0,name=32836401373126,size=163] due to java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp; routing to failure: java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp
java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp
 at org.apache.nifi.processors.standard.PutSQL.setParameters(PutSQL.java:711)
 at org.apache.nifi.processors.standard.PutSQL.lambda$null$5(PutSQL.java:313)
 at org.apache.nifi.processor.util.pattern.ExceptionHandler.execute(ExceptionHandler.java:127)
 at org.apache.nifi.processors.standard.PutSQL.lambda$new$6(PutSQL.java:311)
 at org.apache.nifi.processors.standard.PutSQL.lambda$new$9(PutSQL.java:354)
 at org.apache.nifi.processor.util.pattern.PutGroup.putFlowFiles(PutGroup.java:91)
 at org.apache.nifi.processor.util.pattern.Put.onTrigger(Put.java:101)
 at org.apache.nifi.processors.standard.PutSQL.lambda$onTrigger$20(PutSQL.java:574)
 at org.apache.nifi.processor.util.pattern.PartialFunctions.onTrigger(PartialFunctions.java:114)
 at org.apache.nifi.processor.util.pattern.RollbackOnFailure.onTrigger(RollbackOnFailure.java:184)
 at org.apache.nifi.processors.standard.PutSQL.onTrigger(PutSQL.java:574)
 at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1122)
 at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147)
 at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
 at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:128)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.text.ParseException: Unparseable date: "2018-01-31T20:19:35+00:00"
 at java.text.DateFormat.parse(DateFormat.java:366)
 at org.apache.nifi.processors.standard.PutSQL.setParameter(PutSQL.java:911)
 at org.apache.nifi.processors.standard.PutSQL.setParameters(PutSQL.java:707)
 ... 21 common frames omitted
&lt;/PRE&gt;&lt;P&gt;I have tested the insertion of '2018-01-31T19:01:09+00:00' in to the timestamptz column from the command line and it works perfectly. I have tried various alternative formats such as: &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;'2018-01-31 19:01:09+00:00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31 19:01:09+00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31T19:01:09+00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31 19:01:09'&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;They all fail with the same error in Nifi, even though they are all inserted just fine when performing the INSERT from the command line. &lt;/P&gt;&lt;P&gt;Please find a screenshot of my flow attached. Let me know if you need any more details.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64980-screenshot-from-2018-04-01-20-25-44.png" style="width: 454px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16969iAF45A54B00FD1268/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64980-screenshot-from-2018-04-01-20-25-44.png" alt="64980-screenshot-from-2018-04-01-20-25-44.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have come across various questions regarding this topic, but I still don't get what is going on. Most notably:&lt;/P&gt;&lt;UL&gt;
 &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/42352064/putsql-date-format-error?rq=1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/42352064/putsql-date-format-error?rq=1&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/45685703/nifi-putsql-timestamp-datetime-error-cannot-be-converted-error/45701012" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/45685703/nifi-putsql-timestamp-datetime-error-cannot-be-converted-error/45701012&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/11133759/0000-00-00-000000-can-not-be-represented-as-java-sql-timestamp-error" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/11133759/0000-00-00-000000-can-not-be-represented-as-java-sql-timestamp-error&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/46702722/trying-to-solve-remove-the-timestamp-format-conversion-error-by-using-updateatt?noredirect=1&amp;amp;lq=1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/46702722/trying-to-solve-remove-the-timestamp-format-conversion-error-by-using-updateatt?noredirect=1&amp;amp;lq=1&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Fri, 16 Sep 2022 13:03:11 GMT</pubDate>
    <dc:creator>vincentvanouden</dc:creator>
    <dc:date>2022-09-16T13:03:11Z</dc:date>
    <item>
      <title>... '2018-01-31T19:01:09+00:00', which cannot be converted to a timestamp." (PutSQL)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/207343#M76731</link>
      <description>&lt;P&gt;Hi Hortonworks!&lt;/P&gt;&lt;P&gt;I'm facing issues with the &lt;STRONG&gt;insertion of timestamps in to a PostgreSQL database using PutSQL.&lt;/STRONG&gt; More specifically when trying to insert a date in the format '2018-01-31T19:01:09+00:00' in to a &lt;STRONG&gt;timestamptz&lt;/STRONG&gt; column I get the following error message:&lt;/P&gt;&lt;PRE&gt;2018-04-01 19:29:40,091 ERROR [Timer-Driven Process Thread-5] o.apache.nifi.processors.standard.PutSQL PutSQL[id=7997503a-0162-1000-ee81-a0361cad5e0c] Failed to update database for StandardFlowFileRecord[uuid=d02e8b39-e564-4c37-a08a-dab8931e9890,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1522615075930-15, container=default, section=15], offset=11492, length=163],offset=0,name=32836401373126,size=163] due to java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp; routing to failure: java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp
java.sql.SQLDataException: The value of the sql.args.5.value is '2018-01-31T20:19:35+00:00', which cannot be converted to a timestamp
 at org.apache.nifi.processors.standard.PutSQL.setParameters(PutSQL.java:711)
 at org.apache.nifi.processors.standard.PutSQL.lambda$null$5(PutSQL.java:313)
 at org.apache.nifi.processor.util.pattern.ExceptionHandler.execute(ExceptionHandler.java:127)
 at org.apache.nifi.processors.standard.PutSQL.lambda$new$6(PutSQL.java:311)
 at org.apache.nifi.processors.standard.PutSQL.lambda$new$9(PutSQL.java:354)
 at org.apache.nifi.processor.util.pattern.PutGroup.putFlowFiles(PutGroup.java:91)
 at org.apache.nifi.processor.util.pattern.Put.onTrigger(Put.java:101)
 at org.apache.nifi.processors.standard.PutSQL.lambda$onTrigger$20(PutSQL.java:574)
 at org.apache.nifi.processor.util.pattern.PartialFunctions.onTrigger(PartialFunctions.java:114)
 at org.apache.nifi.processor.util.pattern.RollbackOnFailure.onTrigger(RollbackOnFailure.java:184)
 at org.apache.nifi.processors.standard.PutSQL.onTrigger(PutSQL.java:574)
 at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1122)
 at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:147)
 at org.apache.nifi.controller.tasks.ContinuallyRunProcessorTask.call(ContinuallyRunProcessorTask.java:47)
 at org.apache.nifi.controller.scheduling.TimerDrivenSchedulingAgent$1.run(TimerDrivenSchedulingAgent.java:128)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
 at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
Caused by: java.text.ParseException: Unparseable date: "2018-01-31T20:19:35+00:00"
 at java.text.DateFormat.parse(DateFormat.java:366)
 at org.apache.nifi.processors.standard.PutSQL.setParameter(PutSQL.java:911)
 at org.apache.nifi.processors.standard.PutSQL.setParameters(PutSQL.java:707)
 ... 21 common frames omitted
&lt;/PRE&gt;&lt;P&gt;I have tested the insertion of '2018-01-31T19:01:09+00:00' in to the timestamptz column from the command line and it works perfectly. I have tried various alternative formats such as: &lt;/P&gt;&lt;UL&gt;
&lt;LI&gt;'2018-01-31 19:01:09+00:00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31 19:01:09+00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31T19:01:09+00'&lt;/LI&gt;&lt;LI&gt;'2018-01-31 19:01:09'&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;They all fail with the same error in Nifi, even though they are all inserted just fine when performing the INSERT from the command line. &lt;/P&gt;&lt;P&gt;Please find a screenshot of my flow attached. Let me know if you need any more details.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64980-screenshot-from-2018-04-01-20-25-44.png" style="width: 454px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16969iAF45A54B00FD1268/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64980-screenshot-from-2018-04-01-20-25-44.png" alt="64980-screenshot-from-2018-04-01-20-25-44.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have come across various questions regarding this topic, but I still don't get what is going on. Most notably:&lt;/P&gt;&lt;UL&gt;
 &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/42352064/putsql-date-format-error?rq=1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/42352064/putsql-date-format-error?rq=1&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/45685703/nifi-putsql-timestamp-datetime-error-cannot-be-converted-error/45701012" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/45685703/nifi-putsql-timestamp-datetime-error-cannot-be-converted-error/45701012&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/11133759/0000-00-00-000000-can-not-be-represented-as-java-sql-timestamp-error" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/11133759/0000-00-00-000000-can-not-be-represented-as-java-sql-timestamp-error&lt;/A&gt;&lt;/LI&gt; &lt;LI&gt;&lt;A href="https://stackoverflow.com/questions/46702722/trying-to-solve-remove-the-timestamp-format-conversion-error-by-using-updateatt?noredirect=1&amp;amp;lq=1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/46702722/trying-to-solve-remove-the-timestamp-format-conversion-error-by-using-updateatt?noredirect=1&amp;amp;lq=1&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 16 Sep 2022 13:03:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/207343#M76731</guid>
      <dc:creator>vincentvanouden</dc:creator>
      <dc:date>2022-09-16T13:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: ... '2018-01-31T19:01:09+00:00', which cannot be converted to a timestamp." (PutSQL)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/207344#M76732</link>
      <description>&lt;P&gt;I resolved this by using an ExecuteStreamCommand processor which calls a python script which converts a JSON line in to it's respective SQL insert statement. The table of interest in this case is `reddit_post`. &lt;/P&gt;&lt;P&gt;Code of the python script (I'm aware that there is no need for the `INSERT` argument, but this is there because I plan on adding an `UPDATE` option later on): &lt;/P&gt;&lt;PRE&gt;import json
import argparse
import sys

# For command line arguments
parser = argparse.ArgumentParser(description='Converts JSON to respective SQL statement')
parser.add_argument('statement_type', type=str, nargs=1)
parser.add_argument('table_name', type=str, nargs=1)

# Reading the command line arguments
statement_type = parser.parse_args().statement_type[0]
table_name = parser.parse_args().table_name[0]

# Initialize SQL statement 
statement = ''

for line in sys.stdin:
  # Load JSON line
  lineJSON = json.loads(line)

  # Add table name and SQL syntax
  if statement_type == 'INSERT':
    statement += 'INSERT INTO {} '.format(table_name)

  # Add table parameters and SQL syntax
  statement += '({}) '.format(', '.join(lineJSON.keys()))

  # Add table values and SQL syntax
  # Note that strings are formatted with single quotes, other data types are converted to strings (for the join method)
  statement += "VALUES ({});".format(', '.join("'{0}'".format(value) if type(value) == str else str(value) for value in lineJSON.values()))

  # Send statement to stdout
  print(statement)
&lt;/PRE&gt;&lt;P&gt;Configuration of ExecuteStreamCommand (Note that Argument Delimeter is set to a single space)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65001-configuration-executestreamcommand.png" style="width: 1003px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16967i40827A22A5B2F41D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65001-configuration-executestreamcommand.png" alt="65001-configuration-executestreamcommand.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Flow snippet:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="65002-flow-snippet.png" style="width: 493px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/16968iD3B71AD10C24B1F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="65002-flow-snippet.png" alt="65002-flow-snippet.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope this can help someone that came across a similar issue. If you have any advice on how to improve the script, flow, or anything else please don't hesitate to let me know! &lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 04:34:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/207344#M76732</guid>
      <dc:creator>vincentvanouden</dc:creator>
      <dc:date>2019-08-18T04:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: ... '2018-01-31T19:01:09+00:00', which cannot be converted to a timestamp." (PutSQL)</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/382739#M76733</link>
      <description>&lt;P&gt;if Google sends you here, most probably you're looking for&amp;nbsp;&lt;A href="https://community.cloudera.com/t5/Support-Questions/PUTSQL-which-cannot-be-converted-to-a-timestamp/m-p/292827" target="_blank"&gt;https://community.cloudera.com/t5/Support-Questions/PUTSQL-which-cannot-be-converted-to-a-timestamp/m-p/292827&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 15:01:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/2018-01-31T19-01-09-00-00-which-cannot-be-converted-to-a/m-p/382739#M76733</guid>
      <dc:creator>jonay__reyes</dc:creator>
      <dc:date>2024-01-25T15:01:17Z</dc:date>
    </item>
  </channel>
</rss>

