Skip to content

Spark 4.1: Fix view rename target namespace#17128

Open
manuzhang wants to merge 1 commit into
apache:mainfrom
manuzhang:codex/spark-4.1-fix-view-rename-namespace-clean
Open

Spark 4.1: Fix view rename target namespace#17128
manuzhang wants to merge 1 commit into
apache:mainfrom
manuzhang:codex/spark-4.1-fix-view-rename-namespace-clean

Conversation

@manuzhang

Copy link
Copy Markdown
Member

Summary

Fix Spark 4.1 V2 view rename target resolution so an unqualified rename target keeps the source view namespace instead of being resolved through the current session namespace.

Root Cause

ExtendedDataSourceV2Strategy resolved the rename target with Spark3Util.catalogAndIdentifier before deciding whether the target was actually unqualified. For a single-part target name, that helper fills in the current namespace, which can differ from the source view namespace.

Changes

  • Resolve single-part view rename targets by applying the source view namespace directly.
  • Resolve multi-part targets relative to the source catalog and keep the existing cross-catalog move rejection.
  • Add a Spark 4.1 regression test covering a qualified source view renamed to an unqualified target while the session is using another namespace.

AI Disclosure

  • Model: GPT-5
  • Platform/Tool: OpenAI Codex
  • Human Oversight: partially reviewed
  • Prompt Summary: Fix and publish a Spark 4.1 PR for view rename namespace resolution.

@github-actions github-actions Bot added the spark label Jul 7, 2026
@manuzhang manuzhang requested review from huaxingao and nastra July 8, 2026 01:59
.create();

sql("USE %s.%s", catalogName, currentNamespace);
sql("ALTER VIEW %s.%s RENAME TO %s", sourceNamespace, viewName, renamedView);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it seems a bit counter-intuitive to resolve this against the target namespace instead of resolving against the current namespace? I don't think we have other places where we would have a similar resolution strategy? Typically providing only the plain identifier should always resolve to whatever catalog/namespace is currently configured

@manuzhang manuzhang Jul 9, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you check whether there are other places in Spark where this behavior exists or is rename the only one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it's a specific behavior in rename based on my research.

@manuzhang manuzhang requested a review from nastra July 9, 2026 00:50
@manuzhang manuzhang force-pushed the codex/spark-4.1-fix-view-rename-namespace-clean branch 2 times, most recently from 763b530 to 8f1b73e Compare July 9, 2026 06:39
Preserve the source view namespace when renaming a qualified view to an unqualified target name. This avoids routing the rename target through the current session namespace.

Generated-by: OpenAI Codex

Co-authored-by: Codex <codex@openai.com>
@manuzhang manuzhang force-pushed the codex/spark-4.1-fix-view-rename-namespace-clean branch from 8f1b73e to ad909de Compare July 9, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants