-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][dingo-calcite,dingo-exec] Support select... for update
- Loading branch information
Showing
25 changed files
with
730 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
dingo-calcite/src/main/java/io/dingodb/calcite/rel/DingoForUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.dingodb.calcite.rel; | ||
|
||
import io.dingodb.calcite.visitor.DingoRelVisitor; | ||
import lombok.Getter; | ||
import org.apache.calcite.plan.RelOptCluster; | ||
import org.apache.calcite.plan.RelOptTable; | ||
import org.apache.calcite.plan.RelTraitSet; | ||
import org.apache.calcite.rel.RelNode; | ||
import org.apache.calcite.rel.SingleRel; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
import java.util.List; | ||
|
||
public class DingoForUpdate extends SingleRel implements DingoRel { | ||
|
||
@Getter | ||
private RelOptTable table; | ||
|
||
/** | ||
* Creates a <code>SingleRel</code>. | ||
* | ||
* @param cluster Cluster this relational expression belongs to | ||
* @param traits | ||
* @param input Input relational expression | ||
*/ | ||
public DingoForUpdate(RelOptCluster cluster, RelTraitSet traits, RelNode input, RelOptTable table) { | ||
super(cluster, traits, input); | ||
this.table = table; | ||
} | ||
|
||
@Override | ||
public <T> T accept(@NonNull DingoRelVisitor<T> visitor) { | ||
return visitor.visit(this); | ||
} | ||
|
||
@Override | ||
public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { | ||
return new DingoForUpdate(getCluster(), traitSet, sole(inputs), table); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
dingo-calcite/src/main/java/io/dingodb/calcite/rel/LogicalForUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.dingodb.calcite.rel; | ||
|
||
import io.dingodb.calcite.DingoRelOptTable; | ||
import lombok.Getter; | ||
import org.apache.calcite.plan.RelOptCluster; | ||
import org.apache.calcite.plan.RelOptTable; | ||
import org.apache.calcite.plan.RelTraitSet; | ||
import org.apache.calcite.rel.RelNode; | ||
import org.apache.calcite.rel.SingleRel; | ||
|
||
import java.util.List; | ||
|
||
public class LogicalForUpdate extends SingleRel { | ||
|
||
@Getter | ||
private final RelOptTable table; | ||
|
||
/** | ||
* Creates a <code>SingleRel</code>. | ||
* | ||
* @param cluster Cluster this relational expression belongs to | ||
* @param traits | ||
* @param input Input relational expression | ||
*/ | ||
public LogicalForUpdate(RelOptCluster cluster, RelTraitSet traits, RelNode input, RelOptTable table) { | ||
super(cluster, traits, input); | ||
this.table = table; | ||
} | ||
|
||
@Override | ||
public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { | ||
return new LogicalForUpdate(getCluster(), traitSet, sole(inputs), table); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
dingo-calcite/src/main/java/io/dingodb/calcite/rule/DingoForUpdateRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2021 DataCanvas | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.dingodb.calcite.rule; | ||
|
||
import io.dingodb.calcite.rel.DingoForUpdate; | ||
import io.dingodb.calcite.rel.LogicalForUpdate; | ||
import io.dingodb.calcite.traits.DingoConvention; | ||
import io.dingodb.calcite.traits.DingoRelStreaming; | ||
import org.apache.calcite.plan.Convention; | ||
import org.apache.calcite.plan.RelTraitSet; | ||
import org.apache.calcite.rel.RelNode; | ||
import org.apache.calcite.rel.convert.ConverterRule; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
public class DingoForUpdateRule extends ConverterRule { | ||
|
||
public static final Config DEFAULT = Config.INSTANCE | ||
.withConversion( | ||
LogicalForUpdate.class, | ||
Convention.NONE, | ||
DingoConvention.INSTANCE, | ||
"DingoForUpdateRule" | ||
) | ||
.withRuleFactory(DingoForUpdateRule::new); | ||
|
||
protected DingoForUpdateRule(Config config) { | ||
super(config); | ||
} | ||
|
||
@Override | ||
public @Nullable RelNode convert(RelNode rel) { | ||
LogicalForUpdate logicalForUpdate = (LogicalForUpdate) rel; | ||
RelTraitSet traits = logicalForUpdate.getTraitSet() | ||
.replace(DingoConvention.INSTANCE) | ||
.replace(DingoRelStreaming.ROOT); | ||
return new DingoForUpdate( | ||
logicalForUpdate.getCluster(), | ||
traits, | ||
convert(logicalForUpdate.getInput(), traits), | ||
logicalForUpdate.getTable()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.