question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR: text "<SINGLE QUOTE>2016-08-1" is not like DateTime

See original GitHub issue

This is the error I see in clickhouse when trying to batch insert

2019.04.17 00:08:45.729957 [ 264 ] {0e04b028-f581-4c85-a668-1b3c1d744863} <Error> HTTPHandler: Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected \t before: \'2016-08-12 13:21:32\'\t32767\t\'163.172.36.163\'\t\'185.229.191.169\'\t1522\t1\t0\t0\t0\t1000003\t1000010\t8080\t12724\t16\t\'128110002367193\'\t\'116530121835\'\t968\t968\t968\t\'\'\t\'Amste: (at row 1)

Row 1:
Column 0,   name: received_at,     type: DateTime, ERROR: text "<SINGLE QUOTE>2016-08-1" is not like DateTime

I’m using the same code as is in test here https://github.com/yandex/clickhouse-jdbc/blob/d75f1594b9eebcab200b27bc426b136233b1b927/src/test/java/ru/yandex/clickhouse/integration/BatchInsertsTest.java#L99 Even the same value.

Thus I blame the newer ClickHouse version I’m running (19.4.3.11).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
Baoqicommented, Apr 18, 2019

I also encountered this issue today, as it turns out, when you use prepared statement to batch insert values, if you see

Like '163.172.83.181' instead of 163.172.83.181

it means in PreparedStatementParser.java, your sql is not classified as “valuesMode”.

https://github.com/yandex/clickhouse-jdbc/blob/master/src/main/java/ru/yandex/clickhouse/PreparedStatementParser.java#L19

    private static final Pattern VALUES = Pattern.compile(
"(?i)INSERT\\s+INTO\\s+.+VALUES\\s*\\(");

Then, it turns out my SQL is multiple line. like:

insert into table1
  (col1, col2)
values
  (?, ?)

this will not match the regex. So, my work around is, before send sql to clickhouse’s prepare, I replace all \r \n with empty space. Then, the datetime can be inserted into database successfully.

Is this also your case?

0reactions
DipalPrajapaticommented, Nov 26, 2021

I am also facing this issues. And I really do not want to convert string to Date using dateformat in java code? In 2 columns Caused by: java.lang.Throwable: Code: 27, e.displayText() = DB::Exception: Cannot parse input: expected ‘\n’ before: ‘56300000083\t2021-11-10T20:37:08\n+256300000084\t2021-11-10T16:01:01\n+256300000085\t2021-11-10T14:34:16\n+256300000086\t2021-11-10T08:35:05\n+256300000087\t2021-11-10T1’: (at row 83)

Row 82:

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR: text "<SINGLE QUOTE>2016-08-1" is not like DateTime
This is the error I see in clickhouse when trying to batch insert ... ERROR: text "<SINGLE QUOTE>2016-08-1" is not like DateTime #333....
Read more >
ValueError: time data '2022-04-18T10:00:00-07:00' does not ...
I have a datetime.datetime object that gets stored as text in a text file. ... format doesn't work because the time data is...
Read more >
How to correct a #VALUE! error in the DATEVALUE function
Solution: Make sure that your system's date and time settings (both Short time and Long time) matches the date format in the date_text...
Read more >
Convert a String to a datetime or time Object in Python Using ...
The Python datetime module includes the datetime.strptime() class method to convert a string to a datetime object.
Read more >
DateTime conversion error in a custom script (4210498)
Cause. The string that is being converted into a DateTime has the wrong format, and it is not being converted correctly. Resolution.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found