Fokko commented on code in PR #4526:
URL: https://github.com/apache/iceberg-python/pull/4526#discussion_r4737809753


##########
pyiceberg/io/pyarrow.py:
##########
@@ -922,10 +922,15 @@ def _literal_arrow_type(iceberg_type: IcebergType, 
values: Iterable[Any]) -> pa.
 
     A decimal literal can have more digits than the column, e.g. 1000.00 for 
decimal(5, 2),
     so the precision is widened to hold every literal. The scale always stays 
the column's.
+    Past the 38 digits of decimal128, e.g. 1 for decimal(38, 38), the literal 
is a decimal256
+    (up to 76 digits), which Arrow compares with the decimal128 column by 
value.
     """
     if isinstance(iceberg_type, DecimalType):
         digits = [len(value.as_tuple().digits) for value in values if 
isinstance(value, Decimal)]
-        return pa.decimal128(max([iceberg_type.precision, *digits]), 
iceberg_type.scale)
+        precision = max([iceberg_type.precision, *digits])
+        if precision > 38:
+            return pa.decimal256(precision, iceberg_type.scale)

Review Comment:
   Isn't this in conflict with the spec: 
https://iceberg.apache.org/spec/#primitive-types
   
   It explicitly states:
   
   > Scale is fixed, precision must be 38 or less



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