Skip to content

[BUG] JSQLParser 5.4-SNAPSHOT : ClickHouse : ORDER BY ... WITH FILL / INTERPOLATE not supported #2467

Closed

Description

@tomershay

Failing SQL Feature

ClickHouse supports the WITH FILL modifier on ORDER BY expressions, which fills in missing rows in a sorted sequence (gap filling for time series). It accepts optional FROM, TO and STEP bounds, where STEP may be an INTERVAL literal, and an optional query-level INTERPOLATE clause that computes the values of non-sorted columns for the generated rows. JSQLParser fails to parse the WITH FILL modifier when used in ORDER BY.

See the ClickHouse docs:
https://clickhouse.com/docs/en/sql-reference/statements/select/order-by#order-by-expr-with-fill-modifier

SQL Example

CREATE TABLE t (d Date, v UInt32) ENGINE = MergeTree ORDER BY d;

INSERT INTO t VALUES ('2024-01-03', 10), ('2024-01-06', 20), ('2024-01-10', 30);

SELECT d, v FROM t ORDER BY d WITH FILL FROM toDate('2024-01-01') TO toDate('2024-02-01') STEP INTERVAL 1 DAY INTERPOLATE (v AS v + 1);

Parsing error

ParseException: Encountered: <K_WITH> / "WITH", at line 4, column 3, in lexical state DEFAULT.

Tested with Clickhouse 25.8.

Activity

  1. fudianchn commented on Aug 15, 2026

    @fudianchn
    Contributor

    Root cause: the grammar has no production for the WITH FILL modifier family (FROM/TO/STEP/STALENESS bounds on the order by element) nor for the query-level INTERPOLATE clause.

    PR #2469 implements both following the ClickHouse reference parser: per element [WITH FILL] [FROM expr] [TO expr] [STEP expr] [STALENESS expr] (the step accepts INTERVAL literals) and INTERPOLATE [(col [AS expr], ...)] after the ORDER BY list, where the bare form fills all allowed columns. The keywords stay non-reserved, so fill, step, staleness and interpolate remain usable as column names.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions