[ 
https://issues.apache.org/jira/browse/SPARK-38929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Xinyi Yu updated SPARK-38929:
-----------------------------
    Description: 
Improve several error messages for cast failures in ANSI.
h3. Cast to numeric types
{code:java}
java.lang.NumberFormatException: invalid input syntax for type numeric: 1.0. To 
return NULL instead, use 'try_cast'. ...{code}
This is confusing as 1.0 is numeric to an average user. Need to mention the 
specific target type (integer in this case) and put 1.0 in single quotes. If we 
can mention this is a cast from string to an integer that’s even better.
h4. Proposed change
{code:java}
Invalid `int` value: '1.0'. To return NULL instead, use 'try_cast'.{code}
h3. Cast to date types
{code:java}
java.time.DateTimeException: Cannot cast 2021-09- 2 to DateType.{code}
Can align with the above change.
h4. Proposed change
{code:java}
Invalid `date` value: '2021-09- 2'. To return NULL instead, use 
'try_cast'.{code}

  was:
Improve several error messages for cast failures in ANSI.
h3. Cast to numeric types
{code:java}
java.lang.NumberFormatException: invalid input syntax for type numeric: 1.0. To 
return NULL instead, use 'try_cast'. ...{code}
This is confusing as 1.0 is numeric to an average user. Need to mention the 
specific target type (integer in this case) and put 1.0 in single quotes. If we 
can mention this is a cast from string to an integer that’s even better.
h4. Proposed change

{{Invalid `int` value: '1.0'. To return NULL instead, use 'try_cast'.}}
h3. Cast to date types
{code:java}
java.time.DateTimeException: Cannot cast 2021-09- 2 to DateType.{code}
Can align with the above change.
h4. Proposed change
{code:java}
Invalid `date` value: '2021-09- 2'. To return NULL instead, use 
'try_cast'.{code}


> Improve error messages for cast failures in ANSI
> ------------------------------------------------
>
>                 Key: SPARK-38929
>                 URL: https://issues.apache.org/jira/browse/SPARK-38929
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: Xinyi Yu
>            Priority: Major
>
> Improve several error messages for cast failures in ANSI.
> h3. Cast to numeric types
> {code:java}
> java.lang.NumberFormatException: invalid input syntax for type numeric: 1.0. 
> To return NULL instead, use 'try_cast'. ...{code}
> This is confusing as 1.0 is numeric to an average user. Need to mention the 
> specific target type (integer in this case) and put 1.0 in single quotes. If 
> we can mention this is a cast from string to an integer that’s even better.
> h4. Proposed change
> {code:java}
> Invalid `int` value: '1.0'. To return NULL instead, use 'try_cast'.{code}
> h3. Cast to date types
> {code:java}
> java.time.DateTimeException: Cannot cast 2021-09- 2 to DateType.{code}
> Can align with the above change.
> h4. Proposed change
> {code:java}
> Invalid `date` value: '2021-09- 2'. To return NULL instead, use 
> 'try_cast'.{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to