You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "lowka (via GitHub)" <gi...@apache.org> on 2026/03/04 14:19:58 UTC
[PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
lowka opened a new pull request, #7703:
URL: https://github.com/apache/ignite-3/pull/7703
WIP
https://issues.apache.org/jira/browse/IGNITE-26203
---
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2939804906
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
+ if (!preserveOrder) {
+ return null;
+ }
+
+ if (!nullOrEmpty(projects)) {
+ assert requiredColumns != null : "No required columns: " + rel;
+
+ List<RexNode> expectedProjection = createProjectionFromScan(modifiedTable.getSecond(), projects, requiredColumns);
+ RelDataType rowType = table.getRowType(rel.getCluster().getTypeFactory(), requiredColumns);
+
+ if (!RexUtils.isIdentity(expectedProjection, rowType)) {
Review Comment:
Updated to support projections that preserve order of colocation key columns but allowing arbitrary expressions in non-colocation columns.
```
// Given t with columns k0, k1, k2, k4, where k1, k2 are colocation keys
INSERT INTO t SELECT 10, k1, k2, 100 FROM t WHERE k1=a AND k2=2
// OK, Both Scan and Modify have the same metadata
INSERT INTO t SELECT 10, k2, k1, 100 FROM t WHERE k1=a AND k2=2
// Only Scan has the same metadata as INSERT's k1 is going to have values from k2.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2993628337
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +401,98 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ if (metadata == null) {
+ return null;
Review Comment:
This breaks processing for `UnionAll`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2992908624
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +401,98 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ if (metadata == null) {
+ return null;
Review Comment:
if meta is null or empty then we should use a single row with all columns set to `VALUE_NOT_ASSIGNED` as `values`
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -82,14 +98,59 @@ private ModifyNodeVisitor() {
* <p>Every element from outer list contributes a partition, so after pruning all partitions defined by these
* expressions must be preserved in the plan.
*
+ * @param extractor Metadata extractor to use.
* @param tableModify A modify node to start traversal from.
* @return A list of expressions. It's guaranteed that returned collection represents complete set of partitions. Returns {@code null}
* otherwise.
*/
- static @Nullable List<List<RexNode>> go(IgniteTableModify tableModify) {
- var modifyNodeShuttle = new ModifyNodeVisitor();
+ static @Nullable List<List<@Nullable RexNode>> go(
+ PartitionPruningMetadataExtractor extractor,
+ IgniteTableModify tableModify
+ ) {
+ switch (tableModify.getOperation()) {
+ case INSERT:
+ case UPDATE: {
+ ModifyNodeVisitor visitor = new ModifyNodeVisitor(extractor);
+ return visitor.visit((IgniteRel) tableModify.getInput());
+ }
+ case DELETE: {
+ ModifyNodeVisitor visitor = new ModifyNodeVisitor(extractor);
+ List<List<RexNode>> values = visitor.visit((IgniteRel) tableModify.getInput());
+
+ if (nullOrEmpty(values)) {
+ return null;
+ }
+
Review Comment:
instead of rebuilding the full row I would rather adjusted `org.apache.ignite.internal.sql.engine.prepare.pruning.PartitionPruningMetadataExtractor#extractFromValues` to accept `keysList` as input parameters and pass adjusted list for `DELETE` operation instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 merged PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2939811253
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
+ if (!preserveOrder) {
+ return null;
+ }
+
+ if (!nullOrEmpty(projects)) {
+ assert requiredColumns != null : "No required columns: " + rel;
+
+ List<RexNode> expectedProjection = createProjectionFromScan(modifiedTable.getSecond(), projects, requiredColumns);
+ RelDataType rowType = table.getRowType(rel.getCluster().getTypeFactory(), requiredColumns);
+
+ if (!RexUtils.isIdentity(expectedProjection, rowType)) {
+ return null;
+ }
+ }
+
+ return metadataToValues(table, metadata);
+ }
+
+ private static boolean projectionPreservesColumnOrder(ImmutableIntList requiredColumns) {
Review Comment:
Fixed. This method is no longer needed and it has been removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2939781173
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
Review Comment:
Fixed.
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -73,7 +85,19 @@
class ModifyNodeVisitor implements IgniteRelVisitor<List<List<RexNode>>> {
private static final IgniteLogger LOG = Loggers.forClass(ModifyNodeVisitor.class);
- private ModifyNodeVisitor() {
+ /**
+ * A placeholder used to designate that there is no value for a column. If PP metadata collection algorithm encounters this placeholder
+ * in a colocation column for a source, then there can be no PP metadata for this source. Since this is a marker to terminate
+ * algorithm, the type chosen for this expression does not matter.
+ */
+ static final RexNode VALUE_NOT_ASSIGNED = new RexInputRef(0, Commons.typeFactory().createSqlType(SqlTypeName.NULL));
+
+ private final PartitionPruningMetadataExtractor extractor;
+
+ private Pair<IgniteTable, Operation> modifiedTable;
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2993961330
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +401,98 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ if (metadata == null) {
+ return null;
Review Comment:
Ignore that comment, everything is going to work.
Fixed.
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -82,14 +98,59 @@ private ModifyNodeVisitor() {
* <p>Every element from outer list contributes a partition, so after pruning all partitions defined by these
* expressions must be preserved in the plan.
*
+ * @param extractor Metadata extractor to use.
* @param tableModify A modify node to start traversal from.
* @return A list of expressions. It's guaranteed that returned collection represents complete set of partitions. Returns {@code null}
* otherwise.
*/
- static @Nullable List<List<RexNode>> go(IgniteTableModify tableModify) {
- var modifyNodeShuttle = new ModifyNodeVisitor();
+ static @Nullable List<List<@Nullable RexNode>> go(
+ PartitionPruningMetadataExtractor extractor,
+ IgniteTableModify tableModify
+ ) {
+ switch (tableModify.getOperation()) {
+ case INSERT:
+ case UPDATE: {
+ ModifyNodeVisitor visitor = new ModifyNodeVisitor(extractor);
+ return visitor.visit((IgniteRel) tableModify.getInput());
+ }
+ case DELETE: {
+ ModifyNodeVisitor visitor = new ModifyNodeVisitor(extractor);
+ List<List<RexNode>> values = visitor.visit((IgniteRel) tableModify.getInput());
+
+ if (nullOrEmpty(values)) {
+ return null;
+ }
+
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2938571974
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -73,7 +85,19 @@
class ModifyNodeVisitor implements IgniteRelVisitor<List<List<RexNode>>> {
private static final IgniteLogger LOG = Loggers.forClass(ModifyNodeVisitor.class);
- private ModifyNodeVisitor() {
+ /**
+ * A placeholder used to designate that there is no value for a column. If PP metadata collection algorithm encounters this placeholder
+ * in a colocation column for a source, then there can be no PP metadata for this source. Since this is a marker to terminate
+ * algorithm, the type chosen for this expression does not matter.
+ */
+ static final RexNode VALUE_NOT_ASSIGNED = new RexInputRef(0, Commons.typeFactory().createSqlType(SqlTypeName.NULL));
+
+ private final PartitionPruningMetadataExtractor extractor;
+
+ private Pair<IgniteTable, Operation> modifiedTable;
Review Comment:
let's split this pair and make fields final
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
Review Comment:
if required columns is null then we won't extract anything, right?
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
+ if (!preserveOrder) {
+ return null;
+ }
+
+ if (!nullOrEmpty(projects)) {
+ assert requiredColumns != null : "No required columns: " + rel;
+
+ List<RexNode> expectedProjection = createProjectionFromScan(modifiedTable.getSecond(), projects, requiredColumns);
+ RelDataType rowType = table.getRowType(rel.getCluster().getTypeFactory(), requiredColumns);
+
+ if (!RexUtils.isIdentity(expectedProjection, rowType)) {
Review Comment:
this limitation is too strict. We are interested in colocation columns only and we don't care about the rest. Moreover, all the test which were added for INSERT scenario doesn't make any sense, because you can't insert two identical keys. Such queries always end up in PK violation
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +378,113 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ IgniteRel rel,
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ // Do not propagate metadata if tables are different for now.
+ IgniteTable tableUnderModification = modifiedTable.getFirst();
+ if (metadata == null || tableUnderModification.id() != table.id()) {
+ return null;
+ }
+
+ // Only handle column order-preserving projections for now.
+ boolean preserveOrder = requiredColumns != null && projectionPreservesColumnOrder(requiredColumns);
+ if (!preserveOrder) {
+ return null;
+ }
+
+ if (!nullOrEmpty(projects)) {
+ assert requiredColumns != null : "No required columns: " + rel;
+
+ List<RexNode> expectedProjection = createProjectionFromScan(modifiedTable.getSecond(), projects, requiredColumns);
+ RelDataType rowType = table.getRowType(rel.getCluster().getTypeFactory(), requiredColumns);
+
+ if (!RexUtils.isIdentity(expectedProjection, rowType)) {
+ return null;
+ }
+ }
+
+ return metadataToValues(table, metadata);
+ }
+
+ private static boolean projectionPreservesColumnOrder(ImmutableIntList requiredColumns) {
Review Comment:
name of the method is misleading. Currently, it checks not only order is preserved, but also that `requiredColumns` is prefix with no gaps
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-26203 Sql. Partition pruning. No metadata for INSERT INTO table SELECT FROM table [ignite-3]
Posted by "korlov42 (via GitHub)" <gi...@apache.org>.
korlov42 commented on code in PR #7703:
URL: https://github.com/apache/ignite-3/pull/7703#discussion_r2993891601
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/ModifyNodeVisitor.java:
##########
@@ -332,4 +401,98 @@ public RexNode visitInputRef(RexInputRef inputRef) {
return null;
}
+
+ private @Nullable List<List<RexNode>> extractValuesFromScan(
+ long sourceId,
+ IgniteTable table,
+ @Nullable ImmutableIntList requiredColumns,
+ @Nullable List<RexNode> projects
+ ) {
+ PartitionPruningColumns metadata = extractor.result.get(sourceId);
+ if (metadata == null) {
+ return null;
Review Comment:
may you elaborate what is exactly wrong with `UnionAll`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org