aboutsummaryrefslogtreecommitdiff
path: root/sql/catalyst/src/test
diff options
context:
space:
mode:
authorPatrick Wendell <patrick@databricks.com>2015-02-02 17:52:17 -0800
committerPatrick Wendell <patrick@databricks.com>2015-02-02 17:52:17 -0800
commiteccb9fbb2d1bf6f7c65fb4f017e9205bb3034ec6 (patch)
treef622b1610261ccdafc8aa27578f16e0e27ad4701 /sql/catalyst/src/test
parentcfea30037ff4ac7e386a1478e7dce07ca3bb9072 (diff)
downloadspark-eccb9fbb2d1bf6f7c65fb4f017e9205bb3034ec6.tar.gz
spark-eccb9fbb2d1bf6f7c65fb4f017e9205bb3034ec6.tar.bz2
spark-eccb9fbb2d1bf6f7c65fb4f017e9205bb3034ec6.zip
Revert "[SPARK-4508] [SQL] build native date type to conform behavior to Hive"
This reverts commit 1646f89d967913ee1f231d9606f8502d13c25804.
Diffstat (limited to 'sql/catalyst/src/test')
-rw-r--r--sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala28
-rw-r--r--sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala2
2 files changed, 15 insertions, 15 deletions
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
index 25d1c105a0..37e64adeea 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/ExpressionEvaluationSuite.scala
@@ -303,7 +303,6 @@ class ExpressionEvaluationSuite extends FunSuite {
val sd = "1970-01-01"
val d = Date.valueOf(sd)
- val zts = sd + " 00:00:00"
val sts = sd + " 00:00:02"
val nts = sts + ".1"
val ts = Timestamp.valueOf(nts)
@@ -320,14 +319,14 @@ class ExpressionEvaluationSuite extends FunSuite {
checkEvaluation(Cast(Literal(1.toDouble) cast TimestampType, DoubleType), 1.toDouble)
checkEvaluation(Cast(Literal(sd) cast DateType, StringType), sd)
- checkEvaluation(Cast(Literal(d) cast StringType, DateType), 0)
+ checkEvaluation(Cast(Literal(d) cast StringType, DateType), d)
checkEvaluation(Cast(Literal(nts) cast TimestampType, StringType), nts)
checkEvaluation(Cast(Literal(ts) cast StringType, TimestampType), ts)
// all convert to string type to check
checkEvaluation(
Cast(Cast(Literal(nts) cast TimestampType, DateType), StringType), sd)
checkEvaluation(
- Cast(Cast(Literal(ts) cast DateType, TimestampType), StringType), zts)
+ Cast(Cast(Literal(ts) cast DateType, TimestampType), StringType), sts)
checkEvaluation(Cast("abdef" cast BinaryType, StringType), "abdef")
@@ -378,8 +377,8 @@ class ExpressionEvaluationSuite extends FunSuite {
}
test("date") {
- val d1 = DateUtils.fromJavaDate(Date.valueOf("1970-01-01"))
- val d2 = DateUtils.fromJavaDate(Date.valueOf("1970-01-02"))
+ val d1 = Date.valueOf("1970-01-01")
+ val d2 = Date.valueOf("1970-01-02")
checkEvaluation(Literal(d1) < Literal(d2), true)
}
@@ -460,21 +459,22 @@ class ExpressionEvaluationSuite extends FunSuite {
test("date casting") {
val d = Date.valueOf("1970-01-01")
- checkEvaluation(Cast(Literal(d), ShortType), null)
- checkEvaluation(Cast(Literal(d), IntegerType), null)
- checkEvaluation(Cast(Literal(d), LongType), null)
- checkEvaluation(Cast(Literal(d), FloatType), null)
- checkEvaluation(Cast(Literal(d), DoubleType), null)
- checkEvaluation(Cast(Literal(d), DecimalType.Unlimited), null)
- checkEvaluation(Cast(Literal(d), DecimalType(10, 2)), null)
- checkEvaluation(Cast(Literal(d), StringType), "1970-01-01")
- checkEvaluation(Cast(Cast(Literal(d), TimestampType), StringType), "1970-01-01 00:00:00")
+ checkEvaluation(Cast(d, ShortType), null)
+ checkEvaluation(Cast(d, IntegerType), null)
+ checkEvaluation(Cast(d, LongType), null)
+ checkEvaluation(Cast(d, FloatType), null)
+ checkEvaluation(Cast(d, DoubleType), null)
+ checkEvaluation(Cast(d, DecimalType.Unlimited), null)
+ checkEvaluation(Cast(d, DecimalType(10, 2)), null)
+ checkEvaluation(Cast(d, StringType), "1970-01-01")
+ checkEvaluation(Cast(Cast(d, TimestampType), StringType), "1970-01-01 00:00:00")
}
test("timestamp casting") {
val millis = 15 * 1000 + 2
val seconds = millis * 1000 + 2
val ts = new Timestamp(millis)
+ val ts1 = new Timestamp(15 * 1000) // a timestamp without the milliseconds part
val tss = new Timestamp(seconds)
checkEvaluation(Cast(ts, ShortType), 15)
checkEvaluation(Cast(ts, IntegerType), 15)
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala
index 7bcd6687d1..c147be9f6b 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/types/DataTypeSuite.scala
@@ -106,7 +106,7 @@ class DataTypeSuite extends FunSuite {
checkDefaultSize(DoubleType, 8)
checkDefaultSize(DecimalType(10, 5), 4096)
checkDefaultSize(DecimalType.Unlimited, 4096)
- checkDefaultSize(DateType, 4)
+ checkDefaultSize(DateType, 8)
checkDefaultSize(TimestampType, 8)
checkDefaultSize(StringType, 4096)
checkDefaultSize(BinaryType, 4096)