feat(evolution): support v3 column default values in UpdateSchema (3/4)#793
Open
huan233usc wants to merge 1 commit into
Open
feat(evolution): support v3 column default values in UpdateSchema (3/4)#793huan233usc wants to merge 1 commit into
huan233usc wants to merge 1 commit into
Conversation
AddColumn / AddRequiredColumn now accept an optional default value, used as both the initial-default and write-default of the new column; a non-null default also lets a required column be added (or an added column be made required) without AllowIncompatibleChanges(). UpdateColumnDefault sets or clears the write-default. Defaults are cast to the column type (rejecting uncastable or out-of-range values) and preserved across rename / doc / type updates and nested field-id reassignment. Part 4 of the v3 column-default-values work (POC apache#731), built on apache#746.
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
Part 3 of 4 of Iceberg v3 column default-value support (POC #731), built on the
schema-layer support merged in #746. Independent of the read-path PRs (#792 and
the Avro follow-up).
Adds default-value handling to
UpdateSchema(schema evolution).Changes
AddColumn/AddRequiredColumntake an optionaldefault_value. Whenprovided it is set as both the column's
initial-defaultandwrite-default.A non-null default also lets a required column be added without
AllowIncompatibleChanges()— rows written before the change read the defaultinstead of null.
UpdateColumnDefault(name, default)(new) sets, or clears withstd::nullopt, a column'swrite-default; theinitial-defaultis fixed whenthe column is added.
values) and preserved across rename / doc / type-promotion updates and
nested field-id reassignment.
RequireColumnmay now mark a column that was added with a default required.The
SchemaFieldconstructor stores defaults verbatim (it does not coercethem), so the cast/promotion is performed explicitly at each evolution site —
the same effect as Java, where
NestedField's constructor runscastDefault.Same-scale decimal precision widening is handled directly (the unscaled value is
unchanged), since
Literal::CastTodoes not cast between decimal types.Tests
13 cases in
update_schema_test.cc: add optional/required/nested column with adefault, mismatched/narrowing rejection,
UpdateColumnDefault(set / clear / cast-to-type / pre-existing column), require-after-default, and
preservation across doc updates and type promotion — including same-scale
decimal precision promotion.
Stack
addColumn/updateColumnDefault