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

SQLContext.dropTempTable fails if cache is non-empty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1.0
    • 3.1.1
    • SQL
    • None

    Description

      SQLContext.dropTempView calls CatalogImpl.dropTempView which is implemented as following:

        override def dropTempView(viewName: String): Boolean = {
          sparkSession.sessionState.catalog.getTempView(viewName).exists { viewDef =>
            sparkSession.sharedState.cacheManager.uncacheQuery(
              sparkSession, viewDef, cascade = false)
            sessionCatalog.dropTempView(viewName)
          }
        }
      

      Here, the logical plan viewDef is not resolved, and when passing to uncacheQuery, it could fail at sameResult call, when canonicalized plan is compared. The error message looks like:

      Invalid call to qualifier on unresolved object, tree: 'key
      

      This can be reproduced via:

        test("XXX") {
          val t = "t"
          val v = "v"
          withTable(t) {
            withTempView(v) {
              sql(s"CREATE TABLE $t AS SELECT * FROM src")
              sql(s"CACHE TABLE $t")
              sql(s"CREATE TEMPORARY VIEW $v AS SELECT key FROM src LIMIT 10")
            }
          }
        }
      

      through test.

      Attachments

        Issue Links

          Activity

            People

              csun Chao Sun
              csun Chao Sun
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: