Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : Clickhouse : ORDER BY after CREATE TABLE unsupported #2353

Description

@tomershay

The parser doesn't support an ORDER BY statement after a CREATE TABLE, which is usually used to define the physical sort order of the table.

This capability is supported in latest Clickhouse.

Sample query:

CREATE TABLE metrics (
    event_date Date,
    user_id UInt64,
    value Float64
) ENGINE = MergeTree()
ORDER BY (event_date, user_id);

Error: ParseException: Encountered: <K_ORDER> / "ORDER", at line 6, column 1, in lexical

Activity

  1. fudianchn commented on Aug 17, 2026

    @fudianchn
    Contributor

    Verified on current master f41c0b8: the statement from this issue parses and round-trips.

    CCJSqlParserUtil.parse("CREATE TABLE metrics (\n"
            + " event_date Date,\n user_id UInt64,\n value Float64\n"
            + ") ENGINE = MergeTree()\n"
            + "ORDER BY (event_date, user_id)");
    // => parses, toString() round-trips

    The issue was reported against an older 5.4-SNAPSHOT; current master appears to have this fixed, so this can be closed.

  2. manticore-projects commented on Aug 17, 2026

    @manticore-projects
    Contributor

    Thank you @fudianchn.

  3. minleejae commented on Sep 4, 2026

    @minleejae
    Contributor

    @manticore-projects This was fixed by #2377, and the original SQL now parses and round-trips on the current master. Could you please close this issue?

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions