Skip to content

Commit 460fad8

Browse files
lianchengmarmbrus
authored andcommitted
[SPARK-2729][SQL] Added test case for SPARK-2729
This is a follow up of #1636. Author: Cheng Lian <[email protected]> Closes #1738 from liancheng/test-for-spark-2729 and squashes the following commits: b13692a [Cheng Lian] Added test case for SPARK-2729 (cherry picked from commit 866cf1f) Signed-off-by: Michael Armbrust <[email protected]>
1 parent 4230df4 commit 460fad8

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

sql/core/src/test/scala/org/apache/spark/sql/TestData.scala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
package org.apache.spark.sql
1919

20+
import java.sql.Timestamp
21+
2022
import org.apache.spark.sql.catalyst.plans.logical
2123
import org.apache.spark.sql.test._
2224

2325
/* Implicits */
24-
import TestSQLContext._
26+
import org.apache.spark.sql.test.TestSQLContext._
2527

2628
case class TestData(key: Int, value: String)
2729

@@ -40,7 +42,7 @@ object TestData {
4042
LargeAndSmallInts(2147483646, 1) ::
4143
LargeAndSmallInts(3, 2) :: Nil)
4244
largeAndSmallInts.registerAsTable("largeAndSmallInts")
43-
45+
4446
case class TestData2(a: Int, b: Int)
4547
val testData2: SchemaRDD =
4648
TestSQLContext.sparkContext.parallelize(
@@ -143,4 +145,10 @@ object TestData {
143145
"2, B2, false, null" ::
144146
"3, C3, true, null" ::
145147
"4, D4, true, 2147483644" :: Nil)
148+
149+
case class TimestampField(time: Timestamp)
150+
val timestamps = TestSQLContext.sparkContext.parallelize((1 to 3).map { i =>
151+
TimestampField(new Timestamp(i))
152+
})
153+
timestamps.registerAsTable("timestamps")
146154
}

sql/core/src/test/scala/org/apache/spark/sql/columnar/InMemoryColumnarQuerySuite.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,16 @@ class InMemoryColumnarQuerySuite extends QueryTest {
7373
sql("SELECT * FROM nullableRepeatedData"),
7474
nullableRepeatedData.collect().toSeq)
7575
}
76+
77+
test("SPARK-2729 regression: timestamp data type") {
78+
checkAnswer(
79+
sql("SELECT time FROM timestamps"),
80+
timestamps.collect().toSeq)
81+
82+
TestSQLContext.cacheTable("timestamps")
83+
84+
checkAnswer(
85+
sql("SELECT time FROM timestamps"),
86+
timestamps.collect().toSeq)
87+
}
7688
}

0 commit comments

Comments
 (0)