[
https://issues.apache.org/jira/browse/SPARK-22364?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sean Owen resolved SPARK-22364.
-------------------------------
Resolution: Not A Problem
These functions largely mimic Hive on purpose, and I think that's just how
unix_timestamp("...") is defined to behave. I agree about timezones, and so
would virtually always recommend you work in timestamps at the app level, not
date strings without timezones. If you have a date string with timezone you
should be able to parse it unambiguously with to_date or to_timestamp.
> unix_timestamp function sets valid dates to null
> ------------------------------------------------
>
> Key: SPARK-22364
> URL: https://issues.apache.org/jira/browse/SPARK-22364
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.2.0
> Environment: Windows 10, United Kingdom
> Reporter: Matthew Sinton-Hewitt
>
> org.apache.spark.sql.functions.unix_timestamp sets some valid dates to null.
> The dates happen to be the at the start of Daylight Savings time (UK and
> possibly elsewhere).
> {code:java}
> val spark = SparkSession.builder.getOrCreate()
> import spark.implicits._
> spark.sparkContext.parallelize(
> Seq("25/03/2012 00:59", "25/03/2012 01:00", "25/03/2012 01:59",
> "25/03/2012 02:01"))
> .toDF("date")
> .select(unix_timestamp($"date", "dd/MM/yyyy HH:mm"))
> .show(false)
> // results:
> // 1332637140, null, null, 1332637260
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]