Search in sources :

Example 1 with DingoTableModify

use of io.dingodb.calcite.rel.DingoTableModify 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 2 with DingoTableModify

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

the class DingoPartModifyRule method checkUpdateInPart.

private static void checkUpdateInPart(@Nonnull DingoTableModify rel) {
    DingoTable table = rel.getTable().unwrap(DingoTable.class);
    assert table != null;
    TableDefinition td = table.getTableDefinition();
    List<String> updateList = rel.getUpdateColumnList();
    if (updateList != null && updateList.stream().anyMatch(c -> Objects.requireNonNull(td.getColumn(c)).isPrimary())) {
        throw new IllegalStateException("Update columns " + updateList + " contain primary columns and are not supported.");
    }
}
Also used : DingoTable(io.dingodb.calcite.DingoTable) DingoExchange(io.dingodb.calcite.rel.DingoExchange) RelOptCluster(org.apache.calcite.plan.RelOptCluster) DingoTableModify(io.dingodb.calcite.rel.DingoTableModify) TableDefinition(io.dingodb.common.table.TableDefinition) RelRule(org.apache.calcite.plan.RelRule) RelNode(org.apache.calcite.rel.RelNode) RelOptRuleCall(org.apache.calcite.plan.RelOptRuleCall) Objects(java.util.Objects) DingoConventions(io.dingodb.calcite.DingoConventions) List(java.util.List) DingoPartModify(io.dingodb.calcite.rel.DingoPartModify) DingoPartition(io.dingodb.calcite.rel.DingoPartition) DingoTable(io.dingodb.calcite.DingoTable) Nonnull(javax.annotation.Nonnull) TableDefinition(io.dingodb.common.table.TableDefinition)

Example 3 with DingoTableModify

use of io.dingodb.calcite.rel.DingoTableModify 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 DingoTableModify (io.dingodb.calcite.rel.DingoTableModify)3 RelOptCluster (org.apache.calcite.plan.RelOptCluster)3 DingoExchange (io.dingodb.calcite.rel.DingoExchange)2 DingoPartition (io.dingodb.calcite.rel.DingoPartition)2 RelNode (org.apache.calcite.rel.RelNode)2 DingoConventions (io.dingodb.calcite.DingoConventions)1 DingoTable (io.dingodb.calcite.DingoTable)1 DingoDistributedValues (io.dingodb.calcite.rel.DingoDistributedValues)1 TableDefinition (io.dingodb.common.table.TableDefinition)1 List (java.util.List)1 Objects (java.util.Objects)1 Nonnull (javax.annotation.Nonnull)1 RelOptRuleCall (org.apache.calcite.plan.RelOptRuleCall)1 RelOptTable (org.apache.calcite.plan.RelOptTable)1 RelRule (org.apache.calcite.plan.RelRule)1 Values (org.apache.calcite.rel.core.Values)1