-
Notifications
You must be signed in to change notification settings - Fork 2k
[Server-Side Planning] Add metadata abstraction and factory pattern #5671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
tdas
merged 1 commit into
delta-io:master
from
murali-db:upstream/row3-metadata-abstraction-clean
Dec 11, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...main/scala/org/apache/spark/sql/delta/serverSidePlanning/ServerSidePlanningMetadata.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright (2025) The Delta Lake Project Authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.delta.serverSidePlanning | ||
|
|
||
| import org.apache.spark.sql.SparkSession | ||
| import org.apache.spark.sql.connector.catalog.{Identifier, Table} | ||
|
|
||
| /** | ||
| * Metadata required for creating a server-side planning client. | ||
| * | ||
| * This interface captures all information from the catalog's loadTable response | ||
| * that is needed to create and configure a ServerSidePlanningClient. | ||
| */ | ||
| private[serverSidePlanning] trait ServerSidePlanningMetadata { | ||
| /** | ||
| * The base URI for the planning endpoint. | ||
| */ | ||
| def planningEndpointUri: String | ||
|
|
||
| /** | ||
| * Authentication token for the planning endpoint. | ||
| */ | ||
| def authToken: Option[String] | ||
|
|
||
| /** | ||
| * Catalog name for configuration lookups. | ||
| */ | ||
| def catalogName: String | ||
|
|
||
| /** | ||
| * Additional table properties that may be needed. | ||
| * For example, table UUID, credential hints, etc. | ||
| */ | ||
| def tableProperties: Map[String, String] | ||
| } | ||
|
|
||
| /** | ||
| * Default metadata for non-UC catalogs. | ||
| * Used when server-side planning is force-enabled for testing/development. | ||
| */ | ||
| private[serverSidePlanning] case class DefaultMetadata( | ||
| catalogName: String, | ||
| tableProps: Map[String, String] = Map.empty) extends ServerSidePlanningMetadata { | ||
| override def planningEndpointUri: String = "" | ||
| override def authToken: Option[String] = None | ||
| override def tableProperties: Map[String, String] = tableProps | ||
| } | ||
|
|
||
| object ServerSidePlanningMetadata { | ||
| /** | ||
| * Create metadata from a loaded table. | ||
| * | ||
| * Currently returns DefaultMetadata for all catalogs. | ||
| * Unity Catalog-specific implementation will be added in a later PR. | ||
| */ | ||
| def fromTable( | ||
| table: Table, | ||
| spark: SparkSession, | ||
| ident: Identifier, | ||
| isUnityCatalog: Boolean): ServerSidePlanningMetadata = { | ||
|
|
||
| val catalogName = extractCatalogName(ident) | ||
| DefaultMetadata(catalogName, Map.empty) | ||
| } | ||
|
|
||
| private def extractCatalogName(ident: Identifier): String = { | ||
| if (ident.namespace().length > 1) { | ||
| ident.namespace().head | ||
| } else { | ||
| "spark_catalog" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,4 +176,25 @@ class ServerSidePlannedTableSuite extends QueryTest with DeltaSQLCommandTest { | |
| ) | ||
| } | ||
| } | ||
|
|
||
| test("fromTable returns metadata with empty defaults for non-UC catalogs") { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what fromTable? you have to say ServerSidePlanningMetadata.fromTable? |
||
| import org.apache.spark.sql.connector.catalog.Identifier | ||
|
|
||
| // Create a simple identifier for testing | ||
| val ident = Identifier.of(Array("my_catalog", "my_schema"), "my_table") | ||
|
|
||
| // Call fromTable with a null table (we only use the identifier for catalog name extraction) | ||
| val metadata = ServerSidePlanningMetadata.fromTable( | ||
| table = null, | ||
| spark = spark, | ||
| ident = ident, | ||
| isUnityCatalog = false | ||
| ) | ||
|
|
||
| // Verify the metadata has expected defaults | ||
| assert(metadata.catalogName == "my_catalog") | ||
| assert(metadata.planningEndpointUri == "") | ||
| assert(metadata.authToken.isEmpty) | ||
| assert(metadata.tableProperties.isEmpty) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in future we may want to generalize this to allow different auth mechanisms other than token.