Skip to content

[SPARK-58226][SQL] Honor persistentCatalogFirst for DDL on two-part name resolution#57381

Open
jiashenC wants to merge 1 commit into
apache:masterfrom
jiashenC:ddl-multi-part-resolution
Open

[SPARK-58226][SQL] Honor persistentCatalogFirst for DDL on two-part name resolution#57381
jiashenC wants to merge 1 commit into
apache:masterfrom
jiashenC:ddl-multi-part-resolution

Conversation

@jiashenC

@jiashenC jiashenC commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

The DDL / misc-command resolution path (Analyzer.lookupTableOrView, used by DESCRIBE TABLE, ALTER TABLE, etc.) always resolved a local temp view before the persistent relation for a two-part session.<name> identifier, ignoring spark.sql.legacy.persistentCatalogFirst. Whereas, the SELECT/DML path (RelationResolution.resolveRelation) already honors that config for the same name shape from #53630, so the two paths diverged: the same session.<name> could resolve to different relations in a query vs. a DDL command.

Why are the changes needed?

To resolve the resolution divergence and ambiguity between DDL and SELECT.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Add test to check for DDL commands like DESCRIBE TABLE and ALTER TABLE resolve to the correct table entity.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude-Opus4.8

@jiashenC
jiashenC force-pushed the ddl-multi-part-resolution branch from 20933bc to b8297e0 Compare July 20, 2026 16:30
…ession.<name>

The DDL / misc-command resolution path (`Analyzer.lookupTableOrView`, used by
DESCRIBE TABLE, ALTER TABLE, etc.) always resolved a local temp view before the
persistent relation for a two-part `session.<name>` identifier, ignoring
`spark.sql.legacy.persistentCatalogFirst`. The SELECT/DML path
(`RelationResolution.resolveRelation`) already honors that config for the same
name shape, so the two paths diverged: the same `session.<name>` could resolve
to different relations in a query vs. a DDL command.

This makes `lookupTableOrView` mirror `resolveRelation`: for a two-part
`session.<name>`, resolution order follows `SQLConf.prioritizeSystemCatalog`
(the inverse of `PERSISTENT_CATALOG_FIRST`). All other name shapes and the
default (`prioritizeSystemCatalog = true`) keep their existing behavior.

Adds SECTION 15 to `RelationQualificationSuite`, the DDL companion to the
existing SELECT-path SECTION 13.
@jiashenC
jiashenC force-pushed the ddl-multi-part-resolution branch from b8297e0 to 84aa25c Compare July 20, 2026 17:01
@jiashenC jiashenC changed the title [SPARK-XXXXX][SQL] Honor persistentCatalogFirst for DDL on two-part s… [SPARK-XXXXX][SQL] Honor persistentCatalogFirst for DDL on two-part name resolution Jul 20, 2026
@jiashenC jiashenC changed the title [SPARK-XXXXX][SQL] Honor persistentCatalogFirst for DDL on two-part name resolution [SPARK-58226][SQL] Honor persistentCatalogFirst for DDL on two-part name resolution Jul 20, 2026

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jiashenC! LGTM, adding @cloud-fan @srielau @zhengruifeng - PTAL

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.

2 participants