CircArgs opened a new pull request #3601:
URL: https://github.com/apache/iceberg/pull/3601


   Based off initial commentary in Issue #3464
   
   This pr looks to create a unified way of accessing types and interacting 
with literals.
   
   I think this will serve for better developer experience inside the library 
and outside. For example, see [transforms implemented very concisely using this 
type 
system](https://github.com/CircArgs/iceberg/blob/typed-transforms/python/src/iceberg/transforms.py)
 (and accompanying [PR into existing transforms 
pr](https://github.com/jun-he/incubator-iceberg/pull/4))
   
   - It includes a simple and intuitive api for describing even generic types 
as you would expect in the standard typing library such as `Decimal` where 
`Decimal[32, 3]` specifies a `Decimal` type with precision `32` and scale `3` 
or `List[Integer]` which specifies an Icerberg `List` type containing `Integer`s
   
   - It makes consistent the logic for checking if things are particular types 
whereas currently, `Decimal` and `Fixed` are actually instances. Now, 
`issubclass` and `==` can be used as intended throughout such as `assert 
Fixed[8]==Fixed[8]`
   
   - Types are implemented according to the spec including min, max for 
Integral types, IEEE-754 based floating types with the [correct sorting 
behavior](https://github.com/CircArgs/iceberg/blob/7c29ee28ade88c6f45954b2c547a02330c2df806/python/tests/test_types.py#L469)
 and 
[hashing](https://github.com/CircArgs/iceberg/blob/7c29ee28ade88c6f45954b2c547a02330c2df806/python/tests/test_types.py#L97)
   
   - Casting semantics are also fully implemented, so for example, `Decimal[32, 
3]('3.14').to(Decimal[33, 3])` and `Decimal[33, 3](Decimal[32, 3]('3.14'))` 
succeed while `Decimal[32, 3]('3.14').to(Decimal[31, 3])`  `Decimal[32, 
3]('3.14').to(Decimal[32, 2])`  `Decimal[32, 3]('3.14').to(Decimal[31, 3])` all 
fail 
   
   - Types are fully covariant. Besides `issubclass(Decimal[32, 3], 
Decimal)==True` we have `issubclass(List[Decimal[32, 3]], List[Decimal])==True` 
and `issubclass(List[Map[String, Decimal[32, 3]]], List[Map[IcebergType, 
Decimal[32, 3]]])==True`


-- 
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]

Reply via email to