Skip to content

Commit b43845c

Browse files
author
Davies Liu
committed
add test
1 parent 3b4a94f commit b43845c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sql/core/src/test/scala/org/apache/spark/sql/parquet/ParquetQuerySuite.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.spark.sql.parquet
1919

2020
import org.scalatest.BeforeAndAfterAll
2121

22+
import org.apache.spark.sql.types._
2223
import org.apache.spark.sql.{SQLConf, QueryTest}
2324
import org.apache.spark.sql.catalyst.expressions.Row
2425
import org.apache.spark.sql.test.TestSQLContext
@@ -111,6 +112,18 @@ class ParquetQuerySuiteBase extends QueryTest with ParquetTest {
111112
List(Row("same", "run_5", 100)))
112113
}
113114
}
115+
116+
test("SPARK-6917 DecimalType should work with non-native types") {
117+
val data = (1 to 10).map(i => Row(Decimal(i, 18, 0), new java.sql.Timestamp(i)))
118+
val schema = StructType(List(StructField("d", DecimalType(18, 0), false),
119+
StructField("time", TimestampType, false)).toArray)
120+
withTempPath { file =>
121+
val df = sqlContext.createDataFrame(sparkContext.parallelize(data), schema)
122+
df.write.parquet(file.getCanonicalPath)
123+
val df2 = sqlContext.read.parquet(file.getCanonicalPath)
124+
checkAnswer(df2, df.collect().toSeq)
125+
}
126+
}
114127
}
115128

116129
class ParquetDataSourceOnQuerySuite extends ParquetQuerySuiteBase with BeforeAndAfterAll {

0 commit comments

Comments
 (0)