-
Notifications
You must be signed in to change notification settings - Fork 505
ORC-2038: Improve error message in TypeDescription.withPrecision() #2462
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
Conversation
The previous error message "precision X is out of range 1 .. Y" was misleading when scale > precision. It incorrectly suggested that Y (scale) was the upper bound for precision, when the actual issue was that scale must be less than or equal to precision. Changed the error message to clearly state: "the scale X must be less than or equal to precision Y" to accurately describe the constraint violation and improve developer experience.
1637047 to
c677f6a
Compare
ffacs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves error messages in the TypeDescription.withPrecision() method to make validation failures clearer. The previous error message incorrectly suggested that the scale value was the upper bound for precision when scale > precision. The new implementation separates the validation logic into distinct checks with more descriptive error messages.
- Split the compound validation condition into two separate checks for better clarity
- Improved error message for precision range validation to explicitly state the valid range (1 to MAX_PRECISION)
- Improved error message for scale vs precision validation to clearly indicate that scale must be less than or equal to precision
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The jira issue is not created, let me remove this patch first. |
What changes were proposed in this pull request?
This PR improves the error message in the
TypeDescription.withPrecision(int precision)method. The previous error message incorrectly statedprecision {value} is out of range 1 .. {scale}when the scale was greater than precision, which was misleading because it suggested the scale value was the upper bound for precision.The new error message clearly states:
the scale {scale} must be less than or equal to precision {precision}, which accurately describes the actual constraint violation.Why are the changes needed?
The previous error message was confusing and misleading. When users encountered a case where scale > precision (e.g., precision=5, scale=10), the error message "precision 5 is out of range 1 .. 10" incorrectly suggested that precision must be between 1 and 10, when the real issue was that scale (10) cannot be greater than precision (5).
This improvement enhances the developer experience by providing a clear, accurate error message that directly points to the actual problem, making it easier to diagnose and fix the issue without needing to examine the source code.
How was this patch tested?
The existing test suite should validate this change. The modification only affects the error message text and does not change the validation logic itself. The same conditions that trigger the exception will continue to do so, but with a clearer message.
To verify the change manually:
Was this patch authored or co-authored using generative AI tooling?
No
Try to address the issue #2430