Skip to content

Commit 0ab3262

Browse files
authored
Allow Partition data to be nullable in ManifestEntry (#509)
* fix * use partition field nullability
1 parent a222825 commit 0ab3262

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

pyiceberg/manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def data_file_with_partition(partition_type: StructType, format_version: Literal
308308
field_id=field.field_id,
309309
name=field.name,
310310
field_type=partition_field_to_data_file_partition_field(field.field_type),
311+
required=field.required,
311312
)
312313
for field in partition_type.fields
313314
])

pyiceberg/partitioning.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ def partition_type(self, schema: Schema) -> StructType:
218218
for field in self.fields:
219219
source_type = schema.find_type(field.source_id)
220220
result_type = field.transform.result_type(source_type)
221-
nested_fields.append(NestedField(field.field_id, field.name, result_type, required=False))
221+
required = schema.find_field(field.source_id).required
222+
nested_fields.append(NestedField(field.field_id, field.name, result_type, required=required))
222223
return StructType(*nested_fields)
223224

224225
def partition_to_path(self, data: Record, schema: Schema) -> str:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ def metadata_location_gz(tmp_path_factory: pytest.TempPathFactory) -> str:
892892
"data_file": {
893893
"file_path": "/home/iceberg/warehouse/nyc/taxis_partitioned/data/VendorID=1/00000-633-d8a4223e-dc97-45a1-86e1-adaba6e8abd7-00002.parquet",
894894
"file_format": "PARQUET",
895-
"partition": {"VendorID": 1, "tpep_pickup_datetime": 1925},
895+
"partition": {"VendorID": 1, "tpep_pickup_datetime": None},
896896
"record_count": 95050,
897897
"file_size_in_bytes": 1265950,
898898
"block_size_in_bytes": 67108864,

tests/table/test_partitioning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,5 @@ def test_partition_type(table_schema_simple: Schema) -> None:
127127

128128
assert spec.partition_type(table_schema_simple) == StructType(
129129
NestedField(field_id=1000, name="str_truncate", field_type=StringType(), required=False),
130-
NestedField(field_id=1001, name="int_bucket", field_type=IntegerType(), required=False),
130+
NestedField(field_id=1001, name="int_bucket", field_type=IntegerType(), required=True),
131131
)

0 commit comments

Comments
 (0)