You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2025/08/07 17:42:41 UTC

(iceberg-python) branch main updated: Pass in type explicitly for `initial-default` (#2296)

This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 00222a42 Pass in type explicitly for `initial-default` (#2296)
00222a42 is described below

commit 00222a42d54099897edb29e681f0f310c6cca654
Author: Fokko Driesprong <fo...@apache.org>
AuthorDate: Thu Aug 7 19:42:36 2025 +0200

    Pass in type explicitly for `initial-default` (#2296)
    
    # Rationale for this change
    
    I noticed we just passed in the value, without setting the type
    explicitly. By default, PyArrow will for example upscale 1 to an int64
    field, while the column is of type int32 in the table.
    
    # Are these changes tested?
    
    # Are there any user-facing changes?
    
    <!-- In the case of user-facing changes, please add the changelog label.
    -->
---
 pyiceberg/io/pyarrow.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyiceberg/io/pyarrow.py b/pyiceberg/io/pyarrow.py
index cee2ccac..2fdee174 100644
--- a/pyiceberg/io/pyarrow.py
+++ b/pyiceberg/io/pyarrow.py
@@ -1805,7 +1805,7 @@ class ArrowProjectionVisitor(SchemaWithPartnerVisitor[pa.Array, Optional[pa.Arra
                 elif 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)))
+                    field_arrays.append(pa.repeat(pa.scalar(field.initial_default, type=arrow_type), 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}")