Skip to content
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

fix(core): row type should output the window function aggregation results #286

Merged

Conversation

bvolpato
Copy link
Member

We've caught a problem where the deriveRecordType was very inconsistent with Calcite's RowType, and debugging those closely, Substrait was inconsistently adding the partition expression as part of the record type, which doesn't make sense (I mean in general, there might be cases that you are outputting the partition field).

I've fixed the deriveRecordType method to output based on the windowFunctions instead, and added a test that validates whether the types are still the expected after the round-trip, for the original case and added one new plan that had 2 distinct aggregations.

@@ -29,7 +29,7 @@ protected Type.Struct deriveRecordType() {
.struct(
Stream.concat(
initial.fields().stream(),
getPartitionExpressions().stream().map(Expression::getType)));
getWindowFunctions().stream().map(WindowRelFunctionInvocation::outputType)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consistent with the language in the spec

Same as Project operator (input followed by each window expression).

Copy link
Member

@vbarua vbarua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing and adding a test as well.

@vbarua vbarua merged commit 60575b3 into substrait-io:main Aug 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants