You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Reynold Xin (JIRA)" <ji...@apache.org> on 2015/11/13 20:17:10 UTC
[jira] [Updated] (SPARK-11724) Casting integer types to timestamp
has unexpected semantics
[ https://issues.apache.org/jira/browse/SPARK-11724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Reynold Xin updated SPARK-11724:
--------------------------------
Labels: releasenotes (was: )
> Casting integer types to timestamp has unexpected semantics
> -----------------------------------------------------------
>
> Key: SPARK-11724
> URL: https://issues.apache.org/jira/browse/SPARK-11724
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 1.6.0
> Reporter: Nong Li
> Priority: Minor
> Labels: releasenotes
>
> Casting from integer types to timestamp treats the source int as being in millis. Casting from timestamp to integer types creates the result in seconds. This leads to behavior like:
> {code}
> scala> sql("select cast(cast (1234 as timestamp) as bigint)").show
> +---+
> |_c0|
> +---+
> | 1|
> +---+
> {code}
> Double's on the other hand treat it as seconds when casting to and from:
> {code}
> scala> sql("select cast(cast (1234.5 as timestamp) as double)").show
> +------+
> | _c0|
> +------+
> |1234.5|
> +------+
> {code}
> This also breaks some other functions which return long in seconds, in particular, unix_timestamp.
> {code}
> scala> sql("select cast(unix_timestamp() as timestamp)").show
> +--------------------+
> | _c0|
> +--------------------+
> |1970-01-17 10:03:...|
> +--------------------+
> scala> sql("select cast(unix_timestamp() *1000 as timestamp)").show
> +--------------------+
> | _c0|
> +--------------------+
> |2015-11-12 23:26:...|
> +--------------------+
> {code}
--
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