DECIMAL datatype with a min precision doesn't have outside MIN boundaries
ISSUE
MapD's DECIMAL datatype with the min precision doesn't have some outside boundaries. To reproduce the issues, run the follow sql statements on the MapDQL cursor:
CREATE TABLE t_decimal(id SMALLINT, val DECIMAL(2,1));
INSERT INTO t_decimal VALUES(1, NULL);
INSERT INTO t_decimal VALUES(2, 1);
INSERT INTO t_decimal VALUES(3, 1.1);
INSERT INTO t_decimal VALUES(4, 1.15);
INSERT INTO t_decimal VALUES(5, 15.1);
INSERT INTO t_decimal VALUES(6, 15.15);
INSERT INTO t_decimal VALUES(7, 123456789012345678);
INSERT INTO t_decimal VALUES(8, 1234567890123456789);
INSERT INTO t_decimal VALUES(9, 12345678901234567890);
INSERT INTO t_decimal VALUES(10, 123456789012345678.1);
INSERT INTO t_decimal VALUES(11, 123456789012345678.12);
SELECT * FROM t_decimal ORDER BY id;
Results from the SELECT statement
mapdql> SELECT * FROM t_decimal ORDER BY id;
id|val
1|NULL
2|1.000000
3|1.100000
4|1.100000
5|15.100000
6|15.100000
7|123456789012345680.000000
8|-610106517247498368.000000
9|-1.000000
10|123456789012345680.000000
11|123456789012345680.000000
Comparisons of Expected and Actual Results
Row 1 (id: 1 | val: null)
- Expected Results: null = Actual Results: null? -> PASS
Row 2 (id: 2 | val: 1)
- Expected Results: 1.0 == Actual Results: 1.000000? -> FAIL
Row 3 (id: 3 | val: 1.1)
- Expected Results: 1.1 == Actual Results: 1.100000? -> FAIL
Row 4 (id: 4 | val: 1.15)
- Expected Results: 1.15 == Actual Results: 1.000000?-> FAIL
Row 5 (id: 5 | val: 15.1)
- Expected Results: 15.1 == Actual Results: 15.100000? -> FAIL
Row 6 (id: 6 | val: 15.15)
- Expected Results: 15.1 == Actual Results: 15.100000? -> FAIL
Row 7 (id: 7 | val: 123456789012345678)
- Expected Results: 123456789012345678.0 == Actual Results: 123456789012345680.000000 -> FAIL
Row 7 (id: 8 | val: 1234567890123456789)
- Expected Results: null == Actual Results: -610106517247498368.000000 -> FAIL
Row 7 (id: 9 | val: 12345678901234567890)
- Expected Results: null == Actual Results: -1.000000 -> FAIL
Row 7 (id: 10 | val: 123456789012345678.1)
- Expected Results: 123456789012345678.0 == Actual Results: 123456789012345680.000000 -> FAIL
Row 7 (id: 11 | val: 123456789012345678.12)
- Expected Results: 123456789012345678.0 == Actual Results: 123456789012345680.000000 -> FAIL
Result Explanation
The results show 1 pass out of 11 test cases. In definition, precision is the number of digits in a number. Scale is the number of digits to the right of the decimal point in a number. For example, the number 123.45 has a precision of 5 and a scale of 2. The NUMERIC datatype has 8 bytes allowing up to the 19-digit precision. The way MapD's detection handling to outside boundaries is ineffective.
Suggestions
-
How many scale digit should DECIMAL(2,1) show a value? MapD always gives 6 scale digit including zeros. Should MapD enforce the value output based on scale?
-
What values should MapD give for outside boundaries?
- For example, what should the value of 15.2 in the DECIMAL(2,1) column be? 15.2 or 15?
- What should the value containing over 19 precision be?
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.