-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove hard-coded aggregations from parser and ast #1464
Conversation
Conformance comparison report-Cross Engine
Number failing in both: 203 Number passing in eval engine but fail in legacy engine: 233 Number failing in eval engine but pass in legacy engine: 312 Conformance comparison report-Cross Commit-EVAL
Number failing in both: 515 Number passing in Base (4f89c2d) but now fail: 1 Number failing in Base (4f89c2d) but now pass: 27 Click here to see
Conformance comparison report-Cross Commit-LEGACY
Number failing in both: 436 Number passing in Base (4f89c2d) but now fail: 0 Number failing in Base (4f89c2d) but now pass: 0 |
0b92558
to
c1f826b
Compare
@@ -1,25 +0,0 @@ | |||
// ktlint-disable filename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(self-review) COUNT(*)
builtin function deleted in favor of mapping COUNT(*)
(COUNT()
in ast) to COUNT(1)
partiql-spi/src/main/kotlin/org/partiql/spi/connector/sql/builtins/AggCount.kt
Show resolved
Hide resolved
return@build callAgg(strategy, name, arg, metas) | ||
} | ||
|
||
private fun String.isAggregateCall(): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(self-review) in the legacy PIG AST and conversion from partiql-ast
to PIG AST, keep the same behavior as before with respect to supported aggregations. E.g.
SUM(*)
andF(*)
will still error- Aggregations require exactly
1
argument
Hard-coding the aggregations in the conversion to PIG AST since this is legacy code that will be removed by the v1 release.
} | ||
} | ||
|
||
private fun String.isAggregateCall(): Boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(self-review) since the function resolution specification for scalar vs aggregate functions has not yet been defined, opt to hard-code the aggregation logic to the planner for now. Once we formalize the function resolution, we can remove this hard-coded logic.
function = id("FOO") | ||
setq = SetQuantifier.DISTINCT | ||
args += exprVar(id("x"), Expr.Var.Scope.DEFAULT) | ||
args += exprVar(id("y"), Expr.Var.Scope.DEFAULT) | ||
} | ||
}, | ||
expect("COUNT(*)") { | ||
exprAgg { | ||
function = id("COUNT_STAR") | ||
exprCall { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(self-review) modeling difference in partiql-ast
for COUNT(*)
. Previously it was an exprAgg
with a function name of COUNT_STAR
and no arguments. Changed to just be an exprCall
with function name of COUNT
and no arguments, which I think is slightly cleaner.
This is how Trino opts to represent COUNT(*)
in their AST -- https://github.com/trinodb/trino/blob/429f8a8257d38e09b11a69571456c346f973373e/core/trino-parser/src/main/java/io/trino/sql/ExpressionFormatter.java#L436-L438.
PR should be ready for review. Regarding future work related to user-defined aggregations, function resolution between scalars and aggregations, and qualified paths for aggregations, I'll need to discuss further w/ the PartiQL team on these topics when I'm back online at the end of the month. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Very clean and I'm happy to see this item tackled.
partiql-ast/src/main/kotlin/org/partiql/ast/helpers/ToLegacyAst.kt
Outdated
Show resolved
Hide resolved
partiql-planner/src/main/kotlin/org/partiql/planner/internal/transforms/RelConverter.kt
Outdated
Show resolved
Hide resolved
c1f826b
to
3819b99
Compare
Relevant Issues
Description
COUNT(*)
COUNT_STAR
with no args; changed to map toCOUNT
with no argsOther Information
Updated Unreleased Section in CHANGELOG: [NO]
Any backward-incompatible changes? [YES/NO]
Any new external dependencies? [NO]
Do your changes comply with the Contributing Guidelines
and Code Style Guidelines? [YES/NO]
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.