Skip to content

Commit 3cd837f

Browse files
committed
Fix Json/CsvFunctionsSuite
1 parent ec75350 commit 3cd837f

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@ class CsvFunctionsSuite extends QueryTest with SharedSparkSession {
184184
}
185185

186186
test("special timestamp values") {
187-
Seq("now", "today", "epoch", "tomorrow", "yesterday").foreach { specialValue =>
188-
val input = Seq(specialValue).toDS()
189-
val readback = input.select(from_csv($"value", lit("t timestamp"),
190-
Map.empty[String, String].asJava)).collect()
191-
assert(readback(0).getAs[Row](0).getAs[Timestamp](0).getTime >= 0)
187+
withSQLConf(SQLConf.DIALECT.key -> SQLConf.Dialect.POSTGRESQL.toString) {
188+
Seq("now", "today", "epoch", "tomorrow", "yesterday").foreach { specialValue =>
189+
val input = Seq(specialValue).toDS()
190+
val readback = input.select(from_csv($"value", lit("t timestamp"),
191+
Map.empty[String, String].asJava)).collect()
192+
assert(readback(0).getAs[Row](0).getAs[Timestamp](0).getTime >= 0)
193+
}
192194
}
193195
}
194196
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,11 +611,13 @@ class JsonFunctionsSuite extends QueryTest with SharedSparkSession {
611611
}
612612

613613
test("special timestamp values") {
614-
Seq("now", "today", "epoch", "tomorrow", "yesterday").foreach { specialValue =>
615-
val input = Seq(s"""{"t": "$specialValue"}""").toDS()
616-
val readback = input.select(from_json($"value", lit("t timestamp"),
617-
Map.empty[String, String].asJava)).collect()
618-
assert(readback(0).getAs[Row](0).getAs[Timestamp](0).getTime >= 0)
614+
withSQLConf(SQLConf.DIALECT.key -> SQLConf.Dialect.POSTGRESQL.toString) {
615+
Seq("now", "today", "epoch", "tomorrow", "yesterday").foreach { specialValue =>
616+
val input = Seq(s"""{"t": "$specialValue"}""").toDS()
617+
val readback = input.select(from_json($"value", lit("t timestamp"),
618+
Map.empty[String, String].asJava)).collect()
619+
assert(readback(0).getAs[Row](0).getAs[Timestamp](0).getTime >= 0)
620+
}
619621
}
620622
}
621623
}

0 commit comments

Comments
 (0)