xndai commented on a change in pull request #1884:
URL: https://github.com/apache/calcite/pull/1884#discussion_r416772897
##########
File path: core/src/main/java/org/apache/calcite/tools/RelBuilder.java
##########
@@ -2497,6 +2509,17 @@ public RelBuilder sortLimit(int offset, int fetch,
RexNode... nodes) {
return sortLimit(offset, fetch, ImmutableList.copyOf(nodes));
}
+ /** Creates a {@link Sort} by specifying collations.
+ */
+ public RelBuilder sort(List<RelFieldCollation> collations) {
+ final ImmutableList.Builder<RexNode> builder = ImmutableList.builder();
+ for (RelFieldCollation collation : collations) {
+ builder.add(collation.direction.isDescending()
+ ? desc(field(collation.getFieldIndex())) :
field(collation.getFieldIndex()));
+ }
+ return sortLimit(-1, -1, builder.build());
Review comment:
I try to reuse the existing logic as much as possible. Currently all the
sort operator creations are through sortLimit().
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]