diff --git a/java/core/src/java/org/apache/orc/TypeDescription.java b/java/core/src/java/org/apache/orc/TypeDescription.java index c5ef48b047..9e130e81d1 100644 --- a/java/core/src/java/org/apache/orc/TypeDescription.java +++ b/java/core/src/java/org/apache/orc/TypeDescription.java @@ -241,10 +241,14 @@ public static TypeDescription fromString(String typeName) { public TypeDescription withPrecision(int precision) { if (category != Category.DECIMAL) { throw new IllegalArgumentException("precision is only allowed on decimal"+ - " and not " + category.name); - } else if (precision < 1 || precision > MAX_PRECISION || scale > precision){ - throw new IllegalArgumentException("precision " + precision + - " is out of range 1 .. " + scale); + " and not " + category.name); + } else if (precision < 1 || precision > MAX_PRECISION) { + throw new IllegalArgumentException( + "precision " + precision + " must be between 1 and " + MAX_PRECISION + ); + } else if (scale > precision) { + throw new IllegalArgumentException("scale " + scale + + " must be less than or equal to precision " + precision); } this.precision = precision; return this;