Just doing a bit of code reading here. Looking at the SortRemoveRule implementation:
// Express the "sortedness" requirement in terms of a collation trait and // we can get rid of the sort. This allows us to use rels that just happen // to be sorted but get the same effect. final RelCollation collation = sort.getCollation(); assert collation == sort.getTraitSet() .getTrait(RelCollationTraitDef.INSTANCE); final RelTraitSet traits = sort.getInput().getTraitSet().replace(collation); call.transformTo(convert(sort.getInput(), traits)); I don't understand how this is correct without checking that the input collation is the same as the collation requested by the sort. It looks to me like it just replaces the input's collation with that of the sort. Any thoughts? Thanks. Jess