use of org.apache.drill.exec.planner.logical.DrillSortRel in project drill by apache.
the class SortPrule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final DrillSortRel sort = (DrillSortRel) call.rel(0);
final RelNode input = sort.getInput();
// Keep the collation in logical sort. Convert input into a RelNode with 1) this collation, 2) Physical, 3) hash distributed on
DrillDistributionTrait hashDistribution = new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED, ImmutableList.copyOf(getDistributionField(sort)));
final RelTraitSet traits = sort.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(hashDistribution);
final RelNode convertedInput = convert(input, traits);
if (isSingleMode(call)) {
call.transformTo(convertedInput);
} else {
RelNode exch = new SingleMergeExchangePrel(sort.getCluster(), sort.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON), convertedInput, sort.getCollation());
// transform logical "sort" into "SingleMergeExchange".
call.transformTo(exch);
}
}
Aggregations