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 00:36:08 UTC

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

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



##########
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:
       Could you also explain which this check?

##########
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);
+        }

Review comment:
       Can you add comments to describe what this for loop is doing? Sorry but I had a hard time to understand 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