Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions docs.feldera.com/docs/sql/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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`.

<a id="lateral"></a>
```
tablePrimary
Expand Down Expand Up @@ -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.

<a id="as"></a>
```
projectItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ data: {
includeParsingStringLiteralAsArrayLiteral: true
includeIntervalWithoutQualifier: false
includeStarExclude: true
includeDistinctOn: true

# Method for parsing "SET [OR RESET]" calls.
setOptionParserMethod: "SqlSetOption"
Expand Down
2 changes: 1 addition & 1 deletion sql-to-dbsp-compiler/calcite_version.env
Original file line number Diff line number Diff line change
Expand Up @@ -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"