Attila Zsolt Piros created SPARK-26002:
------------------------------------------

             Summary: SQL date operators calculates with incorrect dayOfYears 
for dates before 1500-03-01
                 Key: SPARK-26002
                 URL: https://issues.apache.org/jira/browse/SPARK-26002
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 2.4.0, 2.3.2, 2.3.1, 2.3.0, 2.2.2, 2.2.1, 2.2.0, 2.1.3, 
3.0.0
            Reporter: Attila Zsolt Piros


Running the following SQL the result is incorrect:
{noformat}
scala> sql("select dayOfYear('1500-01-02')").show()
+-----------------------------------+
|dayofyear(CAST(1500-01-02 AS DATE))|
+-----------------------------------+
|                                  1|
+-----------------------------------+
{noformat}
This off by one day is more annoying right at the beginning of a year:
{noformat}
scala> sql("select year('1500-01-01')").show()
+------------------------------+
|year(CAST(1500-01-01 AS DATE))|
+------------------------------+
|                          1499|
+------------------------------+


scala> sql("select month('1500-01-01')").show()
+-------------------------------+
|month(CAST(1500-01-01 AS DATE))|
+-------------------------------+
|                             12|
+-------------------------------+


scala> sql("select dayOfYear('1500-01-01')").show()
+-----------------------------------+
|dayofyear(CAST(1500-01-01 AS DATE))|
+-----------------------------------+
|                                365|
+-----------------------------------+
{noformat}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to