You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "kevinjqliu (via GitHub)" <gi...@apache.org> on 2025/07/06 21:37:07 UTC
Re: [PR] Update schema projection to support `initial-defaults` [iceberg-python]
kevinjqliu commented on code in PR #1644:
URL: https://github.com/apache/iceberg-python/pull/1644#discussion_r2188646623
##########
pyiceberg/io/pyarrow.py:
##########
@@ -1814,9 +1814,12 @@ def struct(
array = self._cast_if_needed(field, field_array)
field_arrays.append(array)
fields.append(self._construct_field(field, array.type))
- elif field.optional:
+ elif field.optional or field.initial_default is not None:
arrow_type = schema_to_pyarrow(field.field_type, include_field_ids=self._include_field_ids)
- field_arrays.append(pa.nulls(len(struct_array), type=arrow_type))
+ if field.initial_default is None:
+ field_arrays.append(pa.nulls(len(struct_array), type=arrow_type))
+ else:
+ field_arrays.append(pa.repeat(field.initial_default, len(struct_array)))
fields.append(self._construct_field(field, arrow_type))
else:
raise ResolveError(f"Field is required, and could not be found in the file: {field}")
Review Comment:
> I don't think this is true, for V2 you can just add an optional field:
yea this is specifically for V3 tables
I took it from the section about struct evolution for default values:
<img width="722" alt="Screenshot 2025-07-06 at 2 36 15 PM" src="https://github.com/user-attachments/assets/1e49ae0b-a39c-46e8-9a3c-3d4ce7c3040c" />
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org