geruh opened a new pull request, #2093:
URL: https://github.com/apache/iceberg-rust/pull/2093

   ## Summary
   
   The Python bindings expose partition values from manifest files via 
`PyPrimitiveLiteral.value()`, but this loses type information for certain types:
   
   - **Decimal**: `Int128` returns a Python `int`, losing scale information
   - **UUID**: `UInt128` returns a Python `int` instead of `uuid.UUID`
   
   This PR adds three methods to `PyPrimitiveLiteral`:
   
   | Method | Purpose |
   |--------|---------|
   | `decimal_value(scale)` | Convert `Int128` to `decimal.Decimal` with proper 
scale |
   | `uuid_value()` | Convert `UInt128` to `uuid.UUID` |
   | `literal_type()` | Return type name string for runtime type detection |
   
   ## Motivation
   
   This change is needed to support [pyiceberg PR 
#2004](https://github.com/apache/iceberg-python/pull/2004), which replaces 
Cython with iceberg-rust for manifest parsing. Without these methods, pyiceberg 
cannot properly reconstruct partition values with their correct Python types.
   
   ### Example Usage
   
   ```python
   from pyiceberg_core_rust import PyPrimitiveLiteral
   
   # When reading a Decimal(10, 2) partition field:
   literal = entry.data_file.partition[i]
   if literal.literal_type() == "int128":
       # Schema tells us scale=2
       value = literal.decimal_value(2)  # Returns Decimal("123.45")
   elif literal.literal_type() == "uint128":
       value = literal.uuid_value()  # Returns uuid.UUID
   else:
       value = literal.value()
   ```
   
   ## Related
   
   - Discussion: #2062
   - Complementary to #2063 (fastnum for 38-digit precision)


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