snowflakedb / snowflakedb/snowflake-connector-python
SNOW-2248950: converter.py: parameter binding for decimal.Decimal produces incorrect SQL
@sfc-gh-snow-drivers-warsaw-dl is already working on this.
Since Aug 11, 2025.
- Dominant language
- Python
- Stars
- 730
- Forks
- 574
- Avg merge
- 5h 45m
- Merged PRs (30d)
- 16
Description
Python version
3.11.6
Operating system and processor architecture
macOS-15.5-arm64-arm-64bit
Installed packages
snowflake-connector-python==3.15.0
snowflake-sqlalchemy==1.7.3
What did you do?
engine = sa.create_engine(...)
with engine.connect() as conn:
result = conn.execute(sa.select(sa.literal(decimal.Decimal('1.3'))))
resval = result.fetchone()
assert resval == '1.3' # True - the SQL executed will be `SELECT '1.3'`, so it will return a string literal.
This is caused by:
https://github.com/snowflakedb/snowflake-connector-python/blob/99bf6197a8e3032fb49d35701956a9f7506d8e8f/src/snowflake/connector/converter.py#L641-L645
What did you expect to see?
I expect this query to be executed as SELECT 1.3, not SELECT '1.3'. The bind parameter value of decimal.Decimal('1.3') is not being correctly rendered as a NUMBER contstant/literal. If the decimal.Decimal value was being correctly rendered during client-side parameter binding, then a numeric value (either float or, preferably decimal.Decimal) would be returned, not a str.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.