[SPARK-58273][SQL] Do not auto-fill generated columns for by-position schema evolution inserts#57441
Open
szehon-ho wants to merge 1 commit into
Open
Conversation
… schema evolution inserts
HyukjinKwon
approved these changes
Jul 22, 2026
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?
This PR updates
TableOutputResolversoINSERT WITH SCHEMA EVOLUTIONby position does not auto-fill trailing generated columns. If a by-position insert omits a trailing generated column, Spark now throws the same arity mismatch error as a regular by-position insert.The PR also adds coverage that:
INSERT WITH SCHEMA EVOLUTIONrejects an omitted trailing generated column;INSERT WITH SCHEMA EVOLUTIONwith an explicit column list still auto-fills the generated column.Why are the changes needed?
By-position writes require values for all target columns. Generated columns are special because users can omit them only through by-name writes with an explicit column list, where Spark can unambiguously identify the stored input columns used by the generation expression.
Without this change, the by-position schema-evolution path could auto-fill a trailing generated column, making it inconsistent with regular by-position inserts and with Delta behavior.
Does this PR introduce any user-facing change?
Yes. In the current unreleased behavior, a by-position
INSERT WITH SCHEMA EVOLUTIONcould omit a trailing generated column and have Spark auto-fill it. After this change, that insert fails withINSERT_COLUMN_ARITY_MISMATCH.NOT_ENOUGH_DATA_COLUMNS. Users can still omit generated columns with a by-name insert and an explicit column list.How was this patch tested?
Added a regression test in
GeneratedColumnWriteSuite.Ran:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)