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 2025/07/21 06:19:25 UTC

[PR] IGNITE-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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

   https://issues.apache.org/jira/browse/IGNITE-25768
   
   This patch addresses the issue by tweaking the rules of CAST elimination during search bound creation: now only lossless casts which would not require another side to be downcasted are removed.
   
   Also, this patch reworks approach with saturated values: now conditions are analyzed, and if it's known that predicate won't be satisfied, the whole tree is substituted with empty Values node.
    
   ----
   
   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-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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


-- 
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-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/TpcdsQueryPlannerTest.java:
##########
@@ -92,7 +93,7 @@ static String getQueryPlan(String queryId) {
 
     @SuppressWarnings("unused") // used reflectively by AbstractTpcQueryPlannerTest
     static void updateQueryPlan(String queryId, String newPlan) {
-        Path targetDirectory = null;
+        Path targetDirectory = Paths.get("/Users/korlov/projects/work/ignite-3/modules/sql-engine/src/test/resources/tpcds/plan");

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-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/RexUtils.java:
##########
@@ -924,15 +914,24 @@ private static RexNode expandBooleanFieldComparison(RexNode rexNode, RexBuilder
         return null;
     }
 
-    private static @Nullable RexSlot extractRefFromOperand(RexCall call, RelOptCluster cluster, int operandNum) {
+    private static @Nullable RexSlot extractRefFromOperand(RexCall call, int operandNum) {
         assert isSupportedTreeComparison(call) : "Unsupported RexNode is tree comparison: " + call;
 
         RexNode op = call.getOperands().get(operandNum);
+        RelDataType operandType = op.getType();
 
-        op = removeCast(op);
+        while (isLosslessCast(op)) {
+            op = ((RexCall) op).getOperands().get(0);
+        }
+
+        // We cannot compose search condition if expression requires to be downcasted in order to be put
+        // in bound. Downcast is not safe, and may throw `Out of range` error. As of now, such case
+        // must be handler by user explicitly by manually CASTing to the required type.

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-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/TpcdsQueryPlannerTest.java:
##########
@@ -92,7 +93,7 @@ static String getQueryPlan(String queryId) {
 
     @SuppressWarnings("unused") // used reflectively by AbstractTpcQueryPlannerTest
     static void updateQueryPlan(String queryId, String newPlan) {
-        Path targetDirectory = null;
+        Path targetDirectory = Paths.get("/Users/korlov/projects/work/ignite-3/modules/sql-engine/src/test/resources/tpcds/plan");

Review Comment:
   ```suggestion
           Path targetDirectory = null;
   ```



-- 
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-25768 Sql. Invalid search boundaries are generated when accessing the index if the key is out of range [ignite-3]

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


##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/RexUtils.java:
##########
@@ -924,15 +914,24 @@ private static RexNode expandBooleanFieldComparison(RexNode rexNode, RexBuilder
         return null;
     }
 
-    private static @Nullable RexSlot extractRefFromOperand(RexCall call, RelOptCluster cluster, int operandNum) {
+    private static @Nullable RexSlot extractRefFromOperand(RexCall call, int operandNum) {
         assert isSupportedTreeComparison(call) : "Unsupported RexNode is tree comparison: " + call;
 
         RexNode op = call.getOperands().get(operandNum);
+        RelDataType operandType = op.getType();
 
-        op = removeCast(op);
+        while (isLosslessCast(op)) {
+            op = ((RexCall) op).getOperands().get(0);
+        }
+
+        // We cannot compose search condition if expression requires to be downcasted in order to be put
+        // in bound. Downcast is not safe, and may throw `Out of range` error. As of now, such case
+        // must be handler by user explicitly by manually CASTing to the required type.

Review Comment:
   ```suggestion
           // must be handled by user explicitly by manually CASTing to the required type.
   ```



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