[
https://issues.apache.org/jira/browse/SPARK-60572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hyukjin Kwon reassigned SPARK-60572:
------------------------------------
Assignee: Linhong Liu
> Preserve NULL string day counts in date arithmetic
> --------------------------------------------------
>
> Key: SPARK-60572
> URL: https://issues.apache.org/jira/browse/SPARK-60572
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 5.0.0
> Reporter: Linhong Liu
> Assignee: Linhong Liu
> Priority: Major
> Labels: pull-request-available
>
> With ANSI mode disabled, date_add and date_sub incorrectly return their input
> date when the day-count argument is a foldable NULL string.
> {code:sql}
> SET spark.sql.ansi.enabled=false;
> SELECT date_add(DATE '2020-01-01', CAST(NULL AS STRING)),
> date_sub(DATE '2020-01-01', CAST(NULL AS STRING));
> {code}
> Expected: NULL, NULL. Actual: 2020-01-01, 2020-01-01.
> StringLiteralTypeCoercion unboxes the NULL result of the string-to-integer
> cast as Int, producing zero. Keep the cast result boxed and create an
> explicitly typed integer literal to preserve NULL.
> Regression coverage includes foldable NULL expressions, ANSI mode on and off,
> valid string day counts, and unchanged invalid-string errors.
> Patch: https://github.com/apache/spark/pull/59806
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]