Skip to content

Commit a8d27d6

Browse files
committed
Test for inferring the date type
1 parent 676bbb2 commit a8d27d6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/csv/CSVInferSchemaSuite.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,14 @@ class CSVInferSchemaSuite extends SparkFunSuite with SQLHelper {
188188

189189
Seq("en-US", "ko-KR", "ru-RU", "de-DE").foreach(checkDecimalInfer(_, DecimalType(7, 0)))
190190
}
191+
192+
test("inferring date type") {
193+
var options = new CSVOptions(Map("dateFormat" -> "yyyy/MM/dd"), false, "GMT")
194+
var inferSchema = new CSVInferSchema(options)
195+
assert(inferSchema.inferField(NullType, "2018/12/02") == DateType)
196+
197+
options = new CSVOptions(Map("dateFormat" -> "MMM yyyy"), false, "GMT")
198+
inferSchema = new CSVInferSchema(options)
199+
assert(inferSchema.inferField(NullType, "Dec 2018") == DateType)
200+
}
191201
}

0 commit comments

Comments
 (0)