Search in sources :

Example 86 with Join

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Join in project drill by apache.

the class PluginJoinRule method convert.

@Override
public RelNode convert(RelNode rel) {
    Join join = (Join) rel;
    RelTraitSet traits = join.getTraitSet().replace(getOutConvention());
    return new PluginJoinRel(join.getCluster(), traits, convert(join.getLeft(), traits), convert(join.getRight(), traits), join.getCondition(), join.getJoinType());
}
Also used : PluginJoinRel(org.apache.drill.exec.store.plan.rel.PluginJoinRel) Join(org.apache.calcite.rel.core.Join) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 87 with Join

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Join in project drill by apache.

the class PluginConverterRule method matches.

@Override
public boolean matches(RelOptRuleCall call) {
    RelNode rel = call.rel(0);
    boolean canImplement = false;
    // cannot use visitor pattern here, since RelShuttle supports only logical rel implementations
    if (rel instanceof Aggregate) {
        canImplement = pluginImplementor.canImplement(((Aggregate) rel));
    } else if (rel instanceof Filter) {
        canImplement = pluginImplementor.canImplement(((Filter) rel));
    } else if (rel instanceof DrillLimitRelBase) {
        canImplement = pluginImplementor.canImplement(((DrillLimitRelBase) rel));
    } else if (rel instanceof Project) {
        canImplement = pluginImplementor.canImplement(((Project) rel));
    } else if (rel instanceof Sort) {
        canImplement = pluginImplementor.canImplement(((Sort) rel));
    } else if (rel instanceof Union) {
        canImplement = pluginImplementor.canImplement(((Union) rel));
    } else if (rel instanceof Join) {
        canImplement = pluginImplementor.canImplement(((Join) rel));
    }
    return canImplement && super.matches(call);
}
Also used : Project(org.apache.calcite.rel.core.Project) RelNode(org.apache.calcite.rel.RelNode) Filter(org.apache.calcite.rel.core.Filter) DrillLimitRelBase(org.apache.drill.exec.planner.common.DrillLimitRelBase) Sort(org.apache.calcite.rel.core.Sort) Join(org.apache.calcite.rel.core.Join) Aggregate(org.apache.calcite.rel.core.Aggregate) Union(org.apache.calcite.rel.core.Union)

Example 88 with Join

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.core.Join in project calcite by apache.

the class SqlToRelConverter method createJoin.

protected RelNode createJoin(Blackboard bb, RelNode leftRel, RelNode rightRel, RexNode joinCond, JoinRelType joinType) {
    assert joinCond != null;
    final CorrelationUse p = getCorrelationUse(bb, rightRel);
    if (p != null) {
        LogicalCorrelate corr = LogicalCorrelate.create(leftRel, p.r, p.id, p.requiredColumns, SemiJoinType.of(joinType));
        if (!joinCond.isAlwaysTrue()) {
            final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY;
            return factory.createFilter(corr, joinCond);
        }
        return corr;
    }
    final Join originalJoin = (Join) RelFactories.DEFAULT_JOIN_FACTORY.createJoin(leftRel, rightRel, joinCond, ImmutableSet.<CorrelationId>of(), joinType, false);
    return RelOptUtil.pushDownJoinConditions(originalJoin, relBuilder);
}
Also used : Join(org.apache.calcite.rel.core.Join) LogicalJoin(org.apache.calcite.rel.logical.LogicalJoin) SqlJoin(org.apache.calcite.sql.SqlJoin) LogicalCorrelate(org.apache.calcite.rel.logical.LogicalCorrelate) CorrelationId(org.apache.calcite.rel.core.CorrelationId) RelFactories(org.apache.calcite.rel.core.RelFactories)

Aggregations

Join (org.apache.calcite.rel.core.Join)73 RelNode (org.apache.calcite.rel.RelNode)45 RexNode (org.apache.calcite.rex.RexNode)40 ArrayList (java.util.ArrayList)31 LogicalJoin (org.apache.calcite.rel.logical.LogicalJoin)25 Project (org.apache.calcite.rel.core.Project)22 RexBuilder (org.apache.calcite.rex.RexBuilder)20 ImmutableBitSet (org.apache.calcite.util.ImmutableBitSet)18 RelBuilder (org.apache.calcite.tools.RelBuilder)17 HiveJoin (org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin)14 Aggregate (org.apache.calcite.rel.core.Aggregate)13 Test (org.junit.Test)13 Filter (org.apache.calcite.rel.core.Filter)12 RelNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.RelNode)11 SemiJoin (org.apache.calcite.rel.core.SemiJoin)11 RelOptCluster (org.apache.calcite.plan.RelOptCluster)10 JoinRelType (org.apache.calcite.rel.core.JoinRelType)9 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)9 Mappings (org.apache.calcite.util.mapping.Mappings)9 List (java.util.List)8