huan233usc opened a new pull request, #746:
URL: https://github.com/apache/iceberg-cpp/pull/746
Part 1 of 4 splitting #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 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<?>`). Getters
return
`std::optional<std::reference_wrapper<const Literal>>` (the
`Schema::FindFieldByName`
idiom). Copy-preserving modifiers (`WithInitialDefault` /
`WithWriteDefault` /
`WithIdAndType`) ensure reconstruction never silently drops a member.
- **Reconstruction-preservation**: every in-tree site that rebuilds a
`SchemaField`
(`ReassignField`, the `type_util` fresh-id / prune visitors,
`delete_filter`'s
`MergeField`) routes through `WithIdAndType`.
- **JSON serde**: parse/write `initial-default` / `write-default` using the
existing
single-value serialization (all primitive types).
- **`Schema::Validate`**: rejects default values below format v3
(`kMinFormatVersionDefaultValues`), and validates that a default is a
non-null
primitive literal 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
Full suite green. New coverage: schema serde round-trip (incl. nested +
mismatch
rejection), `Schema::Validate` v3 gating for both initial- and
write-default, type
mismatch rejection, generic projection of missing required/optional fields
with
defaults, and id-reassignment preserving defaults. New
`TableMetadataV3Valid.json`
test resource.
This pull request and its description were written by Isaac.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]