iceberg-python icon indicating copy to clipboard operation
iceberg-python copied to clipboard

Include `initial-default` and `write-default` in repr

Open Fokko opened this issue 9 months ago • 3 comments

Feature Request / Improvement

Right now we don't show the initial-default and write-default in the repr of the NestedField. This is because we use it internally to deserialize the Iceberg metadata. With V3, this will also be exposed to the user. It would be good to include these in the repr if they are set. This will not change the repr for existing NestedFields, but it will show it for the ones that have an initial default. The first step would be to look into Pydantic if we can make this conditional.

Fokko avatar Mar 26 '25 09:03 Fokko

@Fokko Can I take a stab at implementing this ?

guptaakashdeep avatar Apr 18 '25 12:04 guptaakashdeep

please do @guptaakashdeep btw there are some somewhat relevant changes in https://github.com/apache/iceberg-python/pull/1770/files#diff-da13ee837fb063bfbb89e7c2b2016dafbe5b9c258286ffe948c370cc84d2c1b7R359-R377

kevinjqliu avatar Apr 19 '25 17:04 kevinjqliu

@kevinjqliu I looked into the mentioned PR. I can see Fokko has already finished changes for initial-default. 👍 I see some additional changes for write-default, are we planning to work separately on write-default or it'll be part of same PR ?

If Fokko is already working on write-default, I will follow along the changes as I am still getting familiar with codebase and following such changes will help me understand it better.

guptaakashdeep avatar Apr 19 '25 19:04 guptaakashdeep

These are the relevant lines:

https://github.com/apache/iceberg-python/blob/ccaa15cf8ac1eb1202256d17efc9cf9d20723d20/pyiceberg/types.py#L343-L344

Right now we never show them, but it would be nice to conditionally include them in the repr when they are not-null.

Fokko avatar Aug 04 '25 14:08 Fokko

Created #2287 to solve this. Unfortunately, Pydantic doesn't natively support this.

rambleraptor avatar Aug 05 '25 21:08 rambleraptor