heavydb
heavydb copied to clipboard
INT datatype doesn't have outside boundaries
ISSUE
MapD's INT datatype doesn't have outside boundaries. To reproduce the issues, run the follow sql statements on the MapDQL cursor:
CREATE TABLE t_int(id SMALLINT, val INT);
INSERT INTO t_int VALUES(1, NULL);
INSERT INTO t_int VALUES(2, 2147483646);
INSERT INTO t_int VALUES(3, 2147483647);
INSERT INTO t_int VALUES(4, 2147483648);
INSERT INTO t_int VALUES(5, -2147483647);
INSERT INTO t_int VALUES(6, -2147483648);
INSERT INTO t_int VALUES(7, -2147483649);
SELECT * FROM t_int ORDER BY id;
Results from the SELECT statement
mapdql> SELECT * FROM t_int ORDER BY id;
# id|val
# 1|NULL
# 2|2147483646
# 3|2147483647
# 4|NULL
# 5|-2147483647
# 6|NULL
# 7|2147483647
Comparisons of Expected and Actual Results
Row 1 (id: 1 | val: null)
- Expected Results: null = Actual Results: null? -> PASS
Row 2 (id: 2 | val: 2147483646)
- Expected Results: 2147483646 == Actual Results: 2147483646? -> PASS
Row 3 (id: 3 | val: 2147483647)
- Expected Results: 2147483647 == Actual Results: 2147483647? -> PASS
Row 4 (id: 4 | val: 2147483648)
- Expected Results: <Error Msg> == Actual Results: null?-> FAIL
Row 5 (id: 5 | val: -2147483647))
- Expected Results: -2147483647) == Actual Results: -2147483647)? -> PASS
Row 6 (id: 6 | val: -2147483648)
- Expected Results: -2147483648 == Actual Results: null? -> FAIL
Row 7 (id: 7 | val: -2147483649)
- Expected Results: <Error Msg> == Actual Results: 2147483647 -> FAIL
Result Explanation
The results show 3 passes out of 7 test cases. According to the C++ datatype, the INT datatype has 8 bytes in the -2147483648 to 2147483647. 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:
- Throw an error exception
- 0 or null
Let me know your thoughts.
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.