Skip to content

Commit ae34a2d

Browse files
committed
Cleanup
1 parent a7c8370 commit ae34a2d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pyiceberg/io/pyarrow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,7 @@ def struct(
18151815
field_arrays.append(array)
18161816
fields.append(self._construct_field(field, array.type))
18171817
elif field.optional or field.initial_default is not None:
1818+
# When an optional field is added, or when a required field with a non-null initial default is added
18181819
arrow_type = schema_to_pyarrow(field.field_type, include_field_ids=self._include_field_ids)
18191820
if field.initial_default is None:
18201821
field_arrays.append(pa.nulls(len(struct_array), type=arrow_type))

tests/io/test_pyarrow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,13 +2400,13 @@ def test_identity_partition_on_multi_columns() -> None:
24002400

24012401
def test_initial_value() -> None:
24022402
# Have some fake data, otherwise it will generate a table without records
2403-
data = pa.record_batch([pa.nulls(10, pa.int32())], ["some_field"])
2403+
data = pa.record_batch([pa.nulls(10, pa.int64())], names=["some_field"])
24042404
result = _to_requested_schema(
2405-
Schema(NestedField(1, "so-true", BooleanType(), required=True, initial_default=True)), Schema(), data
2405+
Schema(NestedField(1, "we-love-22", LongType(), required=True, initial_default=22)), Schema(), data
24062406
)
2407-
assert result.column_names == ["so-true"]
2407+
assert result.column_names == ["we-love-22"]
24082408
for val in result[0]:
2409-
assert val.as_py() is True
2409+
assert val.as_py() == 22
24102410

24112411

24122412
def test__to_requested_schema_timestamps(

0 commit comments

Comments
 (0)