Details
-
Bug
-
Status: Open
-
Trivial
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
With decimal types, precision is the total number of digits in the decimal representation, and scale is the number of digits to the right of the decimal place. Currently, TypeDescription.withPrecision() checks the the precision argument and throws IllegalArgumentException if it's out of bounds. However, the error message is confusing and probably incorrect.
The following snippet:
TypeDescription invalidDecimal = TypeDescription.createDecimal().withScale(10).withPrecision(5);
results in this exception:
java.lang.IllegalArgumentException: precision 5 is out of range 1 .. 10 at org.apache.orc.TypeDescription.withPrecision(TypeDescription.java:427) ~[orc-core-1.5.3.jar:1.5.3] ...
The error message is confusing and probably incorrect. The value 5 is within the range of 1 .. 10
Instead it should probably read something like:
java.lang.IllegalArgumentException: precision 5 was less than scale 10 org.apache.orc.TypeDescription.withPrecision(TypeDescription.java:427) ~[orc-core-1.5.3.jar:1.5.3] ...