You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xuzifu666 (via GitHub)" <gi...@apache.org> on 2026/10/18 15:10:02 UTC

[PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

xuzifu666 opened a new pull request, #5342:
URL: https://github.com/apache/calcite/pull/5342

   jira:https://issues.apache.org/jira/browse/CALCITE-4531
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5342:
URL: https://github.com/apache/calcite/pull/5342#issuecomment-6265808504

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5342) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5342&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5342&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5342&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [25.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5342&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5342&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5342)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #5342:
URL: https://github.com/apache/calcite/pull/5342#issuecomment-6265596162

   Thanks for the review! @mihaibudiu @julianhyde . I’ve re-examined the discussion on the Jira ticket, and it doesn’t seem necessary to pursue it any further; perhaps we can close this Jira ticket.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #5342:
URL: https://github.com/apache/calcite/pull/5342#discussion_r4308219739


##########
druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java:
##########
@@ -712,7 +713,8 @@ protected QuerySpec deriveQuerySpec() {
           numericCollationBitSetBuilder.set(fCol.getFieldIndex());
         }
       }
-      fetch = sort.fetch != null ? RexLiteral.intValue(sort.fetch) : null;
+      fetch = sort.fetch != null

Review Comment:
   this may be a breaking change: the previous code allowed fractional values.
   Maybe you just need to round, check what SQL expects.



##########
cassandra/src/main/java/org/apache/calcite/adapter/cassandra/CassandraLimit.java:
##########
@@ -59,10 +59,10 @@ public CassandraLimit(RelOptCluster cluster, RelTraitSet traitSet,
   @Override public void implement(Implementor implementor) {
     implementor.visitChild(0, getInput());
     if (offset != null) {
-      implementor.offset = RexLiteral.intValue(offset);
+      implementor.offset = RexLiteral.bigDecimalValue(offset).intValueExact();

Review Comment:
   this will throw if the value is not an integer.
   Did you check what Cassandra expects?



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on PR #5342:
URL: https://github.com/apache/calcite/pull/5342#issuecomment-6379133547

   Close this pr first.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on code in PR #5342:
URL: https://github.com/apache/calcite/pull/5342#discussion_r4307540620


##########
core/src/test/java/org/apache/calcite/test/JdbcTest.java:
##########
@@ -3920,6 +3920,42 @@ public void checkOrderBy(final boolean desc,
             + "empid=200; deptno=20; name=Eric; salary=8000.0; commission=500\n");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-4531">[CALCITE-4531]
+   * Deprecate RexLiteral#intValue since it performs silent truncation</a>.
+   *
+   * <p>LIMIT greater than the maximum int value used to be silently
+   * truncated, so "limit 2^40" became "limit 0" and the query silently
+   * returned no rows. */
+  @Test void testLimitExceedsMaxInt() {

Review Comment:
   The two tests mentioned in the Jira discussion are also included here.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on PR #5342:
URL: https://github.com/apache/calcite/pull/5342#issuecomment-6254196563

   If you read the jira case you will see that there is no consensus that this is a bug, or even that it's something we want to fix.
   
   `intValue` does what it does. The behavior is not fully documented, but is not surprising. (`longValue`, added recently, does something similar.)
   
   If we do anything, it should be to identify the user-visible bugs arising from misuses of this method, if there are any (e.g. does {{LIMIT 0.5}} do what the SQL standard says it should?)
   
   -0 to merge this.


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation [calcite]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 closed pull request #5342: [CALCITE-4531] Deprecate RexLiteral#intValue since it performs silent truncation
URL: https://github.com/apache/calcite/pull/5342


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org