Skip to content

[SPARK-58392][SQL] Pass all options while loading relations - #57585

Open
yyanyy wants to merge 1 commit into
apache:masterfrom
yyanyy:spark-dsv2-loadrelation-options-20260727
Open

[SPARK-58392][SQL] Pass all options while loading relations#57585
yyanyy wants to merge 1 commit into
apache:masterfrom
yyanyy:spark-dsv2-loadrelation-options-20260727

Conversation

@yyanyy

@yyanyy yyanyy commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

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 RelationCatalog single-RPC path. This PR adds
RelationCatalog.loadRelation(Identifier, CaseInsensitiveStringMap) (default ignores the
options and delegates to loadRelation(Identifier), so existing connectors are
unaffected) and forwards the user options to it from RelationResolution.

Why are the changes needed?

For a RelationCatalog (a connector exposing both tables and views), loadRelation is
the 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 DataSourceV2OptionSuite asserting a spark.read.option(...) value reaches
loadRelation. 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

### 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant