opensearch-project / opensearch-project/sql

[BUG] Mathematical functions have possibility of overflowing

Open
#1,422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug error-experience SQL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

What is the bug?
There are many Mathematical/Arithmetic functions that have the possibility of overflowing if certain specific values are used

How can one reproduce the bug?
Steps to reproduce the behavior:
These are all the functions and an example input that would cause an integer overflow error:
SELECT 2147483647 + 2147483647;
SELECT -2147483648 - 2147483647;
SELECT 2147483647 * 2;

Here is an example of what the error looks like:
TransportError(503, 'ArithmeticException', {'error': {'reason': 'There was internal problem at backend', 'details': 'integer overflow', 'type': 'ArithmeticException'}, 'status': 503})

What is the expected behavior?
Possibly the functions could return a larger data type if they would overflow, e.g. SELECT 2147483647 + 2147483647; returns 4294967294 as a LONG

What is your host/environment?

  • OS: macOS
  • Version 13.2.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three SQL expressions in the issue and confirm the current integer-overflow response. Trace the arithmetic and mathematical-function handling to identify the affected operations, then define and test the expected wider-type behavior, including the LONG result shown for addition.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.