-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'0E-10' is not a valid decimal literal
#347
Comments
The issue seems to be with the Trino server not recognizing the decimal literal '0E-10' as a valid decimal. One possible solution is to represent the decimal as a string instead of using scientific notation. You can try changing the query parameter to the string '0.0', which should be equivalent to the decimal 0E-10. Another solution could be to update the Trino server to recognize scientific notation for decimals, if possible. If you are willing to submit a pull request, you can also try to update the Trino Python client to handle scientific notation for decimals. |
In the Trino Python client, we're doing the Decimal conversion here:
I was thinking of just converting the Decimal to a float and using the same logic for floats which is here:
My only issue with doing that is I don't know the difference between
But I'm just not sure. |
Trino implicitly converts literals with scientific notation to DOUBLE. DECIMAL literals cannot use scientific notation. Maybe we can detect this on the Python client side and normalize the literal to use decimal instead of scientific notation. |
Expected behavior
In Python, Decimals can be represented with
e
orE
(e.g.Decimal('0E-10')
). When the Trino client receives a Decimal like this one, it should successfully convert the value to something Trino can process.Actual behavior
Given a basic sql query (
SELECT ?
) with the param ([Decimal('0E-10')]
), the Trino client prepared and executed the following:which results in the following error:
Steps To Reproduce
Log output
I've attached the
.json
output from the Trino UI.query.json.txt
Operating System
RHEL
Trino Python client version
0.321.0
Trino Server version
405
Python version
Python 3.9.13
Are you willing to submit PR?
The text was updated successfully, but these errors were encountered: