You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ygerzhedovich (via GitHub)" <gi...@apache.org> on 2024/11/28 14:10:36 UTC

[PR] IGNITE-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

ygerzhedovich opened a new pull request, #4807:
URL: https://github.com/apache/ignite-3/pull/4807

   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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1865943095


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/RowHandler.java:
##########
@@ -114,6 +99,21 @@ interface RowFactory<RowT> {
          * @return RowSchema.
          */
         RowSchema rowSchema();
+
+        /**
+         * Creates a new row from provided source row and containing only the fields specified in the provided mapping.
+         *

Review Comment:
   ```suggestion
            * The result row will satisfy the current factory's schema.
            * 
   ```



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich merged PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807


-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1867994378


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -133,7 +132,8 @@ public ModifyNode(
                         .mapToInt(ColumnDescriptor::logicalIndex)
                         .toArray();
 
-        this.rowFactory = rowFactory;
+        RowSchema rowSchema = rowSchemaForTableDescriptor(table.descriptor());

Review Comment:
   I checked GG9 with spilling enabled in ItDmlTest and looks like that's not correct schema :thinking: 
   At least for Merge.



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863052254


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   It's better to build schema single time for a batch of rows.
   My suggestion (may be @lowka or you have better ideas)
   Add SqlRowHandler.schema(row) method
   Add additional parameter to map method and pass target schema.
   
   In splitMerge, for example, get schema of the first row and build target schema.
   And do the same in flushTuples for the UPDATE operation :thinking: 
   
   p.s. may be it's also worth to mute this failure  https://ci.ignite.apache.org/viewLog.html?buildId=8657663&buildTypeId=ApacheIgnite3xGradle_Test_RunAllTests&fromSakuraUI=true
   in this PR



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863052254


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   It's better to build schema single time for a batch of rows.
   My suggestion (may be @lowka or you have better ideas)
   ~~Add SqlRowHandler.schema(row) method~~
   Add additional parameter to map method and pass target schema.
   
   In ModifyNode.splitMerge, for example, ~~get schema of the first row and~~ build target schema.
   And do the same in flushTuples for the UPDATE operation :thinking: 
   
   p.s. may be it's also worth to mute this failure  https://ci.ignite.apache.org/viewLog.html?buildId=8657663&buildTypeId=ApacheIgnite3xGradle_Test_RunAllTests&fromSakuraUI=true
   in this PR



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863059425


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   Update. There is no need for SqlRowHandler.schema(row) method, just pass source schema in constructor  of modify node
   ```
           RelDataType rowType = rel.getInput().getRowType();
           RowSchema rowSchema = rowSchemaFromRelTypes(RelOptUtil.getFieldTypeList(rowType));
   ```



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#issuecomment-2511704121

   @ygerzhedovich 
   There are changes in documentation that are not related to the PR.


-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1873316096


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -465,9 +479,25 @@ private boolean hasUpsertSemantic(int rowSize) {
 
             assert !columnDescriptor.virtual() : "Virtual column can't be updated";
 
-            mapping[columnDescriptor.logicalIndex()] = columnCount + i;
+            mapping[columnDescriptor.logicalIndex()] = columnCount + i + mergeOffset;
         }
 
         return mapping;
     }
+
+    private RowSchema getMappedRowSchema(RowFactory<RowT> inputRowFactory, int[] mapping) {
+        RowSchema schema;
+        if (mapping != null) {
+            List<TypeSpec> fields = inputRowFactory.rowSchema().fields();
+            Builder builder = RowSchema.builder();
+            for (int i : mapping) {
+                TypeSpec typeSpec = fields.get(i);
+                builder.addField(typeSpec);
+            }
+            schema = builder.build();
+        } else {
+            schema = inputRowFactory.rowSchema();
+        }
+        return schema;
+    }

Review Comment:
   I'm not aware of another place. Could you please show it to me?



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863059425


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   Update. There is no need for SqlRowHandler.schema(row) method, just pass source schema in constructor 
   ```
           RelDataType rowType = rel.getInput().getRowType();
           RowSchema rowSchema = rowSchemaFromRelTypes(RelOptUtil.getFieldTypeList(rowType));
   ```



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1869845895


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/RowHandler.java:
##########
@@ -114,6 +99,21 @@ interface RowFactory<RowT> {
          * @return RowSchema.
          */
         RowSchema rowSchema();
+
+        /**
+         * Creates a new row from provided source row and containing only the fields specified in the provided mapping.
+         *

Review Comment:
   thanks. 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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863052254


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   It's better to build schema single time for all rows.
   My suggestion (may be @lowka or you have better ideas)
   Add SqlRowHandler.schema(row) method
   Add additional parameter to map method and pass target schema.
   
   In splitMerge, for example, get schema of the first row and build target schema.
   And do the same in flushTuples for the UPDATE operation :thinking: 
   
   p.s. may be it's also worth to mute this failure  https://ci.ignite.apache.org/viewLog.html?buildId=8657663&buildTypeId=ApacheIgnite3xGradle_Test_RunAllTests&fromSakuraUI=true
   in this PR



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863052254


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   It's better to build schema single time for a batch of rows.
   My suggestion (may be @lowka or you have better ideas)
   Add SqlRowHandler.schema(row) method
   Add additional parameter to map method and pass target schema.
   
   In ModifyNode.splitMerge, for example, get schema of the first row and build target schema.
   And do the same in flushTuples for the UPDATE operation :thinking: 
   
   p.s. may be it's also worth to mute this failure  https://ci.ignite.apache.org/viewLog.html?buildId=8657663&buildTypeId=ApacheIgnite3xGradle_Test_RunAllTests&fromSakuraUI=true
   in this PR



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863052254


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   It's better to build schema single time for a batch of rows.
   My suggestion (may be @lowka or you have better ideas)
   ~~Add SqlRowHandler.schema(row) method~~
   Add additional parameter to map method and pass target schema.
   
   In ModifyNode.splitMerge, for example, get schema of the first row and build target schema.
   And do the same in flushTuples for the UPDATE operation :thinking: 
   
   p.s. may be it's also worth to mute this failure  https://ci.ignite.apache.org/viewLog.html?buildId=8657663&buildTypeId=ApacheIgnite3xGradle_Test_RunAllTests&fromSakuraUI=true
   in this PR



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1873064198


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -465,9 +479,25 @@ private boolean hasUpsertSemantic(int rowSize) {
 
             assert !columnDescriptor.virtual() : "Virtual column can't be updated";
 
-            mapping[columnDescriptor.logicalIndex()] = columnCount + i;
+            mapping[columnDescriptor.logicalIndex()] = columnCount + i + mergeOffset;
         }
 
         return mapping;
     }
+
+    private RowSchema getMappedRowSchema(RowFactory<RowT> inputRowFactory, int[] mapping) {
+        RowSchema schema;
+        if (mapping != null) {
+            List<TypeSpec> fields = inputRowFactory.rowSchema().fields();
+            Builder builder = RowSchema.builder();
+            for (int i : mapping) {
+                TypeSpec typeSpec = fields.get(i);
+                builder.addField(typeSpec);
+            }
+            schema = builder.build();
+        } else {
+            schema = inputRowFactory.rowSchema();
+        }
+        return schema;
+    }

Review Comment:
   It is not the only class where this method is useful.
   Can it be a static method in RowSchema for example?



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1867994378


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -133,7 +132,8 @@ public ModifyNode(
                         .mapToInt(ColumnDescriptor::logicalIndex)
                         .toArray();
 
-        this.rowFactory = rowFactory;
+        RowSchema rowSchema = rowSchemaForTableDescriptor(table.descriptor());

Review Comment:
   I checked GG9 with spilling enabled in ItDmlTest and looks like that's not correct schema :thinking: 
   At least for Merge.



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1863668049


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/SqlRowHandler.java:
##########
@@ -107,12 +107,16 @@ public RowWrapper concat(RowWrapper left, RowWrapper right) {
     @Override
     public RowWrapper map(RowWrapper row, int[] mapping) {
         Object[] fields = new Object[mapping.length];
+        Builder schemaBuilder = RowSchema.builder();
+        List<TypeSpec> originalFields = row.rowSchema().fields();
 
         for (int i = 0; i < mapping.length; i++) {
-            fields[i] = row.get(mapping[i]);
+            int mappedIdx = mapping[i];
+            fields[i] = row.get(mappedIdx);
+            schemaBuilder.addField(originalFields.get(mappedIdx));
         }
 
-        return new ObjectsArrayRowWrapper(row.rowSchema(), fields);
+        return new ObjectsArrayRowWrapper(schemaBuilder.build(), fields);

Review Comment:
   Why do we have this method here, but not in RowFactory, 
   where we could validate given row schema and desired new row schema?
   
   This change will also help to avoid schema creation on every map() method call.
   WDYT?



-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#issuecomment-2522874964

   Should we do the same with `RowHandler.concat()` method?


-- 
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-23727 Sql. Fix SqlRowHandler to return right schema after mapping [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #4807:
URL: https://github.com/apache/ignite-3/pull/4807#discussion_r1873329993


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/rel/ModifyNode.java:
##########
@@ -465,9 +479,25 @@ private boolean hasUpsertSemantic(int rowSize) {
 
             assert !columnDescriptor.virtual() : "Virtual column can't be updated";
 
-            mapping[columnDescriptor.logicalIndex()] = columnCount + i;
+            mapping[columnDescriptor.logicalIndex()] = columnCount + i + mergeOffset;
         }
 
         return mapping;
     }
+
+    private RowSchema getMappedRowSchema(RowFactory<RowT> inputRowFactory, int[] mapping) {
+        RowSchema schema;
+        if (mapping != null) {
+            List<TypeSpec> fields = inputRowFactory.rowSchema().fields();
+            Builder builder = RowSchema.builder();
+            for (int i : mapping) {
+                TypeSpec typeSpec = fields.get(i);
+                builder.addField(typeSpec);
+            }
+            schema = builder.build();
+        } else {
+            schema = inputRowFactory.rowSchema();
+        }
+        return schema;
+    }

Review Comment:
   I meant this
   ```
   class RowSchema {
       static RowSchema map(RowSchema schema, int[] mapping) {
           List<TypeSpec> fields = schema.fields();
           Builder builder = builder();
   
           for (int i : mapping) {
               TypeSpec typeSpec = fields.get(i);
               builder.addField(typeSpec);
           }
   
           return builder.build();
       }
   }
   ```



-- 
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