use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation in project drill by apache.
the class MergeJoinPrule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
final DrillJoinRel join = call.rel(0);
final RelNode left = join.getLeft();
final RelNode right = join.getRight();
if (!checkPreconditions(join, left, right, settings)) {
return;
}
boolean hashSingleKey = PrelUtil.getPlannerSettings(call.getPlanner()).isHashSingleKey();
try {
RelCollation collationLeft = getCollation(join.getLeftKeys());
RelCollation collationRight = getCollation(join.getRightKeys());
if (isDist) {
createDistBothPlan(call, join, PhysicalJoinType.MERGE_JOIN, left, right, collationLeft, collationRight, hashSingleKey);
} else {
if (checkBroadcastConditions(call.getPlanner(), join, left, right)) {
createBroadcastPlan(call, join, join.getCondition(), PhysicalJoinType.MERGE_JOIN, left, right, collationLeft, collationRight);
}
}
} catch (InvalidRelException e) {
tracer.warn(e.toString());
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation in project drill by apache.
the class WriterPrule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final DrillWriterRel writer = call.rel(0);
final RelNode input = call.rel(1);
final List<Integer> keys = writer.getPartitionKeys();
final RelCollation collation = getCollation(keys);
final boolean hashDistribute = PrelUtil.getPlannerSettings(call.getPlanner()).getOptions().getOption(ExecConstants.CTAS_PARTITIONING_HASH_DISTRIBUTE_VALIDATOR);
final RelTraitSet traits = hashDistribute ? input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation).plus(getDistribution(keys)) : input.getTraitSet().plus(Prel.DRILL_PHYSICAL).plus(collation);
final RelNode convertedInput = convert(input, traits);
if (!new WriteTraitPull(call).go(writer, convertedInput)) {
DrillWriterRelBase newWriter = new WriterPrel(writer.getCluster(), convertedInput.getTraitSet(), convertedInput, writer.getCreateTableEntry());
call.transformTo(newWriter);
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation in project drill by apache.
the class TopNPrel method prepareForLateralUnnestPipeline.
@Override
public Prel prepareForLateralUnnestPipeline(List<RelNode> children) {
List<RelFieldCollation> relFieldCollations = Lists.newArrayList();
relFieldCollations.add(new RelFieldCollation(0, RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST));
for (RelFieldCollation fieldCollation : this.collation.getFieldCollations()) {
relFieldCollations.add(new RelFieldCollation(fieldCollation.getFieldIndex() + 1, fieldCollation.direction, fieldCollation.nullDirection));
}
RelCollation collationTrait = RelCollations.of(relFieldCollations);
RelTraitSet traits = RelTraitSet.createEmpty().replace(this.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE)).replace(collationTrait).replace(DRILL_PHYSICAL);
return transformTopNToSortAndLimit(children, traits, collationTrait);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation in project drill by apache.
the class SortPrel method prepareForLateralUnnestPipeline.
@Override
public Prel prepareForLateralUnnestPipeline(List<RelNode> children) {
List<RelFieldCollation> relFieldCollations = Lists.newArrayList();
relFieldCollations.add(new RelFieldCollation(0, RelFieldCollation.Direction.ASCENDING, RelFieldCollation.NullDirection.FIRST));
for (RelFieldCollation fieldCollation : this.collation.getFieldCollations()) {
relFieldCollations.add(new RelFieldCollation(fieldCollation.getFieldIndex() + 1, fieldCollation.direction, fieldCollation.nullDirection));
}
@SuppressWarnings("deprecation") RelCollation collationTrait = RelCollationImpl.of(relFieldCollations);
RelTraitSet traits = RelTraitSet.createEmpty().replace(this.getTraitSet().getTrait(DrillDistributionTraitDef.INSTANCE)).replace(collationTrait).replace(DRILL_PHYSICAL);
return this.copy(traits, children.get(0), collationTrait, this.offset, this.fetch);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelCollation in project herddb by diennea.
the class CalcitePlanner method planSort.
private PlannerOp planSort(EnumerableSort op, RelDataType rowType) {
PlannerOp input = convertRelNode(op.getInput(), rowType, false, false);
RelCollation collation = op.getCollation();
List<RelFieldCollation> fieldCollations = collation.getFieldCollations();
boolean[] directions = new boolean[fieldCollations.size()];
boolean[] nullLastdirections = new boolean[fieldCollations.size()];
int[] fields = new int[fieldCollations.size()];
int i = 0;
for (RelFieldCollation col : fieldCollations) {
RelFieldCollation.Direction direction = col.getDirection();
int index = col.getFieldIndex();
RelFieldCollation.NullDirection nullDirection = col.nullDirection;
directions[i] = direction == RelFieldCollation.Direction.ASCENDING || direction == RelFieldCollation.Direction.STRICTLY_ASCENDING;
// default is NULL LAST
nullLastdirections[i] = nullDirection == RelFieldCollation.NullDirection.LAST || nullDirection == RelFieldCollation.NullDirection.UNSPECIFIED;
fields[i++] = index;
}
return new SortOp(input, directions, fields, nullLastdirections);
}
Aggregations