Skip to content

Commit 24e9876

Browse files
committed
[SQL] Advance Calcite version
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 336ec74 commit 24e9876

File tree

14 files changed

+510
-180
lines changed

14 files changed

+510
-180
lines changed

docs.feldera.com/docs/sql/grammar.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,15 @@ values
299299
300300
select
301301
: SELECT [ ALL | DISTINCT ]
302-
{ * | projectItem [, projectItem ]* }
302+
{ starExclude | projectItem [, projectItem ]* }
303303
FROM tableExpression
304304
[ WHERE booleanExpression ]
305305
[ GROUP BY [ ALL | DISTINCT ] { groupItem [, groupItem ]* } ]
306306
[ HAVING booleanExpression ]
307+
308+
starExclude
309+
: '*' [ 'EXCLUDE' parensColumnList ]
310+
307311
```
308312

309313
<a id="lateral"></a>

docs.feldera.com/docs/tutorials/time-series.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ CREATE VIEW v AS SELECT t.col1, t.col2 FROM t;
124124
LATENESS v.col1 INTERVAL 1 HOUR;
125125
```
126126

127+
`LATENESS` can only be specified for toplevel view columns; i.e., the following
128+
is illegal: `LATENESS v.str.col INTERVAL 1 HOUR`.
129+
127130
### Guidelines for writing lateness annotations
128131

129132
Keep in mind the following guidelines when choosing lateness annotations for

python/tests/runtime_aggtest/asof_tests/test_asof_illarg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self):
2222
LEFT ASOF JOIN asof_tbl2 t2
2323
MATCH_CONDITION (t1.intt <= t2.intt )
2424
ON t1.id = t2.id;"""
25-
self.expected_error = "Currently the only MATCH_CONDITION comparison supported by ASOF joins is '>='"
25+
self.expected_error = "Currently the only MATCH_CONDITION comparison supported by ASOF joins is 'leftCol >= rightCol'"
2626

2727

2828
class asof_test_illarg3(TstView):

sql-to-dbsp-compiler/SQL-compiler/src/main/codegen/config.fmpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ data: {
976976
includeAdditionalDeclarations: false
977977
includeParsingStringLiteralAsArrayLiteral: true
978978
includeIntervalWithoutQualifier: false
979+
includeStarExclude: true
979980

980981
# Method for parsing "SET [OR RESET]" calls.
981982
setOptionParserMethod: "SqlSetOption"

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/CalciteToDBSPCompiler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,7 @@ private void visitAsofJoin(LogicalAsofJoin join) {
20012001
// This shares a lot of code with the LogicalJoin
20022002
CalciteObject conditionNode = CalciteObject.create(join, join.getCondition());
20032003
IntermediateRel node = CalciteObject.create(join, conditionNode.getPositionRange());
2004+
20042005
JoinRelType joinType = join.getJoinType();
20052006
boolean isLeft = joinType == JoinRelType.LEFT_ASOF;
20062007
if (!isLeft)
@@ -2176,7 +2177,8 @@ private void visitAsofJoin(LogicalAsofJoin join) {
21762177
if (comparison != SqlKind.GREATER_THAN_OR_EQUAL) {
21772178
// Not yet supported by DBSP
21782179
throw new UnimplementedException(
2179-
"Currently the only MATCH_CONDITION comparison supported by ASOF joins is '>='", 2212, node);
2180+
"Currently the only MATCH_CONDITION comparison supported by ASOF joins is 'leftCol >= rightCol'",
2181+
2212, matchNode);
21802182
}
21812183
comparator = new DBSPDirectComparatorExpression(matchNode, comparator, ascending);
21822184

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/calciteCompiler/optimizer/CalciteOptimizer.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ void createOptimizer() {
199199
ReduceExpressionsRule.WINDOW_REDUCE_EXPRESSIONS,
200200
ReduceExpressionsRule.CALC_REDUCE_EXPRESSIONS,
201201
CoreRules.CALC_REDUCE_DECIMALS,
202-
CoreRules.FILTER_VALUES_MERGE,
203-
CoreRules.PROJECT_FILTER_VALUES_MERGE,
204-
// Rule is buggy; disabled due to
205-
// https://github.com/feldera/feldera/issues/217
206-
// CoreRules.PROJECT_VALUES_MERGE
202+
ValuesReduceRule.FILTER_VALUES_MERGE,
203+
ValuesReduceRule.PROJECT_FILTER_VALUES_MERGE,
204+
ValuesReduceRule.PROJECT_VALUES_MERGE,
207205
CoreRules.AGGREGATE_VALUES));
208206
this.addStep(new SimpleOptimizerStep("Remove empty relations", 0,
209207
PruneEmptyRules.UNION_INSTANCE,
@@ -233,7 +231,7 @@ void createOptimizer() {
233231
CoreRules.SORT_REMOVE_CONSTANT_KEYS));
234232
this.addStep(new SimpleOptimizerStep("Simplify correlates", 0,
235233
CoreRules.PROJECT_CORRELATE_TRANSPOSE,
236-
FilterCorrelateRule.FILTER_CORRELATE));
234+
CoreRules.FILTER_CORRELATE));
237235
this.addStep(merge);
238236

239237
var joinOrder = new BaseOptimizerStep("Join order", 2) {
@@ -249,11 +247,7 @@ HepProgram getProgram(RelNode node, int level) {
249247
CoreRules.JOIN_EXPAND_OR_TO_UNION_RULE,
250248
CoreRules.JOIN_CONDITION_PUSH,
251249
CoreRules.JOIN_PUSH_EXPRESSIONS,
252-
// Below rule crashes with test NaiveIncrementalTests.inTest
253250
// CoreRules.JOIN_PUSH_TRANSITIVE_PREDICATES,
254-
// https://issues.apache.org/jira/browse/CALCITE-5387
255-
// TODO: Rule is unsound
256-
// https://github.com/feldera/feldera/issues/1702
257251
CoreRules.FILTER_INTO_JOIN
258252
);
259253
OuterJoinFinder finder = new OuterJoinFinder();
@@ -336,7 +330,7 @@ HepProgram getProgram(RelNode node, int level) {
336330
// this.addStep(merge); -- messes up the shape of uncollect
337331

338332
this.addStep(new SimpleOptimizerStep("Move projections", 0,
339-
// Rule is unsound: https://issues.apache.org/jira/browse/CALCITE-6681
333+
// Tests that fail: IncrementalRegressionTests.issue5182, issue5182a, issue5182b
340334
// CoreRules.PROJECT_CORRELATE_TRANSPOSE,
341335
CoreRules.PROJECT_WINDOW_TRANSPOSE,
342336
CoreRules.PROJECT_SET_OP_TRANSPOSE,
@@ -368,8 +362,6 @@ HepProgram getProgram(RelNode node, int level) {
368362
CoreRules.JOIN_EXPAND_OR_TO_UNION_RULE,
369363
CoreRules.EXPAND_FILTER_DISJUNCTION_GLOBAL,
370364
CoreRules.EXPAND_JOIN_DISJUNCTION_GLOBAL,
371-
// TODO: Rule is unsound
372-
// https://github.com/feldera/feldera/issues/1702
373365
CoreRules.FILTER_INTO_JOIN
374366
);
375367
return this.builder.build();

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/calciteCompiler/optimizer/FilterCorrelateRule.java

Lines changed: 0 additions & 151 deletions
This file was deleted.

sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/frontend/calciteCompiler/optimizer/ReduceExpressionsRule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public abstract class ReduceExpressionsRule<C extends org.apache.calcite.rel.rul
114114
* @see CoreRules#FILTER_REDUCE_EXPRESSIONS
115115
*/
116116
public static class FilterReduceExpressionsRule
117-
extends org.apache.calcite.rel.rules.ReduceExpressionsRule<org.apache.calcite.rel.rules.ReduceExpressionsRule.FilterReduceExpressionsRule.FilterReduceExpressionsRuleConfig> {
117+
extends org.apache.calcite.rel.rules.ReduceExpressionsRule<
118+
org.apache.calcite.rel.rules.ReduceExpressionsRule.FilterReduceExpressionsRule.FilterReduceExpressionsRuleConfig> {
118119
/** Creates a FilterReduceExpressionsRule. */
119120
protected FilterReduceExpressionsRule(FilterReduceExpressionsRule.FilterReduceExpressionsRuleConfig config) {
120121
super(config);

0 commit comments

Comments
 (0)