You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: represent, serialize and validate v3 column default values (#746)
Part 1 of a multi-part split of #730 (column default values, item 2 of
#637). The full
end-to-end implementation is in #731, kept open as the proof-of-concept;
this series
lands it in reviewable pieces.
This PR is the **schema foundation** — representing, serializing and
validating v3
column default values. It is purely additive and changes no read or
write behavior on
its own.
## What's in this PR
- **`SchemaField`** carries `initial-default` / `write-default`, stored
as
`std::shared_ptr<const Literal>` (immutable payload shared across
copies, like the
adjacent `type_`; the C++ analog of Java's `final Literal<?>`). They are
set via the
constructor. Getters return `std::optional<std::reference_wrapper<const
Literal>>` for
reading (the `Schema::FindFieldByName` idiom); `initial_default_ptr()` /
`write_default_ptr()` expose the shared pointer so a rebuilt field (e.g.
ID
reassignment) shares the value instead of copying it.
- **JSON serde**: parse/write `initial-default` / `write-default` using
the existing
single-value serialization (all primitive types).
- **`Schema::Validate`**: version-gates the `initial-default` to format
v3
(`kMinFormatVersionDefaultValues`) — it reinterprets how existing data
files are read,
so it requires the v3 reader contract. The `write-default` only affects
values written
going forward and is **not** version-gated (matching Java's
`Schema.checkCompatibility`,
which gates only the initial default). Both defaults are otherwise
validated to be
non-null primitive literals matching the field type.
- **Generic projection**: a column missing from a data file with an
`initial-default`
maps to `FieldProjection::Kind::kDefault` carrying the literal (the
per-format readers
consume this in the follow-up PRs).
## Follow-ups (stacked on this PR)
- read path — Parquet (`literal_util` + parquet
projection/materialization)
- read path — Avro
- schema evolution (`UpdateSchema` add/update column defaults)
## Testing
Added tests
0 commit comments