From ebe1908f9963de212f678bb9c32bf672085257fb Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Tue, 23 Jun 2026 23:21:50 -0700 Subject: [PATCH 1/2] [SQL] Advance Calcite version Signed-off-by: Mihai Budiu --- sql-to-dbsp-compiler/calcite_version.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-to-dbsp-compiler/calcite_version.env b/sql-to-dbsp-compiler/calcite_version.env index 2666bc1ab3a..cac5a3695d6 100644 --- a/sql-to-dbsp-compiler/calcite_version.env +++ b/sql-to-dbsp-compiler/calcite_version.env @@ -3,5 +3,5 @@ CALCITE_REPO="https://github.com/apache/calcite.git" #CALCITE_REPO="https://github.com/mihaibudiu/calcite" CALCITE_BRANCH="main" CALCITE_CURRENT="1.42.0" -CALCITE_NEXT_COMMIT="1a3173d52a41683acca60fb09a31ad6ee25e587e" +CALCITE_NEXT_COMMIT="1317946ea1c318ca7cc895031ce8ca48777fcf2d" CALCITE_NEXT="1.43.0" From cd48f70914c3e0647d9b44a95d0e1f648e2274a8 Mon Sep 17 00:00:00 2001 From: Mihai Budiu Date: Wed, 24 Jun 2026 08:54:17 -0700 Subject: [PATCH 2/2] [DOCS] Document new syntax supported: GROUP BY ALL, DISTINCT ON, ORDER BY ALL Signed-off-by: Mihai Budiu --- docs.feldera.com/docs/sql/grammar.md | 24 +++++++++++++++---- .../SQL-compiler/src/main/codegen/config.fmpp | 1 + 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs.feldera.com/docs/sql/grammar.md b/docs.feldera.com/docs/sql/grammar.md index f3f10e90ef8..d6277f3d538 100644 --- a/docs.feldera.com/docs/sql/grammar.md +++ b/docs.feldera.com/docs/sql/grammar.md @@ -339,7 +339,7 @@ query | query MINUS [ DISTINCT ] query | query INTERSECT [ DISTINCT ] query } - [ ORDER BY orderItem [, orderItem ]* ] + [ ORDER BY { ALL [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ] | orderItem [, orderItem]* } ] [ LIMIT [ start, ] { count | ALL } ] [ OFFSET start [ { ROW | ROWS } ] ] [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ] @@ -360,15 +360,25 @@ values : { VALUES | VALUE } expression [, expression ]* select - : SELECT [ hintComment ] [ ALL | DISTINCT ] - { projectItem [, projectItem ]* } + : SELECT [ hintComment ] [ ALL | DISTINCT [ ON '(' expression [ ',' expression ]* ')' ] ] { projectItem [, projectItem ]* } FROM tableExpression [ WHERE booleanExpression ] - [ GROUP BY [ ALL | DISTINCT ] { groupItem [, groupItem ]* } ] + [ GROUP BY { ALL | [ ALL | DISTINCT ] { groupItem [, groupItem ]* } } ] [ HAVING booleanExpression ] [ QUALIFY booleanExpression ] ``` +`DISTINCT ON` allows you to eliminate duplicate rows based on +specified expressions, keeping the first row in each group as +determined by the `ORDER BY` clause. When using `DISTINCT ON`, the +expressions in the `DISTINCT ON` clause must match a prefix of the +`ORDER BY` clause. + +`GROUP BY ALL` without any groupItem specified groups by every +expression in the `SELECT` clause that is not an aggregate function. +For example, `SELECT deptno, SUM(sal) FROM emp GROUP BY ALL` is +equivalent to `SELECT deptno, SUM(sal) FROM emp GROUP BY deptno`. + ``` tablePrimary @@ -406,6 +416,12 @@ orderItem : expression [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ] ``` +`ORDER BY ALL` will order on all expressions of the `SELECT` +statement, in the order they appear. E.g., `SELECT x, y FROM t ORDER +BY ALL` is equivalent to `SELECT x, y FROM t ORDER BY x, y`. An +optional trailing `ASC/DESC/NULLS FIRST/NULLS LAST` applies to all +expressions. + ``` projectItem diff --git a/sql-to-dbsp-compiler/SQL-compiler/src/main/codegen/config.fmpp b/sql-to-dbsp-compiler/SQL-compiler/src/main/codegen/config.fmpp index e1c099c4f93..f1d8e78036e 100644 --- a/sql-to-dbsp-compiler/SQL-compiler/src/main/codegen/config.fmpp +++ b/sql-to-dbsp-compiler/SQL-compiler/src/main/codegen/config.fmpp @@ -980,6 +980,7 @@ data: { includeParsingStringLiteralAsArrayLiteral: true includeIntervalWithoutQualifier: false includeStarExclude: true + includeDistinctOn: true # Method for parsing "SET [OR RESET]" calls. setOptionParserMethod: "SqlSetOption"