[default values] Add NestedField column-default APIs and Expressions.lit() (~upstream #9502) - #250
Conversation
…ream #9502) Hand-port the column default-value API from newer Iceberg onto the openhouse-1.2.0 branch (not a git cherry-pick). Types.NestedField: - Add initialDefault and writeDefault fields with initialDefault()/ writeDefault() accessors. - Add a NestedField.Builder (optional(name)/required(name)/from(field) + withId/ofType/withDoc/withInitialDefault/withWriteDefault/build). - castDefault() normalizes a supplied default to the field type via Expressions.lit(value).to(type).value(), and rejects non-null defaults on nested types. - equals() now compares both defaults; existing factory methods remain backward compatible (defaults are null). Expressions: - Add lit(value) returning Literals.from(value). By design, defaults are NOT serialized to metadata.json (SchemaParser is untouched); the API exists in-memory only as a foundation for the glue work to follow. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ion break Tests: - TestTypes: cover NestedField default-value API — builder construction, null defaults, initialDefault/writeDefault accessors, default casting to the field type (Long -> Integer via Expressions.lit), build() requires id, nested-type non-null default rejection, from() copy, asOptional/asRequired preserving defaults, and equals() distinguishing defaults. - TestExpressionHelpers: cover Expressions.lit() and lit().to(type) conversion. Build fix: - Accept the java.class.defaultSerializationChanged revapi break for Types.NestedField (adding initialDefault/writeDefault fields changes the default serialization id only), matching existing precedent in .palantir/revapi.yml. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…into openhouse-1.2.0-nestedfield-defaults # Conflicts: # .palantir/revapi.yml
|
thanks for the change!
General idea (which you've mostly followed): adapt only where 1.2 genuinely lacks the feature (the v3-only bits don't exist here); everything else should land as a copy from [0] tests: |
Re-baseline the column default-value feature onto upstream apache/iceberg:main (faithful copy, adapting only where 1.2 lacks the feature) instead of the narrower #9502 hand-port, and make it format-compatible end to end. - Types.NestedField: store defaults as Literal<?> (per main / #12211). Add withInitialDefault(Literal)/withWriteDefault(Literal) plus the deprecated Object overloads, initialDefaultLiteral()/writeDefaultLiteral(), and the builder() entry points from main. Drop the v3-only UnknownType check. castDefault now surfaces a clear "Cannot cast default value" error instead of NPE-ing on an invalid cast. - SchemaParser: backport main's toJson/fromJson so initial-default and write-default round-trip through the schema JSON (per #11832). Inert until a producer sets a default. (The catalog server strips these attributes before persisting to disk to preserve v2 compatibility.) - Tests: drop the bespoke api tests; add core TestSchemaParser with main's canonical testDocStrings + testPrimitiveTypeDefaultValues serialize->parse round-trip. Dropped the two v3-only TimestampNano rows from the provider. - revapi: keep the NestedField serialization-id accepted break; revert the unrelated BaseMetadataTable::table() reordering churn. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
great work, looks like the needed changes (and no more) are faithfully cherry picked from master. rollout is safe because no exiting client utilizes initial-default in any capacity, and in a future PR in openhouse catalog (direct consumer of this) we will strip the initial-default for v2 persisted tables. |
…s) (#642) Picks up [linkedin/iceberg#250](linkedin/iceberg#250) (released as `com.linkedin.iceberg` tag `v1.2.0.19`). ## Summary Bumps the Iceberg 1.2 line from `1.2.0.18` → `1.2.0.19`. The only change in `v1.2.0.19` is linkedin/iceberg#250, which re-baselines upstream's **column default-value API** (`Types.NestedField` initial/write defaults, `Expressions.lit()`, plus `SchemaParser` serialization) onto `openhouse-1.2.0`, bringing the 1.2 line to parity with the 1.5 line on this API. - Defaults are stored as `Literal<?>` with `withInitialDefault` / `withWriteDefault` builders and matching accessors (`initialDefault()` / `writeDefault()` / `*Literal()`). - `SchemaParser` serializes the defaults, so they are format-compatible end to end. - v3-only bits (e.g. `UnknownType`) are dropped since 1.2 lacks them; everything else is a faithful copy from upstream `main` rather than a cherry-pick. ## Changes - [ ] Client-facing API Changes - [ ] Internal API Changes - [ ] Bug Fixes - [ ] New Features - [ ] Performance Improvements - [ ] Code Style - [ ] Refactoring - [ ] Documentation - [ ] Tests Dependency version bump only — single line in `build.gradle`. The 1.5 line is already at its latest (`1.5.2.15`); this brings the 1.2 line to its latest within-line release. ## Testing Done - [ ] Manually Tested on local docker setup. - [ ] Added new tests for the changes made. - [ ] Updated existing tests to reflect the changes made. - [X] No tests added or updated. Tests for the new APIs live in linkedin/iceberg#250; this PR is a version bump. - [ ] Some other form of testing. # Additional Information - [ ] Breaking Changes - [ ] Deprecations
…ream #9502) (#251) Port the column default-value feature from upstream apache/iceberg:main onto the openhouse-1.5.2 branch (analog of the 1.2.x port in #250). Types.NestedField: - Store initial/write defaults as Literal<?> (per main / #12211). Add a NestedField.Builder (optional(name)/required(name)/from(field)/builder() + withId/ofType/withDoc/withInitialDefault/withWriteDefault/build), the deprecated Object overloads, and initialDefault()/writeDefault() plus the initialDefaultLiteral()/writeDefaultLiteral() accessors. - castDefault() normalizes a supplied default to the field type via to(type) and rejects non-null defaults on nested types, surfacing a clear "Cannot cast default value" error instead of NPE-ing on an invalid cast. - equals() now compares both defaults; existing factory methods remain backward compatible (defaults are null). Expressions: - Add lit(value) returning Literals.from(value). SchemaParser: - Backport main's toJson/fromJson so initial-default and write-default round-trip through the schema JSON (per #11832). Inert until a producer sets a default. Tests: - core TestSchemaParser with main's canonical testDocStrings + testPrimitiveTypeDefaultValues serialize->parse round-trip. revapi: - Accept the NestedField defaultSerializationChanged break (adding the initial/write default fields changes the default serialization id only). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
What
A faithful re-baseline of upstream
apache/iceberg:main's column default-value API ontoopenhouse-1.2.0— the API (Types.NestedFielddefaults,Expressions.lit()) plusSchemaParserserialization, so defaults are format-compatible end to end. Adapted only where 1.2 genuinely lacks the feature (v3-only bits are dropped); everything else lands as a copy frommain. Not agit cherry-pick.Types.NestedFieldLiteral<?>(permain/ #12211).withInitialDefault(Literal)/withWriteDefault(Literal)(+ deprecatedObjectoverloads),initialDefault()/writeDefault()value accessors,initialDefaultLiteral()/writeDefaultLiteral(), andmain'sbuilder()entry points.castDefaultsurfaces a clearCannot cast default valueerror instead of NPE-ing on an invalid cast.UnknownTypecheck.SchemaParsermain'stoJson/fromJson(per #11832) soinitial-default/write-defaultround-trip through the schema JSON.Scope
SchemaParserserialization.UpdateSchema, Avro, and reader wiring (the v3-only bits don't exist in 1.2).Testing
coreTestSchemaParser—main's canonicaltestDocStrings+testPrimitiveTypeDefaultValuesserialize→parse round-trip (the assertion that proves format compatibility), minus the two v3-onlyTimestampNanorows. 14 tests, 0 failures.:iceberg-api:testand schema-related:iceberg-coretests pass;:iceberg-api:revapiandspotlessCheckpass.revapi
Keeps the
NestedFieldserialization-id accepted break (still required, adding fields to aSerializableclass). No unrelated churn.🤖 Generated with Claude Code