Skip to content

Commit 8b0c5ac

Browse files
committed
Support decimal encoding of NaN and Infinities values
1 parent 9af0b31 commit 8b0c5ac

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

trino.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def _trino_error_result(e: BaseException):
4444
def _decimal_to_string(value: Decimal):
4545
if not isinstance(value, Decimal):
4646
raise ValueError('Not a Decimal: ' + type(value).__name__)
47-
if not value.is_finite():
48-
raise ValueError('Decimal is not finite: ' + str(value))
47+
if value.is_nan():
48+
return "NaN"
49+
if value.is_infinite():
50+
if value.is_signed():
51+
return "-Infinity"
52+
return "Infinity"
4953
return "{:f}".format(value)

0 commit comments

Comments
 (0)