rdblue commented on code in PR #5929:
URL: https://github.com/apache/iceberg/pull/5929#discussion_r989537398
##########
python/tests/table/test_partitioning.py:
##########
@@ -102,3 +109,16 @@ def test_deserialize_partition_spec():
PartitionField(source_id=2, field_id=1001,
transform=BucketTransform(num_buckets=25), name="int_bucket"),
),
)
+
+
+def test_partition_type(table_schema_simple: Schema) -> None:
+ spec = PartitionSpec(
+ PartitionField(source_id=1, field_id=1000,
transform=TruncateTransform(width=19), name="str_truncate"),
+ PartitionField(source_id=2, field_id=1001,
transform=BucketTransform(num_buckets=25), name="int_bucket"),
+ spec_id=3,
+ )
+
+ assert spec.partition_type(table_schema_simple) == StructType(
+ NestedField(field_id=1000, name="str_truncate",
field_type=StringType(), required=True),
+ NestedField(field_id=1001, name="int_bucket",
field_type=IntegerType(), required=True),
Review Comment:
The partition fields should be optional.
* All partition transforms are required to produce `null` if the input value
is `null`, so it can happen when the source column is optional
* Partition fields may be added later, in which case not all files would
have the result field and it may be `null`
There is a case where we can guarantee that a partition field in the first
and only partition spec that uses a required source column will never be null,
but it doesn't seem worth tracking this case.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]