-
Notifications
You must be signed in to change notification settings - Fork 74
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(isthmus): support expressions in Sort #322
base: main
Are you sure you want to change the base?
fix(isthmus): support expressions in Sort #322
Conversation
374169d
to
318f831
Compare
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 to me. It's good to be able to rely on built-in Calcite functionality to expand complex expressions in the sort fields.
I did leave one comment on your tests. The CollationRelWriter
seems somewhat redundant given that that the same information is visible in the LogicalSort
s
return relBuilder.push(child).sort(Collections.EMPTY_LIST).build(); | ||
} | ||
RelNode node = relBuilder.push(child).sort(RelCollations.of(relFieldCollations)).build(); | ||
RelNode node = relBuilder.push(child).sort(sortExpressions).build(); |
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.
Nice find! It's really helpful that we can rely on Calcite's machinery to do this for us.
Motivation
This PR adds support for expressions in Sort (today, only input references are supported #192).
Details
This PR uses Calcite's
relbuilder.sort(rexNodes)
rather than computingRelFieldCollation
(which required input references only). Calcite then makes sure to expand the Sort into aLogicalSort
and aLogicalProject
to evaluate expressions if needed (an additionalLogicalProject
is applied which acts like a remap to remove any introduced fields to preserve the same output).Examples:
e1:
e2:
See
ComplexSortTest.java
for more examples