diff --git a/src/firebolt/common/_types.py b/src/firebolt/common/_types.py index d3653f93ea1..3efbf7b3926 100644 --- a/src/firebolt/common/_types.py +++ b/src/firebolt/common/_types.py @@ -343,6 +343,10 @@ def parse_value( if isinstance(ctype, DECIMAL): if not isinstance(value, (str, int, float)): raise DataError(f"Invalid decimal value {value}: str or int expected") + if isinstance(value, float): + # Decimal constructor doesn't support float + # so we need to convert it to string first + value = str(value) return Decimal(value) if isinstance(ctype, ARRAY): if not isinstance(value, list): diff --git a/tests/unit/common/test_typing_parse.py b/tests/unit/common/test_typing_parse.py index 8d24155c6f9..54e3281a969 100644 --- a/tests/unit/common/test_typing_parse.py +++ b/tests/unit/common/test_typing_parse.py @@ -219,13 +219,14 @@ def test_parse_value_datetime_errors() -> None: [ ("123.456", Decimal("123.456")), (123, Decimal("123")), + (123.456, Decimal("123.456")), (None, None), ], ) def test_parse_decimal(value, expected) -> None: assert ( parse_value(value, DECIMAL(38, 3)) == expected - ), "Error parsing decimal(38, 3): provided {value}, expected {expected}" + ), f"Error parsing decimal(38, 3): provided {value}, expected {expected}" @mark.parametrize(