Skip to content

Commit 0d87ef5

Browse files
committed
remove implementation for variant type, mark variant tests as skipped
1 parent b7b7fcb commit 0d87ef5

File tree

3 files changed

+7
-35
lines changed

3 files changed

+7
-35
lines changed

DESCRIPTION.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
2121
- Lower log levels from info to debug for some of the messages to make the output easier to follow.
2222
- Allow the connector to inherit a UUID4 generated upstream, provided in statement parameters (field: `requestId`), rather than automatically generate a UUID4 to use for the HTTP Request ID.
2323
- Fix expired S3 credentials update and increment retry when expired credentials are found.
24+
- Add `snowflake_type` parameter to execute method of a cursor. When set to `OBJECT` or `ARRAY` it allows binding of these semi-structured types.
2425

2526
- v3.14.0(March 03, 2025)
2627
- Bumped pyOpenSSL dependency upper boundary from <25.0.0 to <26.0.0.

src/snowflake/connector/connection.py

+5-35
Original file line numberDiff line numberDiff line change
@@ -1671,8 +1671,10 @@ def _get_snowflake_type_and_binding(
16711671
)
16721672

16731673
@staticmethod
1674-
def _is_semi_structured_type(snowflake_type: str):
1675-
return snowflake_type in ("OBJECT", "ARRAY", "VARIANT")
1674+
def _server_side_binding_supported(snowflake_type: str):
1675+
if snowflake_type == "VARIANT":
1676+
logger.warning("Server side binding for VARIANT type is not supported.")
1677+
return snowflake_type in ("OBJECT", "ARRAY")
16761678

16771679
def _process_server_side_semi_structured_bindings(
16781680
self, cursor: SnowflakeCursor | None, params: Sequence, snowflake_type: str
@@ -1727,38 +1729,6 @@ def _process_server_side_semi_structured_bindings(
17271729
"errno": ER_NOT_SUPPORT_DATA_TYPE,
17281730
},
17291731
)
1730-
elif snowflake_type == "VARIANT":
1731-
snowflake_type = "TEXT"
1732-
for idx, v in enumerate(params):
1733-
if isinstance(v, str) or v is None:
1734-
processed_params[str(idx + 1)] = {
1735-
"type": snowflake_type,
1736-
"fmt": "json",
1737-
"value": v,
1738-
}
1739-
else:
1740-
value = None
1741-
try:
1742-
value = json.dumps(v)
1743-
except TypeError:
1744-
Error.errorhandler_wrapper(
1745-
self,
1746-
cursor,
1747-
ProgrammingError,
1748-
{
1749-
"msg": "Attempted to insert value {} as {} but the it's of an unsupported type: {}.".format(
1750-
v, snowflake_type, type(v)
1751-
),
1752-
"errno": ER_NOT_SUPPORT_DATA_TYPE,
1753-
},
1754-
)
1755-
1756-
if value is not None:
1757-
processed_params[str(idx + 1)] = {
1758-
"type": snowflake_type,
1759-
"fmt": "json",
1760-
"value": value,
1761-
}
17621732

17631733
return processed_params
17641734

@@ -1773,7 +1743,7 @@ def _process_params_qmarks(
17731743
return None
17741744
processed_params = {}
17751745

1776-
if self._is_semi_structured_type(snowflake_type):
1746+
if self._server_side_binding_supported(snowflake_type):
17771747
processed_params = self._process_server_side_semi_structured_bindings(
17781748
cursor, params, snowflake_type
17791749
)

test/integ/test_bindings.py

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ def test_binding_insert_date(conn_cnx, db_parameters):
492492

493493
@pytest.mark.skipolddriver
494494
def test_binding_variant(conn_cnx):
495+
pytest.skip("Server side binding of VARIANT type is not supported")
495496
bind_query = "INSERT INTO TEST_TABLE1 SELECT (?)"
496497
with conn_cnx(paramstyle="qmark") as cnx, cnx.cursor() as cursor:
497498
snowflake_type = "VARIANT"

0 commit comments

Comments
 (0)