Skip to content

Commit 475a29f

Browse files
hvanhovellgatorsmile
authored andcommitted
[SPARK-22637][SQL] Only refresh a logical plan once.
## What changes were proposed in this pull request? `CatalogImpl.refreshTable` uses `foreach(..)` to refresh all tables in a view. This traverses all nodes in the subtree and calls `LogicalPlan.refresh()` on these nodes. However `LogicalPlan.refresh()` is also refreshing its children, as a result refreshing a large view can be quite expensive. This PR just calls `LogicalPlan.refresh()` on the top node. ## How was this patch tested? Existing tests. Author: Herman van Hovell <[email protected]> Closes #19837 from hvanhovell/SPARK-22637.
1 parent a10b328 commit 475a29f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/internal/CatalogImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ class CatalogImpl(sparkSession: SparkSession) extends Catalog {
480480
if (tableMetadata.tableType == CatalogTableType.VIEW) {
481481
// Temp or persistent views: refresh (or invalidate) any metadata/data cached
482482
// in the plan recursively.
483-
table.queryExecution.analyzed.foreach(_.refresh())
483+
table.queryExecution.analyzed.refresh()
484484
} else {
485485
// Non-temp tables: refresh the metadata cache.
486486
sessionCatalog.refreshTable(tableIdent)

0 commit comments

Comments
 (0)