wgzhao opened a new issue, #2430:
URL: https://github.com/apache/orc/issues/2430
Hi,
I encountered a confusing error message when using ORC decimal types in CDH
6.2. Here is the log:
```
2025-09-30 10:24:41.701 [ job-0] ERROR Engine -
com.wgzhao.addax.core.exception.AddaxException:
java.lang.IllegalArgumentException: precision 5 is out of range 1 .. 10
at
org.apache.orc.TypeDescription.withPrecision(TypeDescription.java:219)
at
com.wgzhao.addax.plugin.writer.hdfswriter.OrcWriter.buildOrcSchema(OrcWriter.java:344)
at
com.wgzhao.addax.plugin.writer.hdfswriter.OrcWriter.write(OrcWriter.java:294)
at
com.wgzhao.addax.plugin.writer.hdfswriter.HdfsWriter$Task.startWrite(HdfsWriter.java:473)
at
com.wgzhao.addax.core.taskgroup.runner.WriterRunner.run(WriterRunner.java:74)
at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.IllegalArgumentException: precision 5 is out of range 1
.. 10
at
org.apache.orc.TypeDescription.withPrecision(TypeDescription.java:219)
...
```
After checking the source code, I found that in
`TypeDescription.withPrecision(int precision)`, the exception message is
constructed as:
```java
throw new IllegalArgumentException("precision " + precision + " is out of
range 1 .. " + this.scale);
```
This is misleading, because `this.scale` is not the upper bound for
precision. In my case, precision=5 and scale=10 (default), so the error message
says "precision 5 is out of range 1 .. 10", which is not correct. The real
problem is that scale cannot be greater than precision.
**Expected behavior:**
The error message should clearly indicate the actual constraint, e.g.
- "precision must be between 1 and 38, and scale must be less than or equal
to precision"
- Or, if the check fails because scale > precision, the message should
reflect that.
**Suggestion:**
Update the exception message in `withPrecision` to avoid using `this.scale`
as the upper bound, and clarify the real constraint.
**Environment:**
- ORC 1.9.5
- Java 17
Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]