cloud-fan commented on code in PR #44328:
URL: https://github.com/apache/spark/pull/44328#discussion_r1425836204


##########
sql/core/src/test/scala/org/apache/spark/sql/internal/CatalogSuite.scala:
##########
@@ -167,6 +167,44 @@ class CatalogSuite extends SharedSparkSession with 
AnalysisTest with BeforeAndAf
       Set("default", "my_db2"))
   }
 
+  test("list databases with special character") {
+    Seq(true, false).foreach { legacy =>
+      withSQLConf(SQLConf.LEGACY_KEEP_COMMAND_OUTPUT_SCHEMA.key -> 
legacy.toString) {
+        spark.catalog.setCurrentCatalog(CatalogManager.SESSION_CATALOG_NAME)
+        assert(spark.catalog.listDatabases().collect().map(_.name).toSet == 
Set("default"))
+        // use externalCatalog to bypass the database name validation in 
SessionCatalog
+        
spark.sharedState.externalCatalog.createDatabase(utils.newDb("my-db1"), false)
+        
spark.sharedState.externalCatalog.createDatabase(utils.newDb("my`db2"), false)
+        assert(spark.catalog.listDatabases().collect().map(_.name).toSet ==
+          Set("default", "`my-db1`", "`my``db2`"))
+        if (legacy) {
+          assert(
+            spark.catalog.listDatabases("my*").collect().map(_.name).toSet ==
+              Set("`my-db1`", "`my``db2`")
+          )
+          
assert(spark.catalog.listDatabases("`my*`").collect().map(_.name).toSet == 
Set.empty)
+        } else {
+          
assert(spark.catalog.listDatabases("my*").collect().map(_.name).toSet == 
Set.empty)

Review Comment:
   why is there a behavior difference here?



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