Nong Li created SPARK-11724:
-------------------------------
Summary: 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
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: [email protected]
For additional commands, e-mail: [email protected]