Skip to content

Schema Deserialization Ignores Field initial-default and write-default Values #1431

@paulcichonski

Description

@paulcichonski

Apache Iceberg version

0.8.1 (latest release)

Please describe the bug 🐞

I have a simple Iceberg schema that looks like:

{
  "type": "struct",
  "fields": [
    {
      "id": 1,
      "name": "foo",
      "type": "string",
      "required": false,
      "initial-default": "foo-initial-default",
      "write-default": "foo-write-default"
    }
  ],
  "schema-id": 1
}

If I attempt to deserialize this into a pyiceberg.schema.Schema instance, it ignores the initial-default and write-default attributes:

from pyiceberg.schema import Schema

with open('/tmp/simple_schema.json', 'r') as f:
    s = Schema.model_validate_json(f.read())

print(s.fields)  # prints (NestedField(field_id=1, name='foo', field_type=StringType(), required=False),)
print(s.fields[0].initial_default)  # prints None
print(s.fields[0].write_default)  # prints None

Perhaps this is expected, but looking at the code, it seems like it should work.

If this is indeed a bug (and not expected or user error), I can work on trying to figure out why it is happening and submit a fix.

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions