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

Yuming Wang updated SPARK-34744:
--------------------------------
    Description: 
For example:
{code:sql}
set spark.sql.ansi.enabled=true;
select tinyint(128) * tinyint(2);
{code}

Error message:
{noformat}
Casting 128 to scala.Byte$ causes overflow
{noformat}

Expected:
{noformat}
Casting 128 to tinyint causes overflow
{noformat}

We should use DataType's catalogString.






  was:
For example:
{code:sql}
set spark.sql.ansi.enabled=true;
select tinyint(128) * tinyint(2);
{code}

Error message:
{noformat}
Casting 128 to scala.Byte$ causes overflow
{noformat}

Expected:
{noformat}
Casting 128 to tinyint causes overflow
{noformat}

We can update 
[castingCauseOverflowError|https://github.com/apache/spark/blob/5b2ad59f64a9bb065b49acb2e73a6b246a3d8c64/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala#L64-L66]
 to:
{code:scala}
  def castingCauseOverflowError(t: Any, targetType: DataType): 
ArithmeticException = {
    new ArithmeticException(s"Casting $t to ${targetType.catalogString} causes 
overflow")
  }
{code}







> Improve error message for casting cause overflow error
> ------------------------------------------------------
>
>                 Key: SPARK-34744
>                 URL: https://issues.apache.org/jira/browse/SPARK-34744
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.2.0
>            Reporter: Yuming Wang
>            Priority: Major
>
> For example:
> {code:sql}
> set spark.sql.ansi.enabled=true;
> select tinyint(128) * tinyint(2);
> {code}
> Error message:
> {noformat}
> Casting 128 to scala.Byte$ causes overflow
> {noformat}
> Expected:
> {noformat}
> Casting 128 to tinyint causes overflow
> {noformat}
> We should use DataType's catalogString.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to