Search in sources :

Example 1 with IgniteUnionAll

use of org.apache.ignite.internal.sql.engine.rel.IgniteUnionAll in project ignite-3 by apache.

the class UnionConverterRule method onMatch.

/**
 * {@inheritDoc}
 */
@Override
public void onMatch(RelOptRuleCall call) {
    final LogicalUnion union = call.rel(0);
    RelOptCluster cluster = union.getCluster();
    RelTraitSet traits = cluster.traitSetOf(IgniteConvention.INSTANCE);
    List<RelNode> inputs = Commons.transform(union.getInputs(), input -> convert(input, traits));
    RelNode res = new IgniteUnionAll(cluster, traits, inputs);
    if (!union.all) {
        final RelBuilder relBuilder = relBuilderFactory.create(union.getCluster(), null);
        relBuilder.push(res).aggregate(relBuilder.groupKey(ImmutableBitSet.range(union.getRowType().getFieldCount())));
        res = convert(relBuilder.build(), union.getTraitSet());
    }
    call.transformTo(res);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) IgniteUnionAll(org.apache.ignite.internal.sql.engine.rel.IgniteUnionAll) RelBuilder(org.apache.calcite.tools.RelBuilder) LogicalUnion(org.apache.calcite.rel.logical.LogicalUnion) RelNode(org.apache.calcite.rel.RelNode) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Aggregations

RelOptCluster (org.apache.calcite.plan.RelOptCluster)1 RelTraitSet (org.apache.calcite.plan.RelTraitSet)1 RelNode (org.apache.calcite.rel.RelNode)1 LogicalUnion (org.apache.calcite.rel.logical.LogicalUnion)1 RelBuilder (org.apache.calcite.tools.RelBuilder)1 IgniteUnionAll (org.apache.ignite.internal.sql.engine.rel.IgniteUnionAll)1