[ 
https://issues.apache.org/jira/browse/SPARK-38481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17503538#comment-17503538
 ] 

Apache Spark commented on SPARK-38481:
--------------------------------------

User 'MaxGekk' has created a pull request for this issue:
https://github.com/apache/spark/pull/35787

> Substitute Java overflow exception from TIMESTAMPADD by Spark exception
> -----------------------------------------------------------------------
>
>                 Key: SPARK-38481
>                 URL: https://issues.apache.org/jira/browse/SPARK-38481
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 3.3.0
>            Reporter: Max Gekk
>            Assignee: Max Gekk
>            Priority: Major
>             Fix For: 3.3.0
>
>
> Currently, Spark SQL can throw Java exceptions from the 
> timestampadd()/date_add()/dateadd() functions, for instance:
> {code:java}
> spark-sql> select timestampadd(YEAR, 1000000, timestamp'2022-03-09 01:02:03');
> 22/03/09 14:47:15 ERROR SparkSQLDriver: Failed in [select timestampadd(YEAR, 
> 1000000, timestamp'2022-03-09 01:02:03')]
> java.lang.ArithmeticException: long overflow
>       at java.lang.Math.multiplyExact(Math.java:892) ~[?:1.8.0_292]
>       at 
> org.apache.spark.sql.catalyst.util.DateTimeUtils$.instantToMicros(DateTimeUtils.scala:505)
>  ~[spark-catalyst_2.12-3.3.0-SNAPSHOT.jar:3.3.0-SNAPSHOT]
>       at 
> org.apache.spark.sql.catalyst.util.DateTimeUtils$.timestampAddMonths(DateTimeUtils.scala:724)
>  ~[spark-catalyst_2.12-3.3.0-SNAPSHOT.jar:3.3.0-SNAPSHOT]
>       at 
> org.apache.spark.sql.catalyst.util.DateTimeUtils$.timestampAdd(DateTimeUtils.scala:1197)
>  ~[spark-catalyst_2.12-3.3.0-SNAPSHOT.jar:3.3.0-SNAPSHOT]
> {code}
> That might confuse non-Scala/Java users. Need to wrap such kind of exception 
> by Spark's exception using an error class.



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