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

[PR] IGNITE-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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

   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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java:
##########
@@ -707,6 +709,58 @@ public void testInsertValueOverflow(String type, long max, long min) {
         }
     }
 
+    @ParameterizedTest
+    @CsvSource({
+            "'id1,id2', id1",
+            "'id1,id2', id2",
+            "'id1,id2', 'id1,id2'",
+            "'id1,id2', 'id2,id1'",
+            "'id2,id1', id1",
+            "'id2,id1', id2",
+            "'id2,id1', 'id1,id2'",
+            "'id2,id1', 'id2,id1'",
+    })
+    void test(String pkDefinition, String colocateByDefinition) {

Review Comment:
   added 2 more test cases to verify multistep execution



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java:
##########
@@ -707,6 +709,58 @@ public void testInsertValueOverflow(String type, long max, long min) {
         }
     }
 
+    @ParameterizedTest
+    @CsvSource({

Review Comment:
   CsvSource allows specify to a delimiter character (e.g. ';'):
   So this
   > "'id1,id2', 'id1,id2'",
   
   Becomes this:
   
   > "id1,id2; id1,id2",



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java:
##########
@@ -707,6 +709,58 @@ public void testInsertValueOverflow(String type, long max, long min) {
         }
     }
 
+    @ParameterizedTest
+    @CsvSource({

Review Comment:
   fixed, thanks



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTableImpl.java:
##########
@@ -43,16 +51,62 @@ public class IgniteTableImpl extends AbstractIgniteDataSource implements IgniteT
     private final Lazy<NativeType[]> colocationColumnTypes;
 
     /** Constructor. */
-    public IgniteTableImpl(String name, int id, int version, TableDescriptor desc,
-            Statistic statistic, Map<String, IgniteIndex> indexMap, int partitions) {
-
+    public IgniteTableImpl(
+            String name,
+            int id,
+            int version,
+            TableDescriptor desc,
+            ImmutableIntList keyColumns,
+            Statistic statistic,
+            Map<String, IgniteIndex> indexMap,
+            int partitions
+    ) {
         super(name, id, version, desc, statistic);
+
+        this.keyColumns = keyColumns;
         this.indexMap = indexMap;
         this.partitions = partitions;
+        this.columnsToInsert = deriveColumnsToInsert(desc);
 
         colocationColumnTypes = new Lazy<>(this::evaluateTypes);
     }
 
+    private static RelDataType deriveDeleteRowType(
+            IgniteTypeFactory typeFactory,
+            TableDescriptor desc,
+            ImmutableIntList keyColumns
+    ) {
+        var builder = new RelDataTypeFactory.Builder(typeFactory);
+
+        RelDataType fullRow = desc.rowType(typeFactory, null);
+        for (int i : keyColumns) {
+            builder.add(fullRow.getFieldList().get(i));
+        }
+
+        return builder.build();
+    }
+
+    private static @Nullable ImmutableBitSet deriveColumnsToInsert(TableDescriptor desc) {
+        ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
+
+        boolean hiddenColumnFound = false;
+        for (ColumnDescriptor columnDescriptor : desc) {
+            if (columnDescriptor.hidden()) {

Review Comment:
   added comment in the beginning of the method explaining why do we need to omit hidden columns in INSERT



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTable.java:
##########
@@ -19,11 +19,41 @@
 
 import java.util.Map;
 import java.util.function.Supplier;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory;
 
 /**
  * Table representation as object in SQL schema.
  */
 public interface IgniteTable extends IgniteDataSource {
+    /**
+     * Checks whether it is possible to update a column with a given index.
+     *
+     * @param colIdx Column index.
+     * @return {@code True} if update operation is allowed for a column with a given index.
+     */
+    boolean isUpdateAllowed(int colIdx);
+
+    /**
+     * Returns row type excluding effectively virtual or hidden fields.
+     *
+     * @param factory Type factory.
+     * @return Row type for INSERT operation.
+     */
+    RelDataType insertRowType(IgniteTypeFactory factory);

Review Comment:
   these names looks as action for insert something into table. Maybe will be better to rename it, just for example `insertionRowType `



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTableImpl.java:
##########
@@ -43,16 +51,62 @@ public class IgniteTableImpl extends AbstractIgniteDataSource implements IgniteT
     private final Lazy<NativeType[]> colocationColumnTypes;
 
     /** Constructor. */
-    public IgniteTableImpl(String name, int id, int version, TableDescriptor desc,
-            Statistic statistic, Map<String, IgniteIndex> indexMap, int partitions) {
-
+    public IgniteTableImpl(
+            String name,
+            int id,
+            int version,
+            TableDescriptor desc,
+            ImmutableIntList keyColumns,
+            Statistic statistic,
+            Map<String, IgniteIndex> indexMap,
+            int partitions
+    ) {
         super(name, id, version, desc, statistic);
+
+        this.keyColumns = keyColumns;
         this.indexMap = indexMap;
         this.partitions = partitions;
+        this.columnsToInsert = deriveColumnsToInsert(desc);
 
         colocationColumnTypes = new Lazy<>(this::evaluateTypes);
     }
 
+    private static RelDataType deriveDeleteRowType(
+            IgniteTypeFactory typeFactory,
+            TableDescriptor desc,
+            ImmutableIntList keyColumns
+    ) {
+        var builder = new RelDataTypeFactory.Builder(typeFactory);
+
+        RelDataType fullRow = desc.rowType(typeFactory, null);
+        for (int i : keyColumns) {
+            builder.add(fullRow.getFieldList().get(i));
+        }
+
+        return builder.build();
+    }
+
+    private static @Nullable ImmutableBitSet deriveColumnsToInsert(TableDescriptor desc) {
+        ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
+
+        boolean hiddenColumnFound = false;
+        for (ColumnDescriptor columnDescriptor : desc) {
+            if (columnDescriptor.hidden()) {

Review Comment:
   Maybe It would be better to leave a comment explaining why this is needed?



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTable.java:
##########
@@ -19,11 +19,41 @@
 
 import java.util.Map;
 import java.util.function.Supplier;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory;
 
 /**
  * Table representation as object in SQL schema.
  */
 public interface IgniteTable extends IgniteDataSource {
+    /**
+     * Checks whether it is possible to update a column with a given index.
+     *
+     * @param colIdx Column index.
+     * @return {@code True} if update operation is allowed for a column with a given index.
+     */
+    boolean isUpdateAllowed(int colIdx);
+
+    /**
+     * Returns row type excluding effectively virtual or hidden fields.
+     *
+     * @param factory Type factory.
+     * @return Row type for INSERT operation.
+     */
+    RelDataType insertRowType(IgniteTypeFactory factory);

Review Comment:
   renamed to `rowTypeForInsert`



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteTable.java:
##########
@@ -19,11 +19,41 @@
 
 import java.util.Map;
 import java.util.function.Supplier;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.ignite.internal.sql.engine.type.IgniteTypeFactory;
 
 /**
  * Table representation as object in SQL schema.
  */
 public interface IgniteTable extends IgniteDataSource {
+    /**
+     * Checks whether it is possible to update a column with a given index.
+     *
+     * @param colIdx Column index.
+     * @return {@code True} if update operation is allowed for a column with a given index.
+     */
+    boolean isUpdateAllowed(int colIdx);
+
+    /**
+     * Returns row type excluding effectively virtual or hidden fields.
+     *
+     * @param factory Type factory.
+     * @return Row type for INSERT operation.
+     */
+    RelDataType insertRowType(IgniteTypeFactory factory);

Review Comment:
   or `insertOperationRowType`



-- 
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-21533 Sql. Use actual order of key columns to built key only row [ignite-3]

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


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItDmlTest.java:
##########
@@ -707,6 +709,58 @@ public void testInsertValueOverflow(String type, long max, long min) {
         }
     }
 
+    @ParameterizedTest
+    @CsvSource({
+            "'id1,id2', id1",
+            "'id1,id2', id2",
+            "'id1,id2', 'id1,id2'",
+            "'id1,id2', 'id2,id1'",
+            "'id2,id1', id1",
+            "'id2,id1', id2",
+            "'id2,id1', 'id1,id2'",
+            "'id2,id1', 'id2,id1'",
+    })
+    void test(String pkDefinition, String colocateByDefinition) {

Review Comment:
   should we check the same for disabled rule for KV optimization?



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