Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ def _trino_error_result(e: BaseException):
def _decimal_to_string(value: Decimal):
if not isinstance(value, Decimal):
raise ValueError('Not a Decimal: ' + type(value).__name__)
if not value.is_finite():
raise ValueError('Decimal is not finite: ' + str(value))
if value.is_nan():
return "NaN"
if value.is_infinite():
if value.is_signed():
return "-Infinity"
return "Infinity"
Comment on lines +48 to +52
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are valid values for Trino NUMBER but not for DECIMAL.
If we return NaN for decimal, this should fail somewhere later. I think for DECIMALs it's better to keep failing here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since decimal is shared between decimal and number I think it's better to fail in Trino once nan or infinity is returned for Decimal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return "{:f}".format(value)
Loading