Skip to content

Bogus SqlParser warning for valid ALTER TABLE .. ALTER COLUMN syntax #2573

Closed

Description

@lukaseder

Steps to reproduce

try (Statement s = connection.createStatement()) {
    try {
        s.executeUpdate("create table t (i int, j int, primary key (i)) engine = MergeTree()");
        s.executeUpdate("alter table t alter column j default 1");
    }
    finally {
        s.executeUpdate("drop table if exists t");
    }
}

The syntax is perfectly fine:

Error Log or Exception StackTrace

12:35:58,252  WARN [SqlParser                     ] - SQL syntax error at line: 1, pos: 14, mismatched input 'alter' expecting {ADD, ATTACH, CLEAR, COMMENT, DELETE, DETACH, DROP, FREEZE, MATERIALIZE, MODIFY, MOVE, ON, REMOVE, RENAME, REPLACE, UPDATE}

Expected Behaviour

No log entries

Configuration

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. added
    jdbc
    sql-parser
    on Sep 9, 2025
  2. larshelge commented on Sep 24, 2025

    @larshelge

    I am seeing the same for create table statements.

    • WARN 2025-09-24T15:26:14,873 SQL syntax error at line: 1, pos: 72, mismatched input 'not' expecting {',', ')'} (SqlParser [pool-4-thread-1]) UID:qgoKKOXuRSh

    It certainly appears to not indicate a real issue, but is somewhat confusing and noisy.

  3. added this to the 0.9.3 milestone on Sep 29, 2025
  4. chernser commented on Oct 7, 2025

    @chernser
    Contributor

    Good day, @lukaseder !

    While working on this issue I've found that this form of SQL is not supported by ClickHouse at least it causes error with clickhouse-client:

    DESCRIBE TABLE t2
    
    Query id: 2c20faae-2e16-449f-83e2-a7f4a2366ca6
    
       ┌─name─┬─type────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
    1. │ v    │ Float32 │              │                    │         │                  │                │
       └──────┴─────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘
    
    1 row in set. Elapsed: 0.001 sec. 
    
    0d7376d76759 :) alter table t2 alter column v Int32
    
    Syntax error: failed at position 31 (Int32):
    
    alter table t2 alter column v Int32
    
    Expected one of: token sequence, Dot, token, REMOVE, MODIFY SETTING, RESET SETTING, DEFAULT, MATERIALIZED, EPHEMERAL, ALIAS, AUTO_INCREMENT, PRIMARY KEY, COMMENT, CODEC, TYPE

    However another form with MODIFY COLUMN works.

    0d7376d76759 :) alter table t2 modify column v Int32
    
    ALTER TABLE t2
        (MODIFY COLUMN `v` Int32)
    
    Query id: e794f4a2-2a0f-44ec-801b-05c131ef8716
    
    Ok.
    

    Syntax is described in documentation https://clickhouse.com/docs/sql-reference/statements/alter/column#modify-column. Will this specifics be handled by JOOQ ?

    Thanks!

  5. lukaseder commented on Oct 7, 2025

    @lukaseder
    Author

    Thanks for your message, @chernser. jOOQ actually does generate MODIFY COLUMN. I'm not sure anymore why I reported ALTER COLUMN instead. It's documented as an alternative:

    https://clickhouse.com/docs/sql-reference/statements/alter/column#modify-column

    Image

    Though, the TYPE keyword seems mandatory according to the docs. But it does seem to work also without the TYPE keyword in Dbeaver:

    Image

    In any case, the specific error reported by the JDBC driver doesn't seem correct. There is some set of ALTER TABLE .. ALTER COLUMN syntax that should be accepted, according to the docs.

  6. chernser commented on Oct 27, 2025

    @chernser
    Contributor

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

  7. added
    queries
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugjdbcqueriessql-parser

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions