-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
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.12.10
Operating system and processor architecture
macOS-15.4.1-x86_64-i386-64bit
Installed packages
snowflake-connector-python 3.15.0
snowflake-sqlalchemy 1.7.3
SQLAlchemy 1.4.54What did you do?
I am trying to run a query like this:
business_uuid = UUID("4363f57d-c9ca-4e63-92c7-3e67786c8a30")
user_uuid = UUID("4363f57d-c9ca-4e63-92c7-3e67786c8a30")
stmt = text(
"SELECT * FROM users WHERE business_uuid = :business_uuid AND user_uuid IN [:user_uuids]"
)
conn.cursor().execute(
stmt,
params={"business_uuid": business_uuid.bytes, "user_uuids": [user_uuid.bytes]},
)But it is throwing the following error:
.venv/lib/python3.12/site-packages/snowflake/connector/connection.py:1867: in _process_single_param
return _quote(escape(to_snowflake(param)))
.venv/lib/python3.12/site-packages/snowflake/connector/converter.py:483: in to_snowflake
return getattr(self, f"_{type_name}_to_snowflake")(value)
.venv/lib/python3.12/site-packages/snowflake/connector/converter.py:626: in _list_to_snowflake
SnowflakeConverter.quote(v0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = b';\xe7\x0czb\xa8Kd\xad\x87|G\xae\x8b\xfcM'
@staticmethod
def quote(value) -> str:
if isinstance(value, list):
return ",".join(value)
if value is None:
return "NULL"
elif isinstance(value, bool):
return "TRUE" if value else "FALSE"
elif IS_NUMERIC(value):
return str(repr(value))
elif IS_BINARY(value):
# Binary literal syntax
> return "X'{}'".format(value.decode("ascii"))
E UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 1: ordinal not in range(128)
.venv/lib/python3.12/site-packages/snowflake/connector/converter.py:722: UnicodeDecodeError
For the single business param, to_snowflake is called on the value which results in _bytes_to_snowflake and therefore binary_to_snowflake being called on the value.
For in the case of the list, the to_snowflake call isn't called per each list item, and therefore to_snowflake isn't called.
What did you expect to see?
I expect the list of uuid bytes to be converted properly without error.
Can you set logging to DEBUG and collect the logs?
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