imback82 commented on a change in pull request #34137:
URL: https://github.com/apache/spark/pull/34137#discussion_r718157446



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/ShowTablesSuiteBase.scala
##########
@@ -40,6 +42,10 @@ trait ShowTablesSuiteBase extends QueryTest with 
DDLCommandTestUtils {
     checkAnswer(df, expected)
   }
 
+  after {
+    spark.sessionState.catalogManager.reset()

Review comment:
       @cloud-fan I need to add this because the current namespace is not reset 
even if the dropped namespace is the current namespace. (this introduced a bug 
in test, which I fixed below).
   
   If I have:
   ```
   sql("create database db")
   sql("create table spark_catalog.db ...")
   sql("use spark_catalog.db") // Current namespace is "db"
   sql("drop database db") // Current namespace is still "db"
   ```
   Should we fix above? I can fix it as a separate PR if the current behavior 
doesn't seem right.

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTablesSuite.scala
##########
@@ -84,7 +105,7 @@ trait ShowTablesSuiteBase extends 
command.ShowTablesSuiteBase {
         false -> "PARTITION(YEAR = 2015, Month = 1)"
       ).foreach { case (caseSensitive, partitionSpec) =>
         withSQLConf(SQLConf.CASE_SENSITIVE.key -> caseSensitive.toString) {
-          val df = sql(s"SHOW TABLE EXTENDED LIKE 'part_table' $partitionSpec")
+          val df = sql(s"SHOW TABLE EXTENDED IN ns LIKE 'part_table' 
$partitionSpec")

Review comment:
       This seems like an existing bug, but this worked because the current 
namespace was never reset even when the namespace is dropped.

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/ShowTablesSuiteBase.scala
##########
@@ -40,6 +42,10 @@ trait ShowTablesSuiteBase extends QueryTest with 
DDLCommandTestUtils {
     checkAnswer(df, expected)
   }
 
+  after {
+    spark.sessionState.catalogManager.reset()

Review comment:
       V1 / V2 behaviors are the same since the current namespace is managed by 
`CatalogManager`. (`SessionCatalog` doesn't reset the current database when the 
current database is dropped). Let me check the postgre's behavior.

##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/command/ShowTablesSuiteBase.scala
##########
@@ -40,6 +42,10 @@ trait ShowTablesSuiteBase extends QueryTest with 
DDLCommandTestUtils {
     checkAnswer(df, expected)
   }
 
+  after {
+    spark.sessionState.catalogManager.reset()

Review comment:
       V1 / V2 behaviors are the same since the current namespace is managed by 
`CatalogManager`. (`SessionCatalog.dropDatabase` also doesn't reset the current 
database when the current database is dropped). Let me check the postgre's 
behavior.




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