diff options
author | Nong Li <nong@databricks.com> | 2015-11-20 14:19:34 -0800 |
---|---|---|
committer | Yin Huai <yhuai@databricks.com> | 2015-11-20 14:19:34 -0800 |
commit | 9ed4ad4265cf9d3135307eb62dae6de0b220fc21 (patch) | |
tree | a2d9f8037dafd67baafdbe3de7a903276a472652 /sql/core | |
parent | 652def318e47890bd0a0977dc982cc07f99fb06a (diff) | |
download | spark-9ed4ad4265cf9d3135307eb62dae6de0b220fc21.tar.gz spark-9ed4ad4265cf9d3135307eb62dae6de0b220fc21.tar.bz2 spark-9ed4ad4265cf9d3135307eb62dae6de0b220fc21.zip |
[SPARK-11724][SQL] Change casting between int and timestamp to consistently treat int in seconds.
Hive has since changed this behavior as well. https://issues.apache.org/jira/browse/HIVE-3454
Author: Nong Li <nong@databricks.com>
Author: Nong Li <nongli@gmail.com>
Author: Yin Huai <yhuai@databricks.com>
Closes #9685 from nongli/spark-11724.
Diffstat (limited to 'sql/core')
-rw-r--r-- | sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala index 241cbd0115..a61c3aa48a 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/DateFunctionsSuite.scala @@ -448,6 +448,9 @@ class DateFunctionsSuite extends QueryTest with SharedSQLContext { Row(date1.getTime / 1000L), Row(date2.getTime / 1000L))) checkAnswer(df.selectExpr(s"unix_timestamp(s, '$fmt')"), Seq( Row(ts1.getTime / 1000L), Row(ts2.getTime / 1000L))) + + val now = sql("select unix_timestamp()").collect().head.getLong(0) + checkAnswer(sql(s"select cast ($now as timestamp)"), Row(new java.util.Date(now * 1000))) } test("to_unix_timestamp") { |