zabetak commented on a change in pull request #1462: 
[CALCITE-3353]ProjectJoinTransposeRule caused AssertionError when creating a 
new Join
URL: https://github.com/apache/calcite/pull/1462#discussion_r327851499
 
 

 ##########
 File path: 
core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableCorrelate.java
 ##########
 @@ -77,6 +78,13 @@ public static EnumerableCorrelate create(
   @Override public EnumerableCorrelate copy(RelTraitSet traitSet,
       RelNode left, RelNode right, CorrelationId correlationId,
       ImmutableBitSet requiredColumns, JoinRelType joinType) {
+    // Get new collations since the Correlate has new inputs and new condition.
+    ImmutableList<RelCollation> newCollations = ImmutableList.copyOf(
+            RelMdCollation.enumerableCorrelate(
+            getCluster().getMetadataQuery(), left, right, joinType));
+    if (!newCollations.isEmpty()) {
+      traitSet = traitSet.replace(newCollations);
 
 Review comment:
   I see what you are trying to do here but you are kinda violating the 
contract of `copy` (_Creates a copy of this relational expression, perhaps 
changing traits and inputs_); the client of the method can no longer change 
traits (at least collation). Furthermore, if you do this inside `copy` you 
could call the `create` method directly which brings me to my initial comment. 
Instead of using copy inside the rule you could opt for the RelBuilderFactory.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to