Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/16621#discussion_r96561166
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
---
@@ -650,14 +659,21 @@ class SessionCatalog(
* Refresh the cache entry for a metastore table, if any.
*/
def refreshTable(name: TableIdentifier): Unit = synchronized {
+ val dbName = formatDatabaseName(name.database.getOrElse(currentDb))
+ val tableName = formatTableName(name.table)
+
// Go through temporary tables and invalidate them.
- // If the database is defined, this is definitely not a temp table.
+ // If the database is defined, this may be a global temporary view.
// If the database is not defined, there is a good chance this is a
temp table.
if (name.database.isEmpty) {
- tempTables.get(formatTableName(name.table)).foreach(_.refresh())
- } else if (formatDatabaseName(name.database.get) ==
globalTempViewManager.database) {
-
globalTempViewManager.get(formatTableName(name.table)).foreach(_.refresh())
+ tempTables.get(tableName).foreach(_.refresh())
+ } else if (dbName == globalTempViewManager.database) {
+ globalTempViewManager.get(tableName).foreach(_.refresh())
}
+
+ // Also invalidate the table relation cache.
--- End diff --
How about keep the previous comment here?
```
// refreshTable does not eagerly reload the cache. It just invalidate
the cache.
// Next time when we use the table, it will be populated in the cache.
// Since we also cache ParquetRelations converted from Hive Parquet
tables and
// adding converted ParquetRelations into the cache is not defined in
the load function
// of the cache (instead, we add the cache entry in
convertToParquetRelation),
// it is better at here to invalidate the cache to avoid confusing
waring logs from the
// cache loader (e.g. cannot find data source provider, which is only
defined for
// data source table.).
```
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]