Commit 62e1bd8
authored
feat: support v3 column default values in UpdateSchema (#793)
## 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` / `AddRequiredColumn`** take an optional
`default_value`. When
provided it is set as both the column's `initial-default` and
`write-default`.
A non-null default also lets a required column be added without
`AllowIncompatibleChanges()` — rows written before the change read the
default
instead of null.
- **`UpdateColumnDefault(name, default)`** (new) sets, or clears with
`std::nullopt`, a column's `write-default`; the `initial-default` is
fixed when
the column is added.
- Defaults are **cast to the column type** (rejecting uncastable or
out-of-range
values) and **preserved** across rename / doc / type-promotion updates
and
nested field-id reassignment.
- `RequireColumn` may now mark a column that was added with a default
required.
The `SchemaField` constructor stores defaults verbatim (it does not
coerce
them), so the cast/promotion is performed explicitly at each evolution
site —
the same effect as Java, where `NestedField`'s constructor runs
`castDefault`.
Same-scale decimal precision widening is handled directly (the unscaled
value is
unchanged), since `Literal::CastTo` does not cast between decimal types.
## Tests
13 cases in `update_schema_test.cc`: add optional/required/nested column
with a
default, 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
1. #746 — schema: represent / serialize / validate (merged)
2. #792 — read path: Parquet
3. read path: Avro (follows)
4. **this PR** — schema evolution: `addColumn` / `updateColumnDefault`1 parent 3d5af47 commit 62e1bd8
9 files changed
Lines changed: 720 additions & 87 deletions
File tree
- src/iceberg
- test
- update
- util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
36 | | - | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
68 | 118 | | |
69 | 119 | | |
70 | 120 | | |
| |||
87 | 137 | | |
88 | 138 | | |
89 | 139 | | |
90 | | - | |
91 | | - | |
| 140 | + | |
92 | 141 | | |
93 | 142 | | |
94 | 143 | | |
| |||
97 | 146 | | |
98 | 147 | | |
99 | 148 | | |
100 | | - | |
101 | | - | |
| 149 | + | |
102 | 150 | | |
103 | 151 | | |
104 | 152 | | |
| |||
109 | 157 | | |
110 | 158 | | |
111 | 159 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 160 | + | |
116 | 161 | | |
117 | 162 | | |
118 | 163 | | |
119 | 164 | | |
120 | 165 | | |
121 | | - | |
122 | | - | |
| 166 | + | |
123 | 167 | | |
124 | 168 | | |
125 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 49 | + | |
| 50 | + | |
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
| |||
62 | 60 | | |
63 | 61 | | |
64 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
65 | 82 | | |
66 | | - | |
| 83 | + | |
67 | 84 | | |
68 | 85 | | |
69 | | - | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | | - | |
| 89 | + | |
73 | 90 | | |
74 | 91 | | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
78 | 95 | | |
79 | 96 | | |
80 | | - | |
81 | | - | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | | - | |
85 | | - | |
| 100 | + | |
86 | 101 | | |
87 | 102 | | |
88 | | - | |
| 103 | + | |
89 | 104 | | |
90 | 105 | | |
91 | 106 | | |
| |||
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
110 | | - | |
| 125 | + | |
111 | 126 | | |
112 | 127 | | |
113 | 128 | | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
117 | | - | |
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
110 | 173 | | |
0 commit comments