hsyuan commented on a change in pull request #1884:
URL: https://github.com/apache/calcite/pull/1884#discussion_r416793614
##########
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:
It looks like premature optimization. We pass to it a complete stuff,
this method tear the stuff down and pass all the parts to `sortLimit`, and
assemble it back. But leave it to you to decide.
----------------------------------------------------------------
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]