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

SQLTestUtils.withTempDatabase should set `default` database before dropping

    XMLWordPrintableJSON

Details

    • Test
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 2.0.0
    • Tests
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: