Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-16529

SQLTestUtils.withTempDatabase should set `default` database before dropping

    XMLWordPrintableJSON

    Details

    • Type: Test
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: Tests
    • Labels:
      None

      Description

      `withTempDatabase` is a frequently used test harness to setup a temporary table and clean up finally. This issue improves like the following for usability.

      -    try f(dbName) finally spark.sql(s"DROP DATABASE $dbName CASCADE")
      +    try f(dbName) finally {
      +      if (spark.catalog.currentDatabase == dbName) {
      +        spark.sql(s"USE ${DEFAULT_DATABASE}")
      +      }
      +      spark.sql(s"DROP DATABASE $dbName CASCADE")
      +    }
      

      In case of forgetting to reset the databaes, `withTempDatabase` will not raise Exception.

        Attachments

          Activity

            People

            • Assignee:
              dongjoon Dongjoon Hyun
              Reporter:
              dongjoon Dongjoon Hyun
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: