use of org.apache.calcite.rel.core.CorrelationId in project ignite by apache.
the class IgniteFilter method passThroughCorrelation.
/**
*/
@Override
public Pair<RelTraitSet, List<RelTraitSet>> passThroughCorrelation(RelTraitSet nodeTraits, List<RelTraitSet> inTraits) {
Set<CorrelationId> corrSet = RexUtils.extractCorrelationIds(getCondition());
CorrelationTrait correlation = TraitUtils.correlation(nodeTraits);
if (corrSet.isEmpty() || correlation.correlationIds().containsAll(corrSet))
return Pair.of(nodeTraits, ImmutableList.of(inTraits.get(0).replace(correlation)));
return null;
}
use of org.apache.calcite.rel.core.CorrelationId in project ignite by apache.
the class ProjectConverterRule method convert.
/**
* {@inheritDoc}
*/
@Override
protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalProject rel) {
RelOptCluster cluster = rel.getCluster();
RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE).replace(IgniteDistributions.single());
Set<CorrelationId> corrIds = RexUtils.extractCorrelationIds(rel.getProjects());
if (!corrIds.isEmpty()) {
traits = traits.replace(CorrelationTrait.correlations(corrIds)).replace(RewindabilityTrait.REWINDABLE);
}
RelNode input = convert(rel.getInput(), traits);
return new IgniteProject(cluster, traits, input, rel.getProjects(), rel.getRowType());
}
use of org.apache.calcite.rel.core.CorrelationId in project ignite by apache.
the class CorrelateToNestedLoopRule method convert.
/**
* {@inheritDoc}
*/
@Override
protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalCorrelate rel) {
final RelOptCluster cluster = rel.getCluster();
final Set<CorrelationId> correlationIds = Collections.singleton(rel.getCorrelationId());
CorrelationTrait corrTrait = CorrelationTrait.correlations(correlationIds);
RelTraitSet outTraits = cluster.traitSetOf(IgniteConvention.INSTANCE);
RelTraitSet leftInTraits = cluster.traitSetOf(IgniteConvention.INSTANCE);
RelTraitSet rightInTraits = cluster.traitSetOf(IgniteConvention.INSTANCE).replace(RewindabilityTrait.REWINDABLE).replace(corrTrait);
RelNode left = convert(rel.getLeft(), leftInTraits);
RelNode right = convert(rel.getRight(), rightInTraits);
return new IgniteCorrelatedNestedLoopJoin(cluster, outTraits, left, right, cluster.getRexBuilder().makeLiteral(true), correlationIds, rel.getJoinType());
}
use of org.apache.calcite.rel.core.CorrelationId in project ignite by apache.
the class FilterConverterRule method convert.
/**
* {@inheritDoc}
*/
@Override
protected PhysicalNode convert(RelOptPlanner planner, RelMetadataQuery mq, LogicalFilter rel) {
RelOptCluster cluster = rel.getCluster();
RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE).replace(IgniteDistributions.single());
Set<CorrelationId> corrIds = RexUtils.extractCorrelationIds(rel.getCondition());
if (!corrIds.isEmpty()) {
traits = traits.replace(CorrelationTrait.correlations(corrIds)).replace(RewindabilityTrait.REWINDABLE);
}
return new IgniteFilter(cluster, traits, convert(rel.getInput(), traits.replace(CorrelationTrait.UNCORRELATED)), rel.getCondition());
}
use of org.apache.calcite.rel.core.CorrelationId in project flink by splunk.
the class HiveParserRexNodeConverter method convertColumn.
private RexNode convertColumn(ExprNodeColumnDesc col) throws SemanticException {
// if this is co-rrelated we need to make RexCorrelVariable(with id and type)
// id and type should be retrieved from outerRR
InputCtx ic = getInputCtx(col);
if (ic == null) {
// we have correlated column, build data type from outer rr
RelDataType rowType = HiveParserTypeConverter.getType(cluster, this.outerRR, null);
if (this.outerNameToPos.get(col.getColumn()) == null) {
throw new SemanticException("Invalid column name " + col.getColumn());
}
int pos = this.outerNameToPos.get(col.getColumn());
CorrelationId colCorr = new CorrelationId(this.correlatedId);
RexNode corExpr = cluster.getRexBuilder().makeCorrel(rowType, colCorr);
return cluster.getRexBuilder().makeFieldAccess(corExpr, pos);
}
int pos = ic.hiveNameToPosMap.get(col.getColumn());
return cluster.getRexBuilder().makeInputRef(ic.calciteInpDataType.getFieldList().get(pos).getType(), pos + ic.offsetInCalciteSchema);
}
Aggregations