You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/02/27 22:58:08 UTC

[GitHub] [spark] sadikovi commented on a change in pull request #35655: [SPARK-38315][SQL] Add a config to control decoding of datetime as Java 8 classes

sadikovi commented on a change in pull request #35655:
URL: https://github.com/apache/spark/pull/35655#discussion_r815502277



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/sources/TableScanSuite.scala
##########
@@ -420,4 +434,32 @@ class TableScanSuite extends DataSourceTest with SharedSparkSession {
     val comments = planned.schema.fields.map(_.getComment().getOrElse("NO_COMMENT")).mkString(",")
     assert(comments === "SN,SA,NO_COMMENT")
   }
+
+  test("SPARK-38315: control decoding of datetime as Java 8 classes") {
+    val tableName = "relationProviderWithLegacyTimestamps"
+    def scanTable(): Unit = {
+      withTable (tableName) {
+        sql(
+          s"""
+             |CREATE TABLE $tableName (col TIMESTAMP)
+             |USING org.apache.spark.sql.sources.LegacyTimestampSource
+             """.stripMargin)
+        checkAnswer(
+          spark.table(tableName),
+          Row(java.sql.Timestamp.valueOf("2020-01-01 12:34:56")) :: Nil)
+      }
+    }
+
+    withSQLConf(SQLConf.DATETIME_JAVA8API_ENABLED.key -> "true") {
+      val e = intercept[SparkException] {
+        scanTable()
+      }.getCause
+      assert(e.isInstanceOf[java.lang.RuntimeException])
+      assert(e.getMessage.contains("Error while encoding"))
+
+      withSQLConf(SQLConf.LEGACY_DATETIME_ENCODER_ENABLED.key -> "true") {

Review comment:
       Could you add a comment explaining that this test case is supposed to pass and should not throw any exceptions?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org