Skip to content

Support ksqlDB window grace periods and EMIT FINAL - #2571

Open
minleejae wants to merge 2 commits into
JSQLParser:masterfrom
minleejae:feat/ksqldb-window-options
Open

Support ksqlDB window grace periods and EMIT FINAL#2571
minleejae wants to merge 2 commits into
JSQLParser:masterfrom
minleejae:feat/ksqldb-window-options

Conversation

@minleejae

Copy link
Copy Markdown
Contributor

ksqlDB queries fail on unparenthesized JOIN windows, grace periods and EMIT FINAL. Support these forms while retaining the existing parenthesized single-duration and asymmetric JOIN windows:

SELECT a.id FROM a JOIN b
WITHIN 1 HOUR GRACE PERIOD 15 MINUTES ON a.id = b.id
EMIT CHANGES;

SELECT item_id, SUM(quantity) FROM orders
WINDOW TUMBLING (SIZE 20 SECONDS, GRACE PERIOD 2 SECONDS)
GROUP BY item_id EMIT FINAL;

Reuse one duration production across JOIN, HOPPING/SESSION/TUMBLING and grace periods. KSQLWindow.Duration exposes the grace value and time unit, distinguishing an omitted grace period from zero. JOIN windows preserve their bracket style. PlainSelect.EmitMode exposes NONE/CHANGES/FINAL while the existing boolean API keeps its default behavior; model and deparser share EMIT rendering. A contextual alias check recognizes WITHIN durations without reserving ordinary aliases named within.

Validation:

  • Full Gradle check and Maven verify.
  • Original reproducers, all ten singular/plural time-unit spellings, three aggregation-window forms, symmetric/asymmetric JOIN windows, zero grace periods, LIMIT and following statements.
  • AST fields, legacy builders, SQL/model/deparser round-trips, malformed syntax, keyword aliases and existing ksqlDB/ClickHouse/JOIN regression tests.
  • Syntax follows the Confluent SELECT documentation.

Fixes #1752.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] JSQLParser 4.6 : KsqlDB : Not able to parse Ksqldb queries

1 participant