-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Labels
bugstatus-triage_doneInitial triage done, will be further handled by the driver teamInitial triage done, will be further handled by the driver team
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:
snowflake-connector-python/src/snowflake/connector/converter.py
Lines 641 to 645 in 99bf619
def _decimal_to_snowflake(self, value: decimal.Decimal) -> str | None: | |
if isinstance(value, decimal.Decimal): | |
return str(value) | |
return None |
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
.
Metadata
Metadata
Assignees
Labels
bugstatus-triage_doneInitial triage done, will be further handled by the driver teamInitial triage done, will be further handled by the driver team