dongjoon-hyun commented on a change in pull request #26379: [SPARK-29734][SQL] 
Datasource V2: Support SHOW CURRENT NAMESPACE
URL: https://github.com/apache/spark/pull/26379#discussion_r342247854
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
 ##########
 @@ -990,6 +990,29 @@ class DataSourceV2SQLSuite
     assert(catalogManager.currentNamespace === Array("ns1", "ns2"))
   }
 
+  test("ShowCurrentNamespace: basic tests") {
+    def testShowCurrentNamespace(expectedCatalogName: String, 
expectedNamespace: String): Unit = {
+      val schema = new StructType()
+        .add("catalog", StringType, nullable = false)
+        .add("namespace", StringType, nullable = false)
+      val df = sql("SHOW CURRENT NAMESPACE")
+      val rows = df.collect
+
+      assert(df.schema === schema)
+      assert(rows.length == 1)
+      assert(rows(0).getAs[String](0) === expectedCatalogName)
+      assert(rows(0).getAs[String](1) === expectedNamespace)
+    }
+
+    // Initially, the v2 session catalog is set as a current catalog.
+    testShowCurrentNamespace("spark_catalog", "default")
+
+    sql("Use testcat")
+    testShowCurrentNamespace("testcat", "")
+    sql("Use testcat.ns1.ns2")
+    testShowCurrentNamespace("testcat", "ns1.ns2")
 
 Review comment:
   I guess we need to avoid the side effect of `USE` command at this end of 
this test case. Or do you want to add `afterEach` in this test suite?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to