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;
}
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);
}
}
Aggregations