imback82 commented on a change in pull request #26411: [SPARK-29772][TESTS][SQL] Add withNamespace in SQLTestUtils URL: https://github.com/apache/spark/pull/26411#discussion_r343784310
########## File path: sql/core/src/test/scala/org/apache/spark/sql/test/SQLTestUtils.scala ########## @@ -363,6 +363,18 @@ private[sql] trait SQLTestUtilsBase } } + /** + * Drops namespace `namespace` after calling `f`. + */ + protected def withNamespace(namespaces: String*)(f: => Unit): Unit = { + Utils.tryWithSafeFinally(f) { + namespaces.foreach { name => + spark.sql(s"DROP NAMESPACE IF EXISTS $name CASCADE") + } + spark.sql(s"USE default") Review comment: > We should set back to the default namespace of the current catalog. Not sure we have such a command yet, cc @imback82 No, we don't have a such a command yet. Do you think it will be useful to have one? This also reminds me about the behavior of dropping namespace. If you are trying to drop a namespace, which is set to the current namespace, this shouldn't be allowed right? We don't have a such a check yet, but I can add one if needed. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org