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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to