You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/06/10 03:02:34 UTC

[GitHub] [calcite] chunweilei commented on a change in pull request #2017: [CALCITE-4018] Support trait propagation for EnumerableValues

chunweilei commented on a change in pull request #2017:
URL: https://github.com/apache/calcite/pull/2017#discussion_r437833608



##########
File path: core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableValues.java
##########
@@ -70,6 +74,32 @@ public static EnumerableValues create(RelOptCluster cluster,
     return new EnumerableValues(getCluster(), rowType, tuples, traitSet);
   }
 
+  @Override public RelNode passThrough(final RelTraitSet required) {
+    RelCollation collation = required.getCollation();
+    if (collation == null || collation.isDefault()) {
+      return null;
+    }
+    if (tuples.size() > 1) {
+      Ordering<List<RexLiteral>> ordering = null;
+      for (RelFieldCollation fc : collation.getFieldCollations()) {
+        Ordering<List<RexLiteral>> comparator = RelMdCollation.comparator(fc);
+        if (ordering == null) {
+          ordering = comparator;
+        } else {
+          ordering = ordering.compound(comparator);
+        }
+      }
+      if (!ordering.isOrdered(tuples)) {
+        return null;

Review comment:
       If the tuples are not sorted, we still have to add a sort on it. 




----------------------------------------------------------------
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:
users@infra.apache.org