feat(datafusion): fill omitted INSERT columns with Iceberg write-default values#2804
Open
moomindani wants to merge 5 commits into
Open
feat(datafusion): fill omitted INSERT columns with Iceberg write-default values#2804moomindani wants to merge 5 commits into
moomindani wants to merge 5 commits into
Conversation
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.
Which issue does this PR close?
What changes are included in this PR?
Per the spec, writers must use a column's
write-defaultfor columns they do not supply. DataFusion's insert planner consultsTableProvider::get_column_defaultfor columns omitted from anINSERTand falls back toNULL;IcebergTableProviderdid not implement it, so tables withwrite-defaultvalues silently gotNULLs.IcebergTableProvidercaches the schema's top-levelwrite-defaultvalues as DataFusion expressions at construction and serves them viaget_column_default.literal_to_scalar_valueconversion covering the primitive types (boolean, int, long, float, double, string, date, time, timestamp/timestamptz in µs and ns, decimal, binary, fixed, uuid); defaults with no scalar representation are skipped. The planner casts the expression to the target arrow type, so representation differences are reconciled downstream.write-defaultas the engine column default (TypeToSparkType), and Spark materializes it at INSERT planning.Are these changes tested?
Yes — an end-to-end test (
INSERTomitting defaulted columns, then scanning to assert the defaults land and explicitly provided values win) plus unit tests for the literal conversion. The end-to-end test fails without theget_column_defaultimplementation.cargo test -p iceberg-datafusion --lib(90 tests) andcargo clippy -p iceberg-datafusion --lib --testspass locally.This pull request and its description were written by Claude Fable 5.