use of org.apache.drill.exec.planner.physical.LimitPrel in project drill by apache.
the class AbstractIndexPlanGenerator method getSortNode.
public static RelNode getSortNode(IndexCallContext indexContext, RelNode newRel, boolean donotGenerateSort, boolean isSingleton, boolean isExchangeRequired) {
OrderedRel rel = indexContext.getSort();
DrillDistributionTrait hashDistribution = new DrillDistributionTrait(DrillDistributionTrait.DistributionType.HASH_DISTRIBUTED, ImmutableList.copyOf(indexContext.getDistributionFields()));
if (toRemoveSort(indexContext.getCollation(), newRel.getTraitSet().getTrait(RelCollationTraitDef.INSTANCE))) {
// we are going to remove sort
logger.debug("Not generating SortPrel since we have the required collation");
if (IndexPlanUtils.generateLimit(rel)) {
newRel = new LimitPrel(newRel.getCluster(), newRel.getTraitSet().plus(indexContext.getCollation()).plus(Prel.DRILL_PHYSICAL), newRel, IndexPlanUtils.getOffset(rel), IndexPlanUtils.getFetch(rel));
}
RelTraitSet traits = newRel.getTraitSet().plus(indexContext.getCollation()).plus(Prel.DRILL_PHYSICAL);
newRel = Prule.convert(newRel, traits);
newRel = getExchange(newRel.getCluster(), isSingleton, isExchangeRequired, traits, hashDistribution, indexContext, newRel);
} else {
if (donotGenerateSort) {
logger.debug("Not generating SortPrel and index plan, since just picking index for full index scan is not beneficial.");
return null;
}
RelTraitSet traits = newRel.getTraitSet().plus(indexContext.getCollation()).plus(Prel.DRILL_PHYSICAL);
newRel = getSortOrTopN(indexContext, rel, newRel, Prule.convert(newRel, newRel.getTraitSet().replace(Prel.DRILL_PHYSICAL)));
newRel = getExchange(newRel.getCluster(), isSingleton, isExchangeRequired, traits, hashDistribution, indexContext, newRel);
}
return newRel;
}
use of org.apache.drill.exec.planner.physical.LimitPrel in project drill by apache.
the class MapRDBPushLimitIntoScan method doPushLimitIntoRowKeyJoin.
protected void doPushLimitIntoRowKeyJoin(RelOptRuleCall call, LimitPrel limit, final ProjectPrel project, RowKeyJoinPrel join) {
final RelNode newChild;
try {
RelNode left = join.getLeft();
RelNode right = join.getRight();
final RelNode limitOnLeft = new LimitPrel(left.getCluster(), left.getTraitSet(), left, limit.getOffset(), limit.getFetch());
RowKeyJoinPrel newJoin = new RowKeyJoinPrel(join.getCluster(), join.getTraitSet(), limitOnLeft, right, join.getCondition(), join.getJoinType());
if (project != null) {
final ProjectPrel newProject = new ProjectPrel(project.getCluster(), project.getTraitSet(), newJoin, project.getProjects(), project.getRowType());
newChild = newProject;
} else {
newChild = newJoin;
}
call.transformTo(newChild);
logger.debug("pushLimitIntoRowKeyJoin: Pushed limit on left side of Join " + join.toString());
} catch (Exception e) {
logger.warn("pushLimitIntoRowKeyJoin: Exception while trying limit pushdown!", e);
}
}
Aggregations