use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project drill by axbaretto.
the class DrillWindowRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final Window window = call.rel(0);
final RelNode input = call.rel(1);
final RelTraitSet traits = window.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify();
final RelNode convertedInput = convert(input, traits);
call.transformTo(new DrillWindowRel(window.getCluster(), traits, convertedInput, window.constants, window.getRowType(), window.groups));
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project drill by axbaretto.
the class JoinPruleBase method createDistBothPlan.
// Create join plan with both left and right children hash distributed. If the physical join type
// is MergeJoin, a collation must be provided for both left and right child and the plan will contain
// sort converter if necessary to provide the collation.
private void createDistBothPlan(RelOptRuleCall call, DrillJoinRel join, PhysicalJoinType physicalJoinType, RelNode left, RelNode right, RelCollation collationLeft, RelCollation collationRight, DrillDistributionTrait hashLeftPartition, DrillDistributionTrait hashRightPartition) throws InvalidRelException {
RelTraitSet traitsLeft = null;
RelTraitSet traitsRight = null;
if (physicalJoinType == PhysicalJoinType.MERGE_JOIN) {
assert collationLeft != null && collationRight != null;
traitsLeft = left.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collationLeft).plus(hashLeftPartition);
traitsRight = right.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collationRight).plus(hashRightPartition);
} else if (physicalJoinType == PhysicalJoinType.HASH_JOIN) {
traitsLeft = left.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(hashLeftPartition);
traitsRight = right.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(hashRightPartition);
}
final RelNode convertedLeft = convert(left, traitsLeft);
final RelNode convertedRight = convert(right, traitsRight);
DrillJoinRelBase newJoin = null;
if (physicalJoinType == PhysicalJoinType.HASH_JOIN) {
final RelTraitSet traitSet = PrelUtil.removeCollation(traitsLeft, call);
newJoin = new HashJoinPrel(join.getCluster(), traitSet, convertedLeft, convertedRight, join.getCondition(), join.getJoinType());
} else if (physicalJoinType == PhysicalJoinType.MERGE_JOIN) {
newJoin = new MergeJoinPrel(join.getCluster(), traitsLeft, convertedLeft, convertedRight, join.getCondition(), join.getJoinType());
}
call.transformTo(newJoin);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project drill by axbaretto.
the class LimitPrule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final DrillLimitRel limit = (DrillLimitRel) call.rel(0);
final RelNode input = limit.getInput();
final RelTraitSet traits = input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON);
final RelNode convertedInput = convert(input, traits);
LimitPrel newLimit = new LimitPrel(limit.getCluster(), limit.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON), convertedInput, limit.getOffset(), limit.getFetch());
call.transformTo(newLimit);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project drill by axbaretto.
the class SubsetTransformer method go.
public boolean go(T n, RelNode candidateSet) throws E {
if (!(candidateSet instanceof RelSubset)) {
return false;
}
boolean transform = false;
Set<RelNode> transformedRels = Sets.newIdentityHashSet();
Set<RelTraitSet> traitSets = Sets.newHashSet();
// 1, get all the target traitsets from candidateSet's rel list,
for (RelNode rel : ((RelSubset) candidateSet).getRelList()) {
if (isPhysical(rel)) {
final RelTraitSet relTraitSet = rel.getTraitSet();
if (!traitSets.contains(relTraitSet)) {
traitSets.add(relTraitSet);
logger.trace("{}.convertChild get traitSet {}", this.getClass().getSimpleName(), relTraitSet);
}
}
}
// 2, convert the candidateSet to targeted taitSets
for (RelTraitSet traitSet : traitSets) {
RelNode newRel = RelOptRule.convert(candidateSet, traitSet.simplify());
if (transformedRels.contains(newRel)) {
continue;
}
transformedRels.add(newRel);
logger.trace("{}.convertChild to convert NODE {} ,AND {}", this.getClass().getSimpleName(), n, newRel);
RelNode out = convertChild(n, newRel);
// RelNode out = convertChild(n, rel);
if (out != null) {
call.transformTo(out);
transform = true;
}
}
return transform;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project drill by axbaretto.
the class UnionDistinctPrule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final DrillUnionRel union = call.rel(0);
final List<RelNode> inputs = union.getInputs();
List<RelNode> convertedInputList = Lists.newArrayList();
RelTraitSet traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL);
try {
for (RelNode input : inputs) {
RelNode convertedInput = convert(input, PrelUtil.fixTraits(call, traits));
convertedInputList.add(convertedInput);
}
traits = call.getPlanner().emptyTraitSet().plus(Prel.DRILL_PHYSICAL).plus(DrillDistributionTrait.SINGLETON);
UnionDistinctPrel unionDistinct = new UnionDistinctPrel(union.getCluster(), traits, convertedInputList, false);
call.transformTo(unionDistinct);
} catch (InvalidRelException e) {
tracer.warn(e.toString());
}
}
Aggregations