cloud-fan commented on a change in pull request #29767:
URL: https://github.com/apache/spark/pull/29767#discussion_r500084205
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/streaming/test/DataStreamTableAPISuite.scala
##########
@@ -169,6 +171,150 @@ class DataStreamTableAPISuite extends StreamTest with
BeforeAndAfter {
}
}
}
+
+ test("write: write to table with custom catalog & no namespace") {
+ val tableIdentifier = "testcat.table_name"
+
+ spark.sql(s"CREATE TABLE $tableIdentifier (id bigint, data string) USING
foo")
+ checkAnswer(spark.table(tableIdentifier), Seq.empty)
+
+ runTestWithStreamAppend(tableIdentifier)
+ }
+
+ test("write: write to table with custom catalog & namespace") {
+ spark.sql("CREATE NAMESPACE testcat.ns")
+
+ val tableIdentifier = "testcat.ns.table_name"
+
+ spark.sql(s"CREATE TABLE $tableIdentifier (id bigint, data string) USING
foo")
+ checkAnswer(spark.table(tableIdentifier), Seq.empty)
+
+ runTestWithStreamAppend(tableIdentifier)
+ }
+
+ test("write: write to table with default session catalog") {
+ val v2Source = classOf[FakeV2Provider].getName
+ spark.conf.set(SQLConf.V2_SESSION_CATALOG_IMPLEMENTATION.key,
+ classOf[InMemoryTableSessionCatalog].getName)
+
+ spark.sql("CREATE NAMESPACE ns")
+
+ val tableIdentifier = "ns.table_name"
+ spark.sql(s"CREATE TABLE $tableIdentifier (id bigint, data string) USING
$v2Source")
+ checkAnswer(spark.table(tableIdentifier), Seq.empty)
+
+ runTestWithStreamAppend(tableIdentifier)
+ }
+
+ test("write: write to non-exist table with custom catalog") {
+ val tableIdentifier = "testcat.nonexisttable"
+ val existTableIdentifier = "testcat.ns.nonexisttable"
+
+ spark.sql("CREATE NAMESPACE testcat.ns")
+ spark.sql(s"CREATE TABLE $existTableIdentifier (id bigint, data string)
USING foo")
+
+ withTempDir { checkpointDir =>
+ val exc = intercept[NoSuchTableException] {
+ runStreamQueryAppendMode(tableIdentifier, checkpointDir, Seq.empty,
Seq.empty)
+ }
+ assert(exc.getMessage.contains("nonexisttable"))
+ }
+ }
+
+ test("write: write to file provider based table isn't allowed yet") {
Review comment:
can we use a fake v2 provider that doesn't support streaming? We might
support file source v2 streaming write in the future.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]