[SPARK-58392][SQL] Pass all options while loading relations - #57585
Open
yyanyy wants to merge 1 commit into
Open
[SPARK-58392][SQL] Pass all options while loading relations#57585yyanyy wants to merge 1 commit into
yyanyy wants to merge 1 commit into
Conversation
### What changes were proposed in this pull request?
Add `RelationCatalog.loadRelation(Identifier, CaseInsensitiveStringMap)` and route the
resolver's single-RPC plain-read path through it, so a `RelationCatalog` (a connector that
exposes both tables and views) receives all user-specified `.option(...)` values when a
plain table or view is read.
- New `default` method on `RelationCatalog` whose default implementation ignores the options
and delegates to the existing `loadRelation(Identifier)`, so existing connectors are
unaffected; catalogs that want the options override it.
- `RelationResolution.tryResolvePersistent` forwards the already-computed `finalOptions`
(`= u.clearWritePrivileges.options`) to the new method in the `RelationCatalog` branch,
which fires only when there is no time travel and no write privileges.
### Why are the changes needed?
This is the single-RPC counterpart of the recently added options-aware table read
(`TableCatalog.loadTable(ident, TableContext, CaseInsensitiveStringMap)`). For a
`RelationCatalog`, `loadRelation(ident)` is the primary plain-read path -- it answers "table
or view?" in one call -- and it currently drops the user options, so a connector cannot see
them when reading a plain relation.
### Does this PR introduce _any_ user-facing change?
No. This is a new connector-API entry point with a default that preserves existing behavior.
### How was this patch tested?
Added a test to `DataSourceV2OptionSuite` that registers an `InMemoryRelationCatalog`
(instrumented to record the options passed to `loadRelation`), creates a table, reads it with
`spark.read.option("customOption", "customValue").table(...)`, and asserts the option reaches
`loadRelation`. Regression:
- `DataSourceV2OptionSuite`, `DataSourceV2MetadataViewSuite`, `MetricViewV2CatalogSuite`,
`SupportsCatalogOptionsSuite`: 76/76 passed.
- `DataSourceV2SQLSuiteV1Filter`, `DataSourceV2SQLSuiteV2Filter`, and the v2 view command
suites (`CreateViewSuite`, `DropViewSuite`, `AlterViewAsSuite`, `ShowViewsSuite`,
`DescribeViewSuite`, `ShowTablesSuite`): 572/572 passed (1 pre-existing ignore).
### Was this patch authored or co-authored using generative AI tooling?
Yes, authored with assistance from Claude Code (Anthropic).
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?
Follow-up to #57582 (SPARK-58389), which forwarded user options to the table read path
but not the
RelationCatalogsingle-RPC path. This PR addsRelationCatalog.loadRelation(Identifier, CaseInsensitiveStringMap)(default ignores theoptions and delegates to
loadRelation(Identifier), so existing connectors areunaffected) and forwards the user options to it from
RelationResolution.Why are the changes needed?
For a
RelationCatalog(a connector exposing both tables and views),loadRelationisthe primary plain-read path, and it currently drops the user options. This is the
single-RPC counterpart of #57582 and lets such connectors see the read options when
producing the relation.
Does this PR introduce any user-facing change?
No. New connector-API entry point with a behavior-preserving default; not yet released.
How was this patch tested?
New test in
DataSourceV2OptionSuiteasserting aspark.read.option(...)value reachesloadRelation. Regression:DataSourceV2OptionSuite,DataSourceV2MetadataViewSuite,MetricViewV2CatalogSuite,SupportsCatalogOptionsSuite(76/76);DataSourceV2SQLSuite(V1/V2 filter) and the v2 view command suites (572/572).
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code Opus 4.8