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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]