cloud-fan commented on a change in pull request #34497:
URL: https://github.com/apache/spark/pull/34497#discussion_r749389895



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/SupportsCatalogOptionsSuite.scala
##########
@@ -271,6 +275,47 @@ class SupportsCatalogOptionsSuite extends QueryTest with 
SharedSparkSession with
     }
   }
 
+  test("mock time travel test") {
+    sql(s"create table $catalogName.t123456789 (id bigint) using $format")
+    sql(s"create table $catalogName.t234567891 (id bigint) using $format")
+
+    val df1 = spark.range(10)
+    df1.write.format(format).option("name", "t123456789").option("catalog", 
catalogName)
+      .mode(SaveMode.Append).save()
+
+    val df2 = spark.range(10, 20)
+    df2.write.format(format).option("name", "t234567891").option("catalog", 
catalogName)
+      .mode(SaveMode.Overwrite).save()
+
+    // load with version
+    checkAnswer(load("t", Some(catalogName), Some("123456789")), df1.toDF())
+    checkAnswer(load("t", Some(catalogName), Some("234567891")), df2.toDF())
+
+    val ts1 = 
stringToTimestampWithoutTimeZone(UTF8String.fromString("2019-01-29 
00:37:58")).get
+    val ts2 = 
stringToTimestampWithoutTimeZone(UTF8String.fromString("2021-01-29 
00:37:58")).get
+
+    sql(s"create table $catalogName.t$ts1 (id bigint) using $format")
+    sql(s"create table $catalogName.t$ts2 (id bigint) using $format")
+
+    val df3 = spark.range(30, 40)
+    df3.write.format(format).option("name", s"t$ts1").option("catalog", 
catalogName)
+      .mode(SaveMode.Append).save()
+
+    val df4 = spark.range(50, 60)
+    df4.write.format(format).option("name", s"t$ts2").option("catalog", 
catalogName)
+      .mode(SaveMode.Overwrite).save()
+
+    // load with timestamp
+    checkAnswer(load("t", Some(catalogName), None, Some("2019-01-29 
00:37:58")), df3.toDF())
+    checkAnswer(load("t", Some(catalogName), None, Some("2021-01-29 
00:37:58")), df4.toDF())
+
+    val e = intercept[SparkException] {
+      load("t", Some(catalogName), Some("12345678"), Some("2019-01-29 
00:37:58"))
+    }
+    assert(e.getMessage
+      .contains("Version and Timestamp can't both be set for the underlying 
data source"))
+  }

Review comment:
       Can we have end-to-end test for SQL as well? We can put it in 
`DataSourceV2SQLSuite`




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to