-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ESQL] Fix parsing of large magnitude negative numbers (#110665)
Resolves #104323 This fixes and adds tests for the first of the two bullets in the linked issue. `ExpressionBuilder#visitIntegerValue` will attempt to parse a string as an integral value, and return a Literal of the appropriate type. The actual parsing happens in `StringUtils#parseIntegral`. That function has special handling for values that are larger than `Long.MAX_VALUE` where it attempts to turn them into unsigned longs, and if the number is still out of range, throw `InvalidArgumentException`. `ExpressionBuilder` catches that `InvalidArgumentException` and tries to parse a `double` instead. If, on the other hand, the value is smaller than `Long.MIN_VALUE`, `StringUtils` never enters the unsigned long path and just calls `intValueExact`, which throws `ArithmeticException`. This PR solves the issue by catching that `ArithmeticException` and rethrowing it as an `InvalidArgumentException`.
- Loading branch information
1 parent
0f6c01a
commit 745a3cc
Showing
5 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 110665 | ||
summary: "[ESQL] Fix parsing of large magnitude negative numbers" | ||
area: ES|QL | ||
type: bug | ||
issues: | ||
- 104323 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
x-pack/plugin/esql/qa/testFixtures/src/main/resources/floats.csv-spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters