srowen commented on a change in pull request #24747: [SPARK-27772][SQL][TEST] 
SQLTestUtils Refactoring
URL: https://github.com/apache/spark/pull/24747#discussion_r289517024
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/test/SQLTestUtils.scala
 ##########
 @@ -255,61 +254,41 @@ private[sql] trait SQLTestUtilsBase
    * Drops temporary view `viewNames` after calling `f`.
    */
   protected def withTempView(viewNames: String*)(f: => Unit): Unit = {
-    try f finally {
-      // If the test failed part way, we don't want to mask the failure by 
failing to remove
-      // temp views that never got created.
-      try viewNames.foreach(spark.catalog.dropTempView) catch {
-        case _: NoSuchTableException =>
-      }
-    }
+    Utils.tryWithSafeFinally(f)(viewNames.foreach(spark.catalog.dropTempView))
 
 Review comment:
   It looks like this code purposely doesn't throw NoSuchTableException in any 
case. It doesn't matter much if it's just added as a suppressed exception, but 
in the case the main block doesn't throw, NoSuchTableException is thrown. I 
wouldn't change the semantics here without being sure; it's not clear to me it 
indicates user error.
   
   Why not just leave the finally block as is? it's simpler.

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