镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Bogus SqlParser warning for valid TIMESTAMP literal #2570

Closed

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

Activity

  1. lukaseder commented on Sep 9, 2025

    @lukaseder
    Author

    Note this also happens for DATE literals, and probably other types? E.g.

    try (Statement s = connection.createStatement()) {
        try {
            s.executeUpdate("create table t (i int, t Date, primary key (i)) engine = MergeTree()");
    
            try (PreparedStatement p = connection.prepareStatement("insert into t (i, t) values (1, date '2010-01-01')")) {
                System.out.println(p.executeUpdate());
            }
        }
        finally {
            s.executeUpdate("drop table if exists t");
        }
    }

    N.B: I believe this SqlParser was introduced only recently? It appears to be nowhere near production ready. If you can, I suggest reverting its use in the JDBC driver for now, or enabling it only in an experimental mode. As suggested by this issue, the parser's false positives do appear to have a significant impact on executed queries:

    Surely, you should have a large set of ClickHouse server test queries available that you can use just to smoke test your SqlParser. Anything that is accepted by the server should be accepted by the JDBC driver.

  2. chernser commented on Sep 9, 2025

    @chernser
    Contributor

    @lukaseder
    Thank you for the feedback!
    yes, we have used an antlr4 recently to replace previous javacc implementation (it had some other issues with maintenance).
    We will work on mitigating these issues.

  3. chernser commented on Oct 27, 2025

    @chernser
    Contributor

    Verified in com.clickhouse.jdbc.internal.BaseSqlParserFacadeTest#testMiscStatements

  4. added this to the 0.9.3 milestone on Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions