Skip to content

Bogus SqlParser warning for valid TIMESTAMP literal #2570

@lukaseder

Description

@lukaseder

Steps to reproduce

try (Statement s = connection.createStatement()) {
    try {
        s.executeUpdate("create table t (i int, t DateTime, primary key (i)) engine = MergeTree()");

        try (PreparedStatement p = connection.prepareStatement("insert into t (i, t) values (1, timestamp '2010-01-01 00:00:00')")) {
            System.out.println(p.executeUpdate());
        }
    }
    finally {
        s.executeUpdate("drop table if exists t");
    }
}

Error Log or Exception StackTrace

12:11:54,032  WARN [SqlParser                     ] - SQL syntax error at line: 1, pos: 42, extraneous input ''2010-01-01 00:00:00'' expecting {',', ')'}
1

Expected Behaviour

The valid timestamp literal should be accepted, and no warning should be logged. The same problem does not appear with other SQL contexts, e.g. in a projection:

try (PreparedStatement p = connection.prepareStatement("select timestamp '2010-01-01 00:00:00'")) {
    try (ResultSet rs = p.executeQuery()) {
        while (rs.next())
            System.out.println(rs.getTimestamp(1));
    }
}

This just prints:

12:13:20,688 DEBUG [StatementImpl                 ] - Query ID: 8032217b-ce97-46ca-9b29-02ec64d04224
2010-01-01 00:00:00.0

Environment

  • Client version: com.clickhouse:clickhouse-jdbc:0.9.2
  • Language version: OpenJDK Runtime Environment Temurin-21.0.7+6 (build 21.0.7+6-LTS)
  • OS: Microsoft Windows [Version 10.0.26100.4946]

ClickHouse Server

  • ClickHouse Server version: 25.4.4.25

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions