Search in sources :

Example 1 with DingoPartModify

use of io.dingodb.calcite.rel.DingoPartModify in project dingo by dingodb.

the class TestDingoJobVisitor method testVisitPartModify.

@Test
public void testVisitPartModify() {
    RelOptCluster cluster = parser.getCluster();
    DingoPartModify partModify = new DingoPartModify(cluster, cluster.traitSetOf(DingoConventions.DISTRIBUTED), distributedValues, table, TableModify.Operation.INSERT, null, null);
    Job job = DingoJobVisitor.createJob(partModify);
    Assert.job(job).taskNum(2).task(0, t -> t.location(MockMetaServiceProvider.LOC_0).operatorNum(2).soleSource().isA(ValuesOperator.class).soleOutput().isA(PartModifyOperator.class)).task(1, t -> t.location(MockMetaServiceProvider.LOC_1).operatorNum(2).soleSource().isA(ValuesOperator.class).soleOutput().isA(PartModifyOperator.class));
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoExchange(io.dingodb.calcite.rel.DingoExchange) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) DingoParserContext(io.dingodb.calcite.DingoParserContext) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assert(io.dingodb.calcite.assertion.Assert) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) RelOptTable(org.apache.calcite.plan.RelOptTable) Job(io.dingodb.exec.base.Job) BigDecimal(java.math.BigDecimal) DingoConventions(io.dingodb.calcite.DingoConventions) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) ImmutableList(com.google.common.collect.ImmutableList) BeforeAll(org.junit.jupiter.api.BeforeAll) DingoCoalesce(io.dingodb.calcite.rel.DingoCoalesce) MockMetaServiceProvider(io.dingodb.calcite.mock.MockMetaServiceProvider) TableModify(org.apache.calcite.rel.core.TableModify) PartModifyOperator(io.dingodb.exec.operator.PartModifyOperator) RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelDataType(org.apache.calcite.rel.type.RelDataType) SqlTypeName(org.apache.calcite.sql.type.SqlTypeName) TableId(io.dingodb.common.table.TableId) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) DingoParser(io.dingodb.calcite.DingoParser) SendOperator(io.dingodb.exec.operator.SendOperator) List(java.util.List) DingoPartScan(io.dingodb.calcite.rel.DingoPartScan) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) DingoValues(io.dingodb.calcite.rel.DingoValues) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) Job(io.dingodb.exec.base.Job) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) PartModifyOperator(io.dingodb.exec.operator.PartModifyOperator) Test(org.junit.jupiter.api.Test)

Example 2 with DingoPartModify

use of io.dingodb.calcite.rel.DingoPartModify in project dingo by dingodb.

the class DingoDistributedValuesRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    DingoTableModify modify = call.rel(0);
    Values values = call.rel(1);
    RelOptCluster cluster = modify.getCluster();
    RelOptTable table = modify.getTable();
    call.transformTo(new DingoPartModify(cluster, modify.getTraitSet().replace(DingoConventions.DISTRIBUTED), new DingoDistributedValues(cluster, values.getRowType(), values.getTuples(), values.getTraitSet().replace(DingoConventions.DISTRIBUTED), table), table, modify.getOperation(), modify.getUpdateColumnList(), modify.getSourceExpressionList()));
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) Values(org.apache.calcite.rel.core.Values) DingoDistributedValues(io.dingodb.calcite.rel.DingoDistributedValues) DingoTableModify(io.dingodb.calcite.rel.DingoTableModify) RelOptTable(org.apache.calcite.plan.RelOptTable)

Example 3 with DingoPartModify

use of io.dingodb.calcite.rel.DingoPartModify in project dingo by dingodb.

the class DingoPartModifyRule method onMatch.

@Override
public void onMatch(@Nonnull RelOptRuleCall call) {
    DingoTableModify rel = call.rel(0);
    RelNode input = rel.getInput();
    RelNode convertedInput = null;
    RelOptCluster cluster = rel.getCluster();
    switch(rel.getOperation()) {
        case INSERT:
            convertedInput = new DingoExchange(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), new DingoPartition(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convert(input, DingoConventions.DISTRIBUTED), rel.getTable()));
            break;
        case UPDATE:
            // Only support update in part.
            checkUpdateInPart(rel);
            convertedInput = convert(input, DingoConventions.DISTRIBUTED);
            break;
        case DELETE:
            convertedInput = convert(input, DingoConventions.DISTRIBUTED);
            break;
        default:
            throw new IllegalStateException("Operation \"" + rel.getOperation() + "\" is not supported.");
    }
    call.transformTo(new DingoPartModify(cluster, rel.getTraitSet().replace(DingoConventions.DISTRIBUTED), convertedInput, rel.getTable(), rel.getOperation(), rel.getUpdateColumnList(), rel.getSourceExpressionList()));
}
Also used : RelOptCluster(org.apache.calcite.plan.RelOptCluster) RelNode(org.apache.calcite.rel.RelNode) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) DingoTableModify(io.dingodb.calcite.rel.DingoTableModify) DingoPartition(io.dingodb.calcite.rel.DingoPartition) DingoExchange(io.dingodb.calcite.rel.DingoExchange)

Aggregations

DingoPartModify (io.dingodb.calcite.rel.DingoPartModify)3 RelOptCluster (org.apache.calcite.plan.RelOptCluster)3 DingoDistributedValues (io.dingodb.calcite.rel.DingoDistributedValues)2 DingoExchange (io.dingodb.calcite.rel.DingoExchange)2 DingoTableModify (io.dingodb.calcite.rel.DingoTableModify)2 RelOptTable (org.apache.calcite.plan.RelOptTable)2 ImmutableList (com.google.common.collect.ImmutableList)1 DingoConventions (io.dingodb.calcite.DingoConventions)1 DingoParser (io.dingodb.calcite.DingoParser)1 DingoParserContext (io.dingodb.calcite.DingoParserContext)1 Assert (io.dingodb.calcite.assertion.Assert)1 MockMetaServiceProvider (io.dingodb.calcite.mock.MockMetaServiceProvider)1 DingoCoalesce (io.dingodb.calcite.rel.DingoCoalesce)1 DingoPartScan (io.dingodb.calcite.rel.DingoPartScan)1 DingoPartition (io.dingodb.calcite.rel.DingoPartition)1 DingoValues (io.dingodb.calcite.rel.DingoValues)1 TableId (io.dingodb.common.table.TableId)1 Job (io.dingodb.exec.base.Job)1 CoalesceOperator (io.dingodb.exec.operator.CoalesceOperator)1 PartModifyOperator (io.dingodb.exec.operator.PartModifyOperator)1