Chao Sun created SPARK-34076:
--------------------------------

             Summary: SQLContext.dropTempTable fails if cache is non-empty
                 Key: SPARK-34076
                 URL: https://issues.apache.org/jira/browse/SPARK-34076
             Project: Spark
          Issue Type: Bug
          Components: SQL
    Affects Versions: 3.0.1
            Reporter: Chao Sun


{{SQLContext.dropTempView}} calls {{CatalogImpl.dropTempView}} which is 
implemented as following:
{code}
  override def dropTempView(viewName: String): Boolean = {
    sparkSession.sessionState.catalog.getTempView(viewName).exists { viewDef =>
      sparkSession.sharedState.cacheManager.uncacheQuery(
        sparkSession, viewDef, cascade = false)
      sessionCatalog.dropTempView(viewName)
    }
  }
{code}

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:
{code}
Invalid call to qualifier on unresolved object, tree: 'key
{code}

This can be reproduced via:
{code}
  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")
      }
    }
  }
{code}

through test. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to