This is an automated email from the ASF dual-hosted git repository.
zhenchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new c327ccba1e [CALCITE-7156] OFFSET and FETCH in EnumerableLimit need to
support BIGINT
c327ccba1e is described below
commit c327ccba1ed13c3a03ee8e4f199040c2cdec1bd3
Author: Zhen Chen <[email protected]>
AuthorDate: Tue Sep 9 17:18:30 2025 +0800
[CALCITE-7156] OFFSET and FETCH in EnumerableLimit need to support BIGINT
---
.../java/org/apache/calcite/adapter/enumerable/EnumerableLimit.java | 3 +++
core/src/main/java/org/apache/calcite/rex/RexLiteral.java | 5 +++++
core/src/test/resources/sql/sort.iq | 5 +++++
3 files changed, 13 insertions(+)
diff --git
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableLimit.java
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableLimit.java
index 5958e5d633..3c046de922 100644
---
a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableLimit.java
+++
b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableLimit.java
@@ -127,6 +127,9 @@ static Expression getExpression(RexNode rexNode) {
Expressions.constant("?" + param.getIndex())),
Integer.class);
} else {
+ // TODO: Enumerable runtime only supports INT types for FETCH and
OFFSET, not BIGINT types.
+ // Currently, using BIGINT types for execution will result in an error
message.
+ // This issue needs to be fixed. For more information, see CALCITE-7156.
return Expressions.constant(RexLiteral.intValue(rexNode));
}
}
diff --git a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
index a79e108006..ce7ac68abb 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexLiteral.java
@@ -1275,6 +1275,11 @@ public static Number numberValue(RexNode node) {
* never null. */
public static int intValue(RexNode node) {
final Number number = numberValue(node);
+ long longValue = number.longValue();
+ if (longValue > Integer.MAX_VALUE || longValue < Integer.MIN_VALUE) {
+ throw new ArithmeticException(
+ "Integer overflow: " + longValue + " is out of range for INT");
+ }
return number.intValue();
}
diff --git a/core/src/test/resources/sql/sort.iq
b/core/src/test/resources/sql/sort.iq
index 32f75d2e2b..ea6195273c 100644
--- a/core/src/test/resources/sql/sort.iq
+++ b/core/src/test/resources/sql/sort.iq
@@ -417,4 +417,9 @@ order by arr desc;
!ok
+# [CALCITE-7156] OFFSET and FETCH in EnumerableLimit need to support BIGINT
+select * from "hr"."emps" limit 3000000000 offset 2500000000;
+Caused by: java.lang.ArithmeticException: Integer overflow: 3000000000 is out
of range for INT
+!error
+
# End sort.iq