Search in sources :

Example 11 with RelTraitSet

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project calcite by apache.

the class EnumerableTableModifyRule method convert.

@Override
public RelNode convert(RelNode rel) {
    final LogicalTableModify modify = (LogicalTableModify) rel;
    final ModifiableTable modifiableTable = modify.getTable().unwrap(ModifiableTable.class);
    if (modifiableTable == null) {
        return null;
    }
    final RelTraitSet traitSet = modify.getTraitSet().replace(EnumerableConvention.INSTANCE);
    return new EnumerableTableModify(modify.getCluster(), traitSet, modify.getTable(), modify.getCatalogReader(), convert(modify.getInput(), traitSet), modify.getOperation(), modify.getUpdateColumnList(), modify.getSourceExpressionList(), modify.isFlattened());
}
Also used : ModifiableTable(org.apache.calcite.schema.ModifiableTable) LogicalTableModify(org.apache.calcite.rel.logical.LogicalTableModify) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 12 with RelTraitSet

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project calcite by apache.

the class EnumerableTableFunctionScanRule method convert.

@Override
public RelNode convert(RelNode rel) {
    final RelTraitSet traitSet = rel.getTraitSet().replace(EnumerableConvention.INSTANCE);
    LogicalTableFunctionScan tbl = (LogicalTableFunctionScan) rel;
    return new EnumerableTableFunctionScan(rel.getCluster(), traitSet, tbl.getInputs(), tbl.getElementType(), tbl.getRowType(), tbl.getCall(), tbl.getColumnMappings());
}
Also used : LogicalTableFunctionScan(org.apache.calcite.rel.logical.LogicalTableFunctionScan) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 13 with RelTraitSet

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project calcite by apache.

the class EnumerableAggregateRule method convert.

public RelNode convert(RelNode rel) {
    final LogicalAggregate agg = (LogicalAggregate) rel;
    final RelTraitSet traitSet = agg.getTraitSet().replace(EnumerableConvention.INSTANCE);
    try {
        return new EnumerableAggregate(rel.getCluster(), traitSet, convert(agg.getInput(), EnumerableConvention.INSTANCE), agg.indicator, agg.getGroupSet(), agg.getGroupSets(), agg.getAggCallList());
    } catch (InvalidRelException e) {
        EnumerableRules.LOGGER.debug(e.toString());
        return null;
    }
}
Also used : InvalidRelException(org.apache.calcite.rel.InvalidRelException) LogicalAggregate(org.apache.calcite.rel.logical.LogicalAggregate) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Example 14 with RelTraitSet

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project calcite by apache.

the class EnumerableCalc method create.

/**
 * Creates an EnumerableCalc.
 */
public static EnumerableCalc create(final RelNode input, final RexProgram program) {
    final RelOptCluster cluster = input.getCluster();
    final RelMetadataQuery mq = cluster.getMetadataQuery();
    final RelTraitSet traitSet = cluster.traitSet().replace(EnumerableConvention.INSTANCE).replaceIfs(RelCollationTraitDef.INSTANCE, new Supplier<List<RelCollation>>() {

        public List<RelCollation> get() {
            return RelMdCollation.calc(mq, input, program);
        }
    }).replaceIf(RelDistributionTraitDef.INSTANCE, new Supplier<RelDistribution>() {

        public RelDistribution get() {
            return RelMdDistribution.calc(mq, input, program);
        }
    });
    return new EnumerableCalc(cluster, traitSet, input, program);
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelMetadataQuery(org.apache.calcite.rel.metadata.RelMetadataQuery) RelCollation(org.apache.calcite.rel.RelCollation) Supplier(com.google.common.base.Supplier) RelTraitSet(org.apache.calcite.plan.RelTraitSet) RelDistribution(org.apache.calcite.rel.RelDistribution)

Example 15 with RelTraitSet

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.plan.RelTraitSet in project calcite by apache.

the class EnumerableCollectRule method convert.

public RelNode convert(RelNode rel) {
    final Collect collect = (Collect) rel;
    final RelTraitSet traitSet = collect.getTraitSet().replace(EnumerableConvention.INSTANCE);
    final RelNode input = collect.getInput();
    return new EnumerableCollect(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(EnumerableConvention.INSTANCE)), collect.getFieldName());
}
Also used : RelNode(org.apache.calcite.rel.RelNode) Collect(org.apache.calcite.rel.core.Collect) RelTraitSet(org.apache.calcite.plan.RelTraitSet)

Aggregations

RelTraitSet (org.apache.calcite.plan.RelTraitSet)190 RelNode (org.apache.calcite.rel.RelNode)111 RelOptCluster (org.apache.calcite.plan.RelOptCluster)38 RelCollation (org.apache.calcite.rel.RelCollation)35 RelOptPlanner (org.apache.calcite.plan.RelOptPlanner)26 RexNode (org.apache.calcite.rex.RexNode)24 ArrayList (java.util.ArrayList)20 InvalidRelException (org.apache.calcite.rel.InvalidRelException)19 RelDataType (org.apache.calcite.rel.type.RelDataType)14 SqlNode (org.apache.calcite.sql.SqlNode)14 List (java.util.List)13 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)13 RelOptTable (org.apache.calcite.plan.RelOptTable)11 Sort (org.apache.calcite.rel.core.Sort)11 RelMetadataQuery (org.apache.calcite.rel.metadata.RelMetadataQuery)11 ImmutableList (com.google.common.collect.ImmutableList)10 RelFieldCollation (org.apache.calcite.rel.RelFieldCollation)10 Test (org.junit.Test)9 Table (org.apache.calcite.schema.Table)8 RexInputRef (org.apache.calcite.rex.RexInputRef)7