-
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
Adds basic aggregations to the partiql-planner #1247
Conversation
Conformance comparison report
Number passing in both: 5372 Number failing in both: 446 Number passing in Base (5ca3723) but now fail: 0 Number failing in Base (5ca3723) but now pass: 0 |
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.
Overall looks good. I'm skimming through the inference tests, and could you add tests specifically dedicated to aggregations with only group by keys and no agg functions? Ideally, with some positive tests and negative tests where the input arguments are nullable, missing, potentially missing, potentially the wrong type, and definitely of the wrong type?
partiql-ast/src/main/kotlin/org/partiql/ast/normalize/NormalizeGroupBy.kt
Show resolved
Hide resolved
partiql-ast/src/test/kotlin/org/partiql/ast/normalize/NormalizeTest.kt
Outdated
Show resolved
Hide resolved
partiql-planner/src/main/kotlin/org/partiql/planner/typer/PlanTyper.kt
Outdated
Show resolved
Hide resolved
var missingArg = false | ||
val args = arguments.map { | ||
val arg = visitRex(it, null) | ||
if (arg.type == MissingType) missingArg = true |
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.
What happens if it's a union including missing? Or, if we're trying to compute COUNT
and the argument is always a string?
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.
I don't believe the COUNT column type matters. The SQL spec doesn't show anything about the input argument type to COUNT (as far as I can tell), only the output being exact numeric.
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.
Switched arg.type == MissingType
to arg.type.isMissable
partiql-types/src/main/kotlin/org/partiql/types/function/FunctionSignature.kt
Show resolved
Hide resolved
partiql-planner/src/main/kotlin/org/partiql/planner/typer/PlanTyper.kt
Outdated
Show resolved
Hide resolved
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.
Overall, this looks good to ship. Have some clean-up comments, but once rebased and addressed, I can approve.
partiql-ast/src/test/kotlin/org/partiql/ast/normalize/NormalizeTest.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/types/function/FunctionSignature.kt
Outdated
Show resolved
Hide resolved
partiql-types/src/main/kotlin/org/partiql/types/function/FunctionSignature.kt
Show resolved
Hide resolved
|
||
// Some operators can return MISSING during runtime | ||
if (match.isMissable) { | ||
type = StaticType.unionOf(type, StaticType.MISSING) |
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.
While it's not an explicit requirement within PlanTyper, several functions in the PlanTyper flatten their union types before returning. Helps avoid accidental breaks in the future.
Here, you could potentially have a type = union(union(type, NULL), MISSING)
-- which, I don't think all functions account for. When you call allTypes
, you typically wouldn't expect any AnyOfType
's to be part of the return.
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.
That's very odd StaticType behavior. Union is an associative operation you'd expect
(A U B) U (B U C) <--> A U B U C
The need to flatten is a workaround for StaticType union not being associative
if (!hadMissingArg && arg.type.isMissable()) { | ||
hadMissingArg = true | ||
} | ||
arg.type.isNullOrMissing() |
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.
Left behind
…Typer.kt Co-authored-by: John Ed Quinn <[email protected]>
e51c035
to
11ff840
Compare
Description
This PR adds basic aggregations to the resolved planner. We define aggregation functions in the header and resolve to one of the available / defined operators. Like a SELECT list, each GROUP BY key gets its own unique binder.
At the moment, this work is not thoroughly tested, but behaves as desired for the 12 sanity tests. This does not include the SQL++ GROUP AS.
Other Information
Updated Unreleased Section in CHANGELOG: [YES/NO]
No
Any backward-incompatible changes? [YES/NO]
No partiql-planner is a new package
Any new external dependencies? [YES/NO]
No
Do your changes comply with the Contributing Guidelines
and Code Style Guidelines? [YES/NO]
Yes
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.