mihailom-db opened a new pull request, #48054:
URL: https://github.com/apache/spark/pull/48054

   ### What changes were proposed in this pull request?
   Removal of suggestion to turn off ansi when experiencing CAST_INVALID_INPUT 
or CAST_OVERFLOW.
   
   
   ### Why are the changes needed?
   These errors already contain sufficient suggestions, amongst which one is to 
use `try_cast` in place of `cast`. This removal of ANSI turn off suggestion is 
part of a movement keep suggestions of not using ANSI in code to minimum.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. This PR is changing user-facing error message.
   Previous state:
   `
   SELECT CAST('a' AS INT)
   org.apache.spark.SparkNumberFormatException: [CAST_INVALID_INPUT] The value 
'a' of the type "STRING" cannot be cast to "INT" because it is malformed. 
Correct the value as per the syntax, or change its target type. Use `try_cast` 
to tolerate malformed input and return NULL instead. If necessary set 
"spark.sql.ansi.enabled" to "false" to bypass this error.
   SELECT CAST(2147483648L AS INT);
   org.apache.spark.SparkArithmeticException: [CAST_OVERFLOW] The value 
2147483648L of the type "BIGINT" cannot be cast to "INT" due to an overflow. 
Use `try_cast` to tolerate overflow and return NULL instead. If necessary set 
"spark.sql.ansi.enabled" to "false" to bypass this error.
   `
   
   Current state:
   `
   SELECT CAST('a' AS INT)
   org.apache.spark.SparkNumberFormatException: [CAST_INVALID_INPUT] The value 
'a' of the type "STRING" cannot be cast to "INT" because it is malformed. 
Correct the value as per the syntax, or change its target type. Use `try_cast` 
to tolerate malformed input and return NULL instead.
   SELECT CAST(2147483648L AS INT);
   org.apache.spark.SparkArithmeticException: [CAST_OVERFLOW] The value 
2147483648L of the type "BIGINT" cannot be cast to "INT" due to an overflow. 
Use `try_cast` to tolerate overflow and return NULL instead.
   `
   
   ### How was this patch tested?
   Existing tests check for existence of ansiConfig message parameter.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to