Search in sources :

Example 16 with RelSubset

use of org.apache.calcite.plan.volcano.RelSubset in project drill by apache.

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
    if (traitSets.size() == 0 && forceConvert()) {
        RelNode out = convertChild(n, null);
        if (out != null) {
            call.transformTo(out);
            return true;
        }
        return false;
    }
    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;
}
Also used : RelNode(org.apache.calcite.rel.RelNode) RelTraitSet(org.apache.calcite.plan.RelTraitSet) RelSubset(org.apache.calcite.plan.volcano.RelSubset)

Example 17 with RelSubset

use of org.apache.calcite.plan.volcano.RelSubset in project drill by apache.

the class RuntimeFilterVisitor method findLeftScanPrel.

/**
 * Find a join condition's left input source scan Prel. If we can't find a target scan Prel then this
 * RuntimeFilter can not pushed down to a probe side scan Prel.
 *
 * @param fieldName   left join condition field Name
 * @param leftRelNode left RelNode of a BiRel or the SingleRel
 * @return a left scan Prel which contains the left join condition name or null
 */
private ScanPrel findLeftScanPrel(String fieldName, RelNode leftRelNode) {
    if (leftRelNode instanceof ScanPrel) {
        RelDataType scanRowType = leftRelNode.getRowType();
        RelDataTypeField field = scanRowType.getField(fieldName, true, true);
        if (field != null) {
            // found
            return (ScanPrel) leftRelNode;
        } else {
            return null;
        }
    } else if (leftRelNode instanceof RelSubset) {
        RelNode bestNode = ((RelSubset) leftRelNode).getBest();
        if (bestNode != null) {
            return findLeftScanPrel(fieldName, bestNode);
        } else {
            return null;
        }
    } else {
        List<RelNode> relNodes = leftRelNode.getInputs();
        RelNode leftNode = relNodes.get(0);
        return findLeftScanPrel(fieldName, leftNode);
    }
}
Also used : ScanPrel(org.apache.drill.exec.planner.physical.ScanPrel) RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) RelNode(org.apache.calcite.rel.RelNode) RelDataType(org.apache.calcite.rel.type.RelDataType) ArrayList(java.util.ArrayList) List(java.util.List) RelSubset(org.apache.calcite.plan.volcano.RelSubset)

Aggregations

RelSubset (org.apache.calcite.plan.volcano.RelSubset)11 RelNode (org.apache.calcite.rel.RelNode)10 RelSubset (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.volcano.RelSubset)6 RelNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode)6 ArrayList (java.util.ArrayList)3 RexNode (org.apache.calcite.rex.RexNode)3 LogicalCorrelate (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.logical.LogicalCorrelate)2 LogicalProject (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.logical.LogicalProject)2 RexFieldAccess (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexFieldAccess)2 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)2 RelTraitSet (org.apache.calcite.plan.RelTraitSet)2 HepRelVertex (org.apache.calcite.plan.hep.HepRelVertex)2 Join (org.apache.calcite.rel.core.Join)2 DrillAggregateRel (org.apache.drill.exec.planner.logical.DrillAggregateRel)2 FlinkLogicalCalc (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCalc)2 FlinkLogicalCorrelate (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalCorrelate)2 FlinkLogicalTableFunctionScan (org.apache.flink.table.planner.plan.nodes.logical.FlinkLogicalTableFunctionScan)2 List (java.util.List)1 BaseRelTest (org.apache.beam.sdk.extensions.sql.impl.rel.BaseRelTest)1 BeamIOSourceRel (org.apache.beam.sdk.extensions.sql.impl.rel.BeamIOSourceRel)1