Skip to content

Commit e3dab82

Browse files
committed
remove implementation for variant type, mark variant tests as skipped
1 parent 7aaf1d2 commit e3dab82

File tree

3 files changed

+7
-35
lines changed

3 files changed

+7
-35
lines changed

DESCRIPTION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
2323
- 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.
2424
- Fix expired S3 credentials update and increment retry when expired credentials are found.
2525
- Added `client_fetch_threads` experimental parameter to better utilize threads for fetching query results.
26+
- Add `snowflake_type` parameter to execute method of a cursor. When set to `OBJECT` or `ARRAY` it allows binding of these semi-structured types.
2627

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

src/snowflake/connector/connection.py

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,8 +1782,10 @@ def _get_snowflake_type_and_binding(
17821782
)
17831783

17841784
@staticmethod
1785-
def _is_semi_structured_type(snowflake_type: str):
1786-
return snowflake_type in ("OBJECT", "ARRAY", "VARIANT")
1785+
def _server_side_binding_supported(snowflake_type: str):
1786+
if snowflake_type == "VARIANT":
1787+
logger.warning("Server side binding for VARIANT type is not supported.")
1788+
return snowflake_type in ("OBJECT", "ARRAY")
17871789

17881790
def _process_server_side_semi_structured_bindings(
17891791
self, cursor: SnowflakeCursor | None, params: Sequence, snowflake_type: str
@@ -1838,38 +1840,6 @@ def _process_server_side_semi_structured_bindings(
18381840
"errno": ER_NOT_SUPPORT_DATA_TYPE,
18391841
},
18401842
)
1841-
elif snowflake_type == "VARIANT":
1842-
snowflake_type = "TEXT"
1843-
for idx, v in enumerate(params):
1844-
if isinstance(v, str) or v is None:
1845-
processed_params[str(idx + 1)] = {
1846-
"type": snowflake_type,
1847-
"fmt": "json",
1848-
"value": v,
1849-
}
1850-
else:
1851-
value = None
1852-
try:
1853-
value = json.dumps(v)
1854-
except TypeError:
1855-
Error.errorhandler_wrapper(
1856-
self,
1857-
cursor,
1858-
ProgrammingError,
1859-
{
1860-
"msg": "Attempted to insert value {} as {} but the it's of an unsupported type: {}.".format(
1861-
v, snowflake_type, type(v)
1862-
),
1863-
"errno": ER_NOT_SUPPORT_DATA_TYPE,
1864-
},
1865-
)
1866-
1867-
if value is not None:
1868-
processed_params[str(idx + 1)] = {
1869-
"type": snowflake_type,
1870-
"fmt": "json",
1871-
"value": value,
1872-
}
18731843

18741844
return processed_params
18751845

@@ -1884,7 +1854,7 @@ def _process_params_qmarks(
18841854
return None
18851855
processed_params = {}
18861856

1887-
if self._is_semi_structured_type(snowflake_type):
1857+
if self._server_side_binding_supported(snowflake_type):
18881858
processed_params = self._process_server_side_semi_structured_bindings(
18891859
cursor, params, snowflake_type
18901860
)

test/integ/test_bindings.py

Lines changed: 1 addition & 0 deletions
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)