-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Improve error messages for cast errors #23729
base: master
Are you sure you want to change the base?
Improve error messages for cast errors #23729
Conversation
Can you add some examples of the before and after? |
Previous stack trace -
|
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.
I think the change on PageProcessor may not be the right way to do it. Also, Instead of just giving the columns that MIGHT cause the cast error, we should be able to get which column and type caused this error. But I can't give the suggestion how to do it now. @tdcmeehan Do you have any better idea?
@@ -68,7 +68,7 @@ private Slice castToIpAddress(Slice slice) | |||
address = InetAddresses.forString(slice.toStringUtf8()).getAddress(); | |||
} | |||
catch (IllegalArgumentException e) { | |||
throw new PrestoException(INVALID_CAST_ARGUMENT, "Cannot cast value to IPADDRESS: " + slice.toStringUtf8()); |
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.
A Slice may not necessarily represent a string. Just use value is fine
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.
WHy remove the space?
6a41147
to
21e3dde
Compare
Description
if some query runs into cannot cast errors, the error message does not include any useful information around column names, problematic projection or the row number in the query from where the error is being thrown. This PR attempts to include column name as well in the error message so that users know which column value is causing issues.
Motivation and Context
While this PR attempts to add column names in the error message, there is a limitation. In cases where multiple columns in the table have the same data type, and multiple ones from them are getting cast to the same data type, then we print all these columns as the probable problematic columns. For example, table tbl has below columns - col1 integer, col2 real, col3 varchar, col4 real, col5 double. col2 has a NaN value in one of the rows. Please see the below queries and their possible errors -
Impact
Error messages get more user friendly in case of cannot cast errors
Test Plan
Manual testing
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.