Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NUMERIC/DECIMAL datatype has flaw. #28

Open
njmarshall opened this issue Jun 13, 2017 · 3 comments
Open

NUMERIC/DECIMAL datatype has flaw. #28

njmarshall opened this issue Jun 13, 2017 · 3 comments

Comments

@njmarshall
Copy link
Contributor

njmarshall commented Jun 13, 2017

ISSUE

MapD's NUMERIC/DECIMAL datatype has flaws. To reproduce the issues, run the follow sql statements on the MapDQL cursor:

CREATE TABLE t_d(id SMALLINT, val DECIMAL(2,1));
INSERT INTO t_d VALUES(1, NULL);
INSERT INTO t_d VALUES(2, 1);
INSERT INTO t_d VALUES(3, 0.1);
INSERT INTO t_d VALUES(4, 1.1);
INSERT INTO t_d VALUES(5, 15.1);
INSERT INTO t_d VALUES(6, 1.15);
INSERT INTO t_d VALUES(7, 15.15);

Results from the SELECT statement

# id|val
# 1|NULL
# 2|1.000000
# 3|0.100000
# 4|1.100000
# 5|15.100000
# 6|1.100000
# 7|15.100000

Explanation

The NUMERIC/DECIMAL datatype has 4 bytes for the maximum of 19 digits. The datatype has a precision and scale. Precision is defined as the total number of digits in a numeric or decimal type, and scale as the number of digits to the right of the decimal point. In this case, the val column is defined as DECIMAL(2,1) -> 2 digits precision and 1 digit scale. But result rows (#2 - 7) has 6 digit scales (i.e. the expected results for Row #4 should be 1.1, not 1.100000. In addition, no decimal nearest is calculated. For example, the expected results for in row #6 should be 1.2 (1.15 -> 1.2) but get 1.1.

@njmarshall
Copy link
Contributor Author

@asuhan @andrewseidl @RalphLoen Please check this issue and let me know your consideration. Thanks

@njmarshall
Copy link
Contributor Author

@DennisDawson Can you please add detail of this datatype to www.mapd.com/docs?

@asuhan
Copy link
Contributor

asuhan commented Jun 14, 2017

These are two separate issues actually:

  1. The way we print the 4th row is a client-side formatting issue.
  2. The rounding is an import issue.

I don't think either is a high priority at this point, but we'll have to address them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants