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 2016/07/05 22:53:11 UTC

[jira] [Commented] (SPARK-16384) FROM_UNIXTIME reports incorrect days

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

Dongjoon Hyun commented on SPARK-16384:
---------------------------------------

Hi, [~epanastasi]

That is not a bug. You should use 'yyyy' instead of 'YYYY'.

{code}
scala> sql("SELECT FROM_UNIXTIME(1451260800, 'YYYY-MM-dd')").collect
res1: Array[org.apache.spark.sql.Row] = Array([2016-12-27])

scala> sql("SELECT FROM_UNIXTIME(1451260800, 'yyyy-MM-dd')").collect
res2: Array[org.apache.spark.sql.Row] = Array([2015-12-27])
{code}

> FROM_UNIXTIME reports incorrect days
> ------------------------------------
>
>                 Key: SPARK-16384
>                 URL: https://issues.apache.org/jira/browse/SPARK-16384
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.6.1, 1.6.2, 2.0.0
>            Reporter: Frank Stratton
>
> Timestamps between 2015-12-27 and 2015-12-31 are reported in the incorrect year (2016-12-*):
> {quote}
> results = sqlContext.sql("SELECT FROM_UNIXTIME(1451088000, 'YYYY-MM-dd')")   # 2015-12-26
> print results.collect()
> results = sqlContext.sql("SELECT FROM_UNIXTIME(1451174400, 'YYYY-MM-dd')")   # 2015-12-27
> print results.collect()
> results = sqlContext.sql("SELECT FROM_UNIXTIME(1451260800, 'YYYY-MM-dd')")   # 2015-12-28
> print results.collect()
> results = sqlContext.sql("SELECT FROM_UNIXTIME(1451347200, 'YYYY-MM-dd')")   # 2015-12-29
> print results.collect()
> {quote}
> outputs:
> {quote}
> [Row(_c0=u'2015-12-26')]
> [Row(_c0=u'2016-12-27')]
> [Row(_c0=u'2016-12-28')]
> [Row(_c0=u'2016-12-29')]
> {quote}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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