You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2018/12/17 03:50:00 UTC

[jira] [Comment Edited] (SPARK-26002) SQL date operators calculates with incorrect dayOfYears for dates before 1500-03-01

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

Dongjoon Hyun edited comment on SPARK-26002 at 12/17/18 3:49 AM:
-----------------------------------------------------------------

Thanks, [~attilapiros]. I also confirmed that this bug exists in 2.0.2/1.6.3 while `date_format` works correctly.

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

scala> sc.version
res2: String = 2.0.2
{code}

{code}
scala> sql("select date_format('1500-01-01', 'D')").show
+---------------------------------------------+
|date_format(CAST(1500-01-01 AS TIMESTAMP), D)|
+---------------------------------------------+
|                                            1|
+---------------------------------------------+
{code}


was (Author: dongjoon):
Thanks, [~attilapiros]. I also confirmed that this bug exists in 2.0.2 while `date_format` works correctly.

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

scala> sc.version
res2: String = 2.0.2
{code}

{code}
scala> sql("select date_format('1500-01-01', 'D')").show
+---------------------------------------------+
|date_format(CAST(1500-01-01 AS TIMESTAMP), D)|
+---------------------------------------------+
|                                            1|
+---------------------------------------------+
{code}

> 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: 1.6.3, 2.0.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4.0, 3.0.0
>            Reporter: Attila Zsolt Piros
>            Priority: Major
>
> 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-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org