From f5bfd5e1726fd37d415abce5b7c3d0b1993114ca Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Tue, 16 Jun 2026 19:41:05 +0000 Subject: [PATCH 1/2] [Spark] Only attempt server-side planning for Delta tables in loadTable AbstractDeltaCatalog.loadTable called ServerSidePlannedTable.tryCreate on every table returned by super.loadTable and returned the SSP table early when one was produced. That runs before the `case o => o` fallthrough, so a non-Delta table or a catalog-specific shape that is meant to pass through unchanged -- e.g. Unity Catalog's MetadataTable wrapping a ViewInfo for a metric view -- can be captured by SSP and short-circuit view loading. Move the tryCreate attempt inside the `case v1: V1Table if isDeltaTable` branch so SSP applies only to Delta tables; everything else flows through `case o => o` unchanged. Signed-off-by: Chen Wang --- .../sql/delta/catalog/AbstractDeltaCatalog.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spark/src/main/scala/org/apache/spark/sql/delta/catalog/AbstractDeltaCatalog.scala b/spark/src/main/scala/org/apache/spark/sql/delta/catalog/AbstractDeltaCatalog.scala index 12bcfaf8cce..1b0b59b95ea 100644 --- a/spark/src/main/scala/org/apache/spark/sql/delta/catalog/AbstractDeltaCatalog.scala +++ b/spark/src/main/scala/org/apache/spark/sql/delta/catalog/AbstractDeltaCatalog.scala @@ -374,13 +374,17 @@ class AbstractDeltaCatalog extends DelegatingCatalogExtension .map(_.loadTable(ident)) .getOrElse(super.loadTable(ident)) - ServerSidePlannedTable.tryCreate(spark, ident, table, isUnityCatalog).foreach { sspt => - return sspt - } - table match { case v1: V1Table if DeltaTableUtils.isDeltaTable(v1.catalogTable) => - loadCatalogTable(ident, v1.catalogTable) + // Server-side planning only applies to Delta tables. Attempt it here, inside the + // Delta-`V1Table` branch, rather than on every loaded table: a non-Delta table or a + // catalog-specific shape (e.g. Unity Catalog's `MetadataTable` wrapping a `ViewInfo` + // for a metric view) must flow through the `case o => o` fallthrough unchanged so the + // resolver can route it correctly. Capturing those in `ServerSidePlannedTable.tryCreate` + // would short-circuit view loading. + ServerSidePlannedTable + .tryCreate(spark, ident, table, isUnityCatalog) + .getOrElse(loadCatalogTable(ident, v1.catalogTable)) case o => o } } catch { From 59c766d0f2c35f6c0f89c91ebf1b58e65c3b60a9 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Mon, 22 Jun 2026 21:29:34 +0000 Subject: [PATCH 2/2] [Spark] Use Delta tables in ServerSidePlannedTableSuite fixtures SSP now only wraps Delta tables in loadTable, but the suite's fixtures were created USING parquet, so they fell through the non-Delta path and were never wrapped as ServerSidePlannedTable. Switch both fixtures to USING delta so they route through the Delta branch and SSP engages as the suite expects. Co-authored-by: Isaac --- .../serverSidePlanning/ServerSidePlannedTableSuite.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spark/src/test/scala/org/apache/spark/sql/delta/serverSidePlanning/ServerSidePlannedTableSuite.scala b/spark/src/test/scala/org/apache/spark/sql/delta/serverSidePlanning/ServerSidePlannedTableSuite.scala index 231ea7493ed..ab035bda505 100644 --- a/spark/src/test/scala/org/apache/spark/sql/delta/serverSidePlanning/ServerSidePlannedTableSuite.scala +++ b/spark/src/test/scala/org/apache/spark/sql/delta/serverSidePlanning/ServerSidePlannedTableSuite.scala @@ -36,7 +36,7 @@ class ServerSidePlannedTableSuite extends QueryTest with DeltaSQLCommandTest { name STRING, value INT, a STRUCT<`b.c`: STRING> - ) USING parquet + ) USING delta """) sql(""" INSERT INTO test_db.shared_test (id, name, value, a) VALUES @@ -222,7 +222,7 @@ class ServerSidePlannedTableSuite extends QueryTest with DeltaSQLCommandTest { CREATE TABLE readonly_test ( id INT, data STRING - ) USING parquet + ) USING delta """) // First insert WITHOUT server-side planning should succeed