aboutsummaryrefslogtreecommitdiff
path: root/sql/hive
diff options
context:
space:
mode:
authorChristian Kadner <ckadner@us.ibm.com>2015-06-30 12:22:34 -0700
committerMichael Armbrust <michael@databricks.com>2015-06-30 12:22:34 -0700
commit1e1f339976641af4cc87d4010db57c3b600f91af (patch)
tree0ac825f3470c5ac4b53afaaab737c86a1f3161da /sql/hive
parentd16a9443750eebb7a3d7688d4b98a2ac39cc0da7 (diff)
downloadspark-1e1f339976641af4cc87d4010db57c3b600f91af.tar.gz
spark-1e1f339976641af4cc87d4010db57c3b600f91af.tar.bz2
spark-1e1f339976641af4cc87d4010db57c3b600f91af.zip
[SPARK-6785] [SQL] fix DateTimeUtils for dates before 1970
Hi Michael, this Pull-Request is a follow-up to [PR-6242](https://github.com/apache/spark/pull/6242). I removed the two obsolete test cases from the HiveQuerySuite and deleted the corresponding golden answer files. Thanks for your review! Author: Christian Kadner <ckadner@us.ibm.com> Closes #6983 from ckadner/SPARK-6785 and squashes the following commits: ab1e79b [Christian Kadner] Merge remote-tracking branch 'origin/SPARK-6785' into SPARK-6785 1fed877 [Christian Kadner] [SPARK-6785][SQL] failed Scala style test, remove spaces on empty line DateTimeUtils.scala:61 9d8021d [Christian Kadner] [SPARK-6785][SQL] merge recent changes in DateTimeUtils & MiscFunctionsSuite b97c3fb [Christian Kadner] [SPARK-6785][SQL] move test case for DateTimeUtils to DateTimeUtilsSuite a451184 [Christian Kadner] [SPARK-6785][SQL] fix DateTimeUtils.fromJavaDate(java.util.Date) for Dates before 1970
Diffstat (limited to 'sql/hive')
-rw-r--r--sql/hive/src/test/resources/golden/Date cast-0-a7cd69b80c77a771a2c955db666be53d1
-rw-r--r--sql/hive/src/test/resources/golden/Date comparison test 2-0-dc1b267f1d79d49e6675afe4fd2a34a51
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala14
-rw-r--r--sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala31
4 files changed, 30 insertions, 17 deletions
diff --git a/sql/hive/src/test/resources/golden/Date cast-0-a7cd69b80c77a771a2c955db666be53d b/sql/hive/src/test/resources/golden/Date cast-0-a7cd69b80c77a771a2c955db666be53d
deleted file mode 100644
index 98da82fa89..0000000000
--- a/sql/hive/src/test/resources/golden/Date cast-0-a7cd69b80c77a771a2c955db666be53d
+++ /dev/null
@@ -1 +0,0 @@
-1970-01-01 1970-01-01 1969-12-31 16:00:00 1969-12-31 16:00:00 1970-01-01 00:00:00
diff --git a/sql/hive/src/test/resources/golden/Date comparison test 2-0-dc1b267f1d79d49e6675afe4fd2a34a5 b/sql/hive/src/test/resources/golden/Date comparison test 2-0-dc1b267f1d79d49e6675afe4fd2a34a5
deleted file mode 100644
index 27ba77ddaf..0000000000
--- a/sql/hive/src/test/resources/golden/Date comparison test 2-0-dc1b267f1d79d49e6675afe4fd2a34a5
+++ /dev/null
@@ -1 +0,0 @@
-true
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
index 51dabc67fa..4cdba03b27 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala
@@ -324,20 +324,6 @@ class HiveQuerySuite extends HiveComparisonTest with BeforeAndAfter {
| FROM src LIMIT 1
""".stripMargin)
- createQueryTest("Date comparison test 2",
- "SELECT CAST(CAST(0 AS timestamp) AS date) > CAST(0 AS timestamp) FROM src LIMIT 1")
-
- createQueryTest("Date cast",
- """
- | SELECT
- | CAST(CAST(0 AS timestamp) AS date),
- | CAST(CAST(CAST(0 AS timestamp) AS date) AS string),
- | CAST(0 AS timestamp),
- | CAST(CAST(0 AS timestamp) AS string),
- | CAST(CAST(CAST('1970-01-01 23:00:00' AS timestamp) AS date) AS timestamp)
- | FROM src LIMIT 1
- """.stripMargin)
-
createQueryTest("Simple Average",
"SELECT AVG(key) FROM src")
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index 9f7e58f890..6d645393a6 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -17,10 +17,12 @@
package org.apache.spark.sql.hive.execution
+import java.sql.{Date, Timestamp}
+
+import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.DefaultParserDialect
import org.apache.spark.sql.catalyst.analysis.EliminateSubQueries
import org.apache.spark.sql.catalyst.errors.DialectException
-import org.apache.spark.sql._
import org.apache.spark.sql.hive.test.TestHive
import org.apache.spark.sql.hive.test.TestHive._
import org.apache.spark.sql.hive.test.TestHive.implicits._
@@ -962,4 +964,31 @@ class SQLQuerySuite extends QueryTest {
case None => // OK
}
}
+
+ test("SPARK-6785: HiveQuerySuite - Date comparison test 2") {
+ checkAnswer(
+ sql("SELECT CAST(CAST(0 AS timestamp) AS date) > CAST(0 AS timestamp) FROM src LIMIT 1"),
+ Row(false))
+ }
+
+ test("SPARK-6785: HiveQuerySuite - Date cast") {
+ // new Date(0) == 1970-01-01 00:00:00.0 GMT == 1969-12-31 16:00:00.0 PST
+ checkAnswer(
+ sql(
+ """
+ | SELECT
+ | CAST(CAST(0 AS timestamp) AS date),
+ | CAST(CAST(CAST(0 AS timestamp) AS date) AS string),
+ | CAST(0 AS timestamp),
+ | CAST(CAST(0 AS timestamp) AS string),
+ | CAST(CAST(CAST('1970-01-01 23:00:00' AS timestamp) AS date) AS timestamp)
+ | FROM src LIMIT 1
+ """.stripMargin),
+ Row(
+ Date.valueOf("1969-12-31"),
+ String.valueOf("1969-12-31"),
+ Timestamp.valueOf("1969-12-31 16:00:00"),
+ String.valueOf("1969-12-31 16:00:00"),
+ Timestamp.valueOf("1970-01-01 00:00:00")))
+ }
}