Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.calcite.plan.RelOptPredicateList;
import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.rel.RelCollation;
import org.apache.calcite.rel.RelCollationTraitDef;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelFieldCollation;
Expand Down Expand Up @@ -77,8 +78,13 @@ protected SortRemoveConstantKeysRule(Config config) {
return;
}

final RelCollation collation =
RelCollationTraitDef.INSTANCE.canonize(RelCollations.of(collationsList));
final Sort result =
sort.copy(sort.getTraitSet(), input, RelCollations.of(collationsList));
sort.copy(
sort.getTraitSet().replaceIf(RelCollationTraitDef.INSTANCE, () -> collation),
input,
collation);
call.transformTo(result);
call.getPlanner().prune(sort);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,11 @@ private void checkSemiOrAntiJoinProjectTranspose(JoinRelType type) {
+ "group by deptno, sal\n"
+ "order by deptno, sal desc nulls first";
sql(sql)
// Use VolcanoPlanner with collation to ensure the correct creation of the new Sort
.withVolcanoPlanner(false, p -> {
p.addRelTraitDef(RelCollationTraitDef.INSTANCE);
RelOptUtil.registerDefaultRules(p, false, false);
})
.withRule(CoreRules.SORT_REMOVE_CONSTANT_KEYS)
.check();
}
Expand Down