Skip to content

[SPARK-43752][SQL] Support column DEFAULT values in V2 write commands#55127

Open
LuciferYang wants to merge 1 commit intoapache:masterfrom
LuciferYang:SPARK-43752
Open

[SPARK-43752][SQL] Support column DEFAULT values in V2 write commands#55127
LuciferYang wants to merge 1 commit intoapache:masterfrom
LuciferYang:SPARK-43752

Conversation

@LuciferYang
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Resolve column DEFAULT references in V2 write commands (AppendData, OverwriteByExpression, OverwritePartitionsDynamic).

Previously, ResolveColumnDefaultInCommandInputQuery only handled InsertIntoStatement (V1 path) and SetVariable. V2 write commands with DEFAULT would fail with unresolved attribute errors.

Changes:

  • Analyzer.ResolveReferences: dispatch V2WriteCommand to resolveColumnDefaultInCommandInputQuery when the query contains unresolved attributes
  • ResolveColumnDefaultInCommandInputQuery: add V2WriteCommand case that resolves DEFAULT by matching query columns to the table schema by position
  • Remove the TODO (SPARK-43752) comment

Why are the changes needed?

INSERT INTO v2_table VALUES (1, DEFAULT) fails for V2 data sources even when the table has column default values defined. This blocks V2 adoption for catalogs that support SUPPORT_COLUMN_DEFAULT_VALUE.

Does this PR introduce any user-facing change?

Yes. DEFAULT keyword now works in INSERT INTO / INSERT OVERWRITE for V2 tables.

How was this patch tested?

  • Pass Github Actions
  • Added test in ResolveDefaultColumnsSuite

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

Generated-by: Claude Code 4.6

@LuciferYang
Copy link
Copy Markdown
Contributor Author

LuciferYang commented Apr 1, 2026

cc @cloud-fan @gengliangwang

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