Skip to content

[SPARK-52417][SQL] Simplify Table properties handling in View Schema Evolution Mode #51107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

szehon-ho
Copy link
Contributor

@szehon-ho szehon-ho commented Jun 7, 2025

What changes were proposed in this pull request?

When a View is created, ex CREATE VIEW v (a1 INT, a2 STRING) AS select c1, c2, it needs to save both set of columns (alias and query output).

  1. Alias is saved as View Schema (a1 INT, b2 STRING).
  2. Query output is saved as Table property w/index (c1, 0) (c2, 1)

In the new Schema Evolution mode, we never allow alias, so view schema == view query output schema.  Every time we detect the output view schema changes, we sync the view's schema with view query schema, keeping the invariant.

So we can simplify the update in Schema Evolution mode to not update the Table Properties, and instead rely on the View Schema all the time.

Why are the changes needed?

View Schema Evolution is a useful mode. However, it requires a lot of permissions on the user querying the view, because that user needs to update the View definition. It will simplify auth if we do not have to update the properties too (which could be admin-level properties), and reduce the update to only the schema.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing unit test

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

No

@github-actions github-actions bot added the SQL label Jun 7, 2025
@szehon-ho szehon-ho force-pushed the SPARK-524167 branch 2 times, most recently from 4dca0ad to 4a7aced Compare June 7, 2025 01:23
@szehon-ho szehon-ho changed the title [SPARK-524167][SQL] Simplify Table properties handling in View Schema Evolution Mode [SPARK-52417][SQL] Simplify Table properties handling in View Schema Evolution Mode Jun 7, 2025
val viewQueryOutputColumns: JValue =
if (viewQueryColumnNames.nonEmpty) JArray(viewQueryColumnNames.map(JString).toList)
else JNull
val viewQueryOutputColumns: JValue = {
Copy link
Contributor Author

@szehon-ho szehon-ho Jun 7, 2025

Choose a reason for hiding this comment

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

This is for describe view query output.

Note we already seem to use the ViewSchema directly in the view resolution for SchemaEvolution mode: https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala#L991 iiuc

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.

1 participant