You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Max Gekk (Jira)" <ji...@apache.org> on 2024/11/24 11:19:00 UTC
[jira] [Commented] (SPARK-49247) 0000-01-01 is a valid date
[ https://issues.apache.org/jira/browse/SPARK-49247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17900682#comment-17900682 ]
Max Gekk commented on SPARK-49247:
----------------------------------
> year 0 is not legal, it never existed
# Spark SQL uses the Proleptic Gregorian calendar according to the SQL standard and ISO 8601. The calendar includes a year 0, with dates before that given negative numbers, and dates after (dates AD) given positive ones. Apparently, Julian 1 BC is 0 in the Proleptic Gregorian calendar, 2 BC (Julian) is Gregorian -1.
# The supported range of dates by the SQL standard starts from 0001-01-01. The behavior for earlier dates is out standard's scope and is leaved to the implementation. Our implementation follows another standard ISO 8601.
> 0000-01-01 is a valid date
> --------------------------
>
> Key: SPARK-49247
> URL: https://issues.apache.org/jira/browse/SPARK-49247
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 3.4.3
> Reporter: Caican Cai
> Priority: Major
> Fix For: 4.0.0
>
>
> {code:java}
> scala> val df = spark.sql("SELECT date_add('0001-01-01', -2)")
> df: org.apache.spark.sql.DataFrame = [date_add(0001-01-01, -2): date]
> scala> df.show()
> +------------------------+
> |date_add(0001-01-01, -2)|
> +------------------------+
> | 0000-12-30|
> +------------------------+
> scala> val df = spark.sql("SELECT date_add('0000-01-01', -2)")
> df: org.apache.spark.sql.DataFrame = [date_add(0000-01-01, -2): date]
> scala> df.show()
> +------------------------+
> |date_add(0000-01-01, -2)|
> +------------------------+
> | -0001-12-30|
> +------------------------+
> {code}
> year 0 is not legal, it never existed
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org