diff --git a/pyiceberg/conversions.py b/pyiceberg/conversions.py index 6b3d84135b..919bf44f6d 100644 --- a/pyiceberg/conversions.py +++ b/pyiceberg/conversions.py @@ -506,6 +506,10 @@ def _(_: DecimalType, val: Decimal) -> str: decimal point is used to indicate scale, for values with a negative scale, the scientific notation is used and the exponent must equal the negated scale. """ + exponent = val.as_tuple().exponent + if isinstance(exponent, int) and exponent <= 0: + # str() switches to scientific notation for small values, such as 0E-8 + return f"{val:f}" return str(val) diff --git a/tests/test_conversions.py b/tests/test_conversions.py index 8a6a8d3c84..8eb1b30604 100644 --- a/tests/test_conversions.py +++ b/tests/test_conversions.py @@ -578,6 +578,9 @@ def test_datetime_obj_to_bytes(primitive_type: PrimitiveType, value: datetime | (DecimalType(9, 4), Decimal("123.4500"), "123.4500"), (DecimalType(9, 0), Decimal("2"), "2"), (DecimalType(9, 9), Decimal("0.123456789"), "0.123456789"), + (DecimalType(20, 8), Decimal("0.00000000"), "0.00000000"), + (DecimalType(20, 8), Decimal("-0.00000012"), "-0.00000012"), + (DecimalType(38, 18), Decimal("0.000000000000000001"), "0.000000000000000001"), (DateType(), date(2017, 11, 16), "2017-11-16"), (TimeType(), time(22, 31, 8, 123456), "22:31:08.123456"), (TimestampType(), datetime(2017, 11, 16, 22, 31, 8, 123456), "2017-11-16T22:31:08.123456"),