transforms
BucketTransform
¶
Bases: Transform[S, int]
Base Transform class to transform a value into a bucket partition value.
Transforms are parameterized by a number of buckets. Bucket partition transforms use a 32-bit hash of the source value to produce a positive value by mod the bucket number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_buckets
|
int
|
The number of buckets. |
required |
Source code in pyiceberg/transforms.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
DayTransform
¶
Bases: TimeTransform[S]
Transforms a datetime value into a day value.
Example
transform = DayTransform() transform.transform(DateType())(17501) 17501
Source code in pyiceberg/transforms.py
__repr__()
¶
result_type(source)
¶
Return the result type of a day transform.
The physical representation conforms to the Iceberg spec as DateType is internally converted to int. The DateType returned here provides a more human-readable way to display the partition field.
Source code in pyiceberg/transforms.py
HourTransform
¶
Bases: TimeTransform[S]
Transforms a datetime value into a hour value.
Example
transform = HourTransform() transform.transform(TimestampType())(1512151975038194) 420042
Source code in pyiceberg/transforms.py
IdentityTransform
¶
Bases: Transform[S, S]
Transforms a value into itself.
Example
transform = IdentityTransform() transform.transform(StringType())('hello-world') 'hello-world'
Source code in pyiceberg/transforms.py
MonthTransform
¶
Bases: TimeTransform[S]
Transforms a datetime value into a month value.
Example
transform = MonthTransform() transform.transform(DateType())(17501) 575
Source code in pyiceberg/transforms.py
Transform
¶
Bases: IcebergRootModel[str]
, ABC
, Generic[S, T]
Transform base class for concrete transforms.
A base class to transform values and project predicates on partition values. This class is not used directly. Instead, use one of module method to create the child classes.
Source code in pyiceberg/transforms.py
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 |
|
__eq__(other)
¶
Return the equality of two instances of the Transform class.
__str__()
¶
result_type(source)
abstractmethod
¶
Return the IcebergType
produced by this transform given a source type.
This method defines both the physical and display representation of the partition field.
The physical representation must conform to the Iceberg spec. The display representation can deviate from the spec, such as by transforming the value into a more human-readable format.
Source code in pyiceberg/transforms.py
TruncateTransform
¶
Bases: Transform[S, S]
A transform for truncating a value to a specified width.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width
|
int
|
The truncate width, should be positive. |
required |
Raises: ValueError: If a type is provided that is incompatible with a Truncate transform.
Source code in pyiceberg/transforms.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 |
|
UnknownTransform
¶
Bases: Transform[S, T]
A transform that represents when an unknown transform is provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transform
|
str
|
A string name of a transform. |
required |
Other Parameters:
Name | Type | Description |
---|---|---|
source_type |
IcebergType
|
An Iceberg |
Source code in pyiceberg/transforms.py
VoidTransform
¶
Bases: Transform[S, None]
, Singleton
A transform that always returns None.
Source code in pyiceberg/transforms.py
YearTransform
¶
Bases: TimeTransform[S]
Transforms a datetime value into a year value.
Example
transform = YearTransform() transform.transform(TimestampType())(1512151975038194) 47
Source code in pyiceberg/transforms.py
_base64encode(buffer)
¶
_transform_literal(func, lit)
¶
Small helper to upwrap the value from the literal, and wrap it again.