Github user skambha commented on a diff in the pull request: https://github.com/apache/spark/pull/14897#discussion_r77879554 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala --- @@ -451,7 +464,7 @@ class SessionCatalog( if (isTemporaryTable(name)) { true } else { - externalCatalog.tableExists(db, table) + globalTempViews.get(table).isDefined || externalCatalog.tableExists(db, table) --- End diff -- I think the tableExists should also follow the similar semantics as the lookupRelation. i.e. If database in TableIdentifier is defined, then table existence should be checked against the defined database and table. The code comment is correct but the code is not enforcing it in tableExists. The table/view resolution in the lookupRelation is - if database is defined, then fetch the table/view from it. - if database is not defined, then the following checks happen in the particular order. a) check if it a local temp view exists b) if a global temp view with name exists. c) If not, then check if there is a table/view in current db. Currently, if I do tableExists(db1.t1), it will return true if a global temp view t1 exists but there is no db1.t1 in the externalCatalog. In tableExists method, we should enforce the check if database is defined, we should check against the externalCatalog and not the globalTempView... and enhance it to follow the resolution semantics in the lookupRelation.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org