[CONNECT] Skip redundant DSv2 table refreshes in Spark Connect - #57609
Open
longvu-db wants to merge 1 commit into
Open
[CONNECT] Skip redundant DSv2 table refreshes in Spark Connect#57609longvu-db wants to merge 1 commit into
longvu-db wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
This PR implements the server-side SQL configuration approach suggested in #57043 (comment).
It adds the internal
spark.sql.execution.skipV2TableRefreshconfiguration, defaulting tofalse, and sets it totruewhenever the Spark Connect server creates or clones a session.QueryExecutionuses this setting when deriving its effectiverefreshPhaseEnabledvalue, so the optimization covers every Connect path that creates a query execution, including SQL, DataFrame operations, checkpoint, local checkpoint, and future call sites.Spark Connect's plan cache is handled conservatively. A cache hit can contain an already-resolved
DataSourceV2Relation, for which analysis alone cannot reload current table metadata. Such cached plans are cloned and tagged so theirQueryExecutionretains the refresh phase. Freshly analyzed Connect plans still skip it.The existing
QueryExecutionconstructor signature andrefreshPhaseEnabledaccessor remain binary-compatible.Why are the changes needed?
Spark Connect normally analyzes a plan immediately before execution. The DSv2 table refresh phase then performs another catalog
loadTablerequest without changing the outcome, adding an avoidable catalog round trip and latency.Using
spark.api.modeon the server is not reliable because it is a client-side builder/launcher directive and is not propagated to Spark Connect server sessions. A server-side session setting explicitly records the execution environment and avoids having to update every Connect call site.The plan-cache exception preserves correctness for resolved DSv2 relations that may outlive the table metadata captured during their original analysis.
Does this PR introduce any user-facing change?
No. The new configuration is internal. Spark Classic keeps the refresh phase enabled, while Spark Connect avoids redundant catalog refresh requests for freshly analyzed plans.
How was this patch tested?
Added a counting DSv2 catalog and tests that assert the exact number of
loadTablecalls, not only query results. Coverage includes:table,drop, SQL, checkpoint, and local checkpoint paths.The following suites passed (119 tests total):
QueryExecutionSuite: 29 tests.SparkConnectSessionManagerSuite: 11 tests.SparkConnectCloneSessionSuite: 9 tests.SparkConnectServerTestSuite: 21 tests.DataSourceV2DataFrameConnectSuite: 49 tests.Compilation passed for
catalyst/Test/compile,sql/Test/compile, andconnect/Test/compile. Scalastyle passed for the catalyst, SQL, and Connect modules.Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex