partitioning
PartitionField
¶
Bases: IcebergBaseModel
PartitionField represents how one partition value is derived from the source column via transformation.
Attributes:
Name | Type | Description |
---|---|---|
source_id(int) |
The source column id of table's schema. |
|
field_id(int) |
The partition field id across all the table partition specs. |
|
transform(Transform) |
The transform used to produce partition values from source column. |
|
name(str) |
The name of this partition field. |
Source code in pyiceberg/partitioning.py
PartitionSpec
¶
Bases: IcebergBaseModel
PartitionSpec captures the transformation from table data to partition values.
Attributes:
Name | Type | Description |
---|---|---|
spec_id(int) |
any change to PartitionSpec will produce a new specId. |
|
fields(Tuple[PartitionField) |
list of partition fields to produce partition values. |
Source code in pyiceberg/partitioning.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
__eq__(other)
¶
Produce a boolean to return True if two objects are considered equal.
Note
Equality of PartitionSpec is determined by spec_id and partition fields only.
Source code in pyiceberg/partitioning.py
__repr__()
¶
Return the string representation of the PartitionSpec class.
__str__()
¶
Produce a human-readable string representation of PartitionSpec.
Note
Only include list of partition fields in the PartitionSpec's string representation.
Source code in pyiceberg/partitioning.py
compatible_with(other)
¶
Produce a boolean to return True if two PartitionSpec are considered compatible.
Source code in pyiceberg/partitioning.py
partition_type(schema)
¶
Produce a struct of the PartitionSpec.
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.
:param schema: The schema to bind to. :return: A StructType that represents the PartitionSpec, with a NestedField for each PartitionField.
Source code in pyiceberg/partitioning.py
PartitionSpecVisitor
¶
Bases: Generic[T]
, ABC
Source code in pyiceberg/partitioning.py
always_null(field_id, source_name, source_id)
abstractmethod
¶
bucket(field_id, source_name, source_id, num_buckets)
abstractmethod
¶
day(field_id, source_name, source_id)
abstractmethod
¶
hour(field_id, source_name, source_id)
abstractmethod
¶
identity(field_id, source_name, source_id)
abstractmethod
¶
month(field_id, source_name, source_id)
abstractmethod
¶
truncate(field_id, source_name, source_id, width)
abstractmethod
¶
unknown(field_id, source_name, source_id, transform)
abstractmethod
¶
partition_record_value(partition_field, value, schema)
¶
Return the Partition Record representation of the value.
The value is first converted to internal partition representation. For example, UUID is converted to bytes[16], DateType to days since epoch, etc.
Then the corresponding PartitionField's transform is applied to return the final partition record value.