hsyuan commented on a change in pull request #1985:
URL: https://github.com/apache/calcite/pull/1985#discussion_r429056354



##########
File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableProject.java
##########
@@ -86,4 +99,38 @@ public Result implement(EnumerableRelImplementor 
implementor, Prefer pref) {
     // EnumerableCalcRel is always better
     throw new UnsupportedOperationException();
   }
+
+  @Override public Pair<RelTraitSet, List<RelTraitSet>> passThroughTraits(
+      RelTraitSet required) {
+    RelCollation collation = required.getTrait(RelCollationTraitDef.INSTANCE);
+    if (collation == null || collation.getFieldCollations().size() == 0) {
+      return null;
+    }
+    final Mappings.TargetMapping map =
+        RelOptUtil.permutationIgnoreCast(
+            getProjects(), getInput().getRowType());
+
+    // Determine mapping between project input and output fields. If sort
+    // relies on non-trivial expressions, we can't push.
+    for (RelFieldCollation fc : collation.getFieldCollations()) {
+      if (map.getTargetOpt(fc.getFieldIndex()) < 0) {
+        return null;
+      }
+      final RexNode node = getProjects().get(fc.getFieldIndex());
+      if (node.isA(SqlKind.CAST)) {

Review comment:
       There is no test case covering this.




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


Reply via email to