cloud-fan 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_r343656079
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/test/SQLTestUtils.scala
##########
@@ -363,6 +364,28 @@ private[sql] trait SQLTestUtilsBase
}
}
+ /**
+ * Drops namespace `namespace` after calling `f`.
+ * Note that, do not switch current catalog in `f`. It may remove the wrong
namespace.
+ */
+ protected def withNamespace(namespaces: String*)(f: => Unit): Unit = {
+ Utils.tryWithSafeFinally(f) {
+ namespaces.foreach { name =>
+ spark.sql(s"DROP NAMESPACE IF EXISTS $name CASCADE")
+ }
+ import org.apache.spark.sql.connector.catalog.CatalogV2Implicits._
Review comment:
let's make it simple and not add complexity before we really need it.
For now all the caller sides do not switch current catalog/namespace. We can
just drop the namespace here, with doc saying callers should not switch current
catalog/namespace.
----------------------------------------------------------------
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]