heavydb icon indicating copy to clipboard operation
heavydb copied to clipboard

BIGINT datatype doesn't have outside boundaries

Open njmarshall opened this issue 9 years ago • 1 comments

ISSUE

MapD's BIGINT datatype doesn't have outside boundaries. To reproduce the issues, run the follow sql statements on the MapDQL cursor:

CREATE TABLE t_bigint(id SMALLINT, val BIGINT);
INSERT INTO t_bigint VALUES(1, NULL);
INSERT INTO t_bigint VALUES(2, 9223372036854775806);
INSERT INTO t_bigint VALUES(3, 9223372036854775807);
INSERT INTO t_bigint VALUES(4, 9223372036854775808);
INSERT INTO t_bigint VALUES(5, -9223372036854775807);
INSERT INTO t_bigint VALUES(6, -9223372036854775808);
INSERT INTO t_bigint VALUES(7, -9223372036854775809);
SELECT * FROM t_bigint ORDER BY id;

Results from the SELECT statement

mapdql> SELECT * FROM t_bigint ORDER BY id;
id|val
1|NULL
2|9223372036854775806
3|9223372036854775807
4|9223372036854775807
5|-9223372036854775807
6|NULL
7|NULL

Comparisons of Expected and Actual Results

Row 1 (id: 1 | val: null)
- Expected Results: null  = Actual Results: null? -> PASS

Row 2 (id: 2 | val: 9223372036854775806)
- Expected Results: 9223372036854775806  == Actual Results: 9223372036854775806? -> PASS

Row 3 (id: 3 | val: 9223372036854775807)
- Expected Results: 9223372036854775807  == Actual Results: 9223372036854775807? -> PASS

Row 4 (id: 4 | val: 9223372036854775808)
- Expected Results: <Error Msg>  == Actual Results: 9223372036854775807?-> FAIL

Row 5 (id: 5 | val: -9223372036854775807)
- Expected Results: -9223372036854775807  == Actual Results: -9223372036854775807? -> PASS

Row 6 (id: 6 | val: -9223372036854775808)
- Expected Results: -9223372036854775808  == Actual Results: null? -> FAIL

Row 7 (id: 7 | val: -9223372036854775809)
- Expected Results: <Error Msg>  == Actual Results: null -> FAIL

Result Explanation

The results show 3 passes out of 7 test cases. According to the C++ datatype, the BIGINT datatype has 8 bytes in the -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The way MapD's detection handling to outside boundaries is incorrect and doesn't throw error exceptions.

Suggestions

What values should MapD give for outside boundaries? Here are two suggestions:

  1. Throw an error exception
  2. 0 or null

Let me know your thoughts.

njmarshall avatar Jun 29 '17 19:06 njmarshall

This issue has been inactive for a while, and the project has changed substantially. If this still occurs on the latest release, please add reproduction steps and environment details.

psilvest avatar Sep 16 '26 18:09 psilvest