soda-sqlserver 4.30.0__tar.gz → 4.31.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/PKG-INFO +2 -2
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/pyproject.toml +2 -2
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver/common/data_sources/sqlserver_data_source_connection.py +25 -14
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver/test_helpers/sqlserver_data_source_test_helper.py +5 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/PKG-INFO +2 -2
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/requires.txt +1 -1
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/setup.cfg +0 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver/common/data_sources/sqlserver_data_source.py +0 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/SOURCES.txt +0 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/dependency_links.txt +0 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/entry_points.txt +0 -0
- {soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: soda-sqlserver
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.31.0
|
|
4
4
|
Summary: Soda SQL Server V4
|
|
5
5
|
Author-email: "Soda Data N.V." <info@soda.io>
|
|
6
6
|
License: Proprietary
|
|
7
7
|
Requires-Python: >=3.10
|
|
8
|
-
Requires-Dist: soda-core==4.
|
|
8
|
+
Requires-Dist: soda-core==4.31.0
|
|
9
9
|
Requires-Dist: pyodbc
|
|
10
10
|
Requires-Dist: azure-identity<2,>=1.17.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "soda-sqlserver"
|
|
3
|
-
version = "4.
|
|
3
|
+
version = "4.31.0"
|
|
4
4
|
description = "Soda SQL Server V4"
|
|
5
5
|
requires-python = ">=3.10"
|
|
6
6
|
license = {text = "Proprietary"}
|
|
@@ -8,7 +8,7 @@ authors = [
|
|
|
8
8
|
{name = "Soda Data N.V.", email = "info@soda.io"}
|
|
9
9
|
]
|
|
10
10
|
dependencies = [
|
|
11
|
-
"soda-core==4.
|
|
11
|
+
"soda-core==4.31.0",
|
|
12
12
|
"pyodbc",
|
|
13
13
|
"azure-identity>=1.17.1,<2",
|
|
14
14
|
]
|
|
@@ -231,8 +231,13 @@ class SqlServerDataSourceConnection(DataSourceConnection):
|
|
|
231
231
|
# few times before the error is propagated. The pause is drawn uniformly from
|
|
232
232
|
# an exponentially growing window (full jitter) so that the parties of a killed
|
|
233
233
|
# deadlock don't retry in lockstep and immediately deadlock again.
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
# Under snapshot isolation, which Fabric always uses, a statement that reads
|
|
235
|
+
# an object that another session changed with DDL since the transaction
|
|
236
|
+
# started fails with error 3961. A catalog scan such as INFORMATION_SCHEMA.TABLES
|
|
237
|
+
# reads every object in the database, so DDL anywhere in it can trigger this.
|
|
238
|
+
# Rerunning the statement starts a fresh snapshot, so it is retried the same way.
|
|
239
|
+
CONFLICT_MAX_ATTEMPTS: int = 3
|
|
240
|
+
CONFLICT_RETRY_BACKOFF_SECONDS: float = 0.1
|
|
236
241
|
|
|
237
242
|
def __init__(self, name: str, connection_properties: DataSourceConnectionProperties):
|
|
238
243
|
# Set before super().__init__(), which auto-opens the connection and
|
|
@@ -243,46 +248,52 @@ class SqlServerDataSourceConnection(DataSourceConnection):
|
|
|
243
248
|
|
|
244
249
|
def execute_query(self, sql: str, log_query: bool = True) -> QueryResult:
|
|
245
250
|
execute = super().execute_query
|
|
246
|
-
return self.
|
|
251
|
+
return self._execute_with_conflict_retry(lambda: execute(sql, log_query))
|
|
247
252
|
|
|
248
253
|
def execute_update(self, sql: str, log_query: bool = True) -> int:
|
|
249
254
|
execute = super().execute_update
|
|
250
|
-
return self.
|
|
255
|
+
return self._execute_with_conflict_retry(lambda: execute(sql, log_query))
|
|
251
256
|
|
|
252
257
|
@staticmethod
|
|
253
|
-
def
|
|
258
|
+
def _is_retryable_conflict_error(e: pyodbc.Error) -> bool:
|
|
254
259
|
# pyodbc error args are (sqlstate, message); 40001 is the serialization
|
|
255
260
|
# failure SQLSTATE that SQL Server raises for deadlock victims (1205).
|
|
256
|
-
|
|
261
|
+
# The snapshot isolation DDL conflict (3961) comes with the generic SQLSTATE
|
|
262
|
+
# 42000, so it is recognised by the native error number in the message.
|
|
263
|
+
if not e.args:
|
|
264
|
+
return False
|
|
265
|
+
if e.args[0] == "40001":
|
|
266
|
+
return True
|
|
267
|
+
return e.args[0] == "42000" and len(e.args) > 1 and "(3961)" in str(e.args[1])
|
|
257
268
|
|
|
258
269
|
@staticmethod
|
|
259
270
|
def _is_login_failed_error(e: pyodbc.Error) -> bool:
|
|
260
271
|
# 28000 is the invalid authorization SQLSTATE that SQL Server raises for a rejected login (18456).
|
|
261
272
|
return bool(e.args) and e.args[0] == "28000"
|
|
262
273
|
|
|
263
|
-
def
|
|
274
|
+
def _execute_with_conflict_retry(self, operation: Callable[[], T]) -> T:
|
|
264
275
|
"""Assumes ``operation`` is a single-statement unit of work: recovery
|
|
265
276
|
issues a connection-wide rollback, discarding any earlier uncommitted
|
|
266
277
|
statements on this connection (SQL Server runs autocommit=False).
|
|
267
278
|
Only the buffered paths (execute_query/execute_update) are wrapped;
|
|
268
279
|
the callback/iterator paths (execute_query_one_by_one*,
|
|
269
|
-
execute_query_iterate) may have already delivered rows when a
|
|
280
|
+
execute_query_iterate) may have already delivered rows when a conflict
|
|
270
281
|
strikes mid-fetch, so re-executing them would double-process rows."""
|
|
271
|
-
for attempt in range(1, max(self.
|
|
282
|
+
for attempt in range(1, max(self.CONFLICT_MAX_ATTEMPTS, 1) + 1):
|
|
272
283
|
try:
|
|
273
284
|
return operation()
|
|
274
285
|
except pyodbc.Error as e:
|
|
275
|
-
if not self.
|
|
286
|
+
if not self._is_retryable_conflict_error(e) or attempt == self.CONFLICT_MAX_ATTEMPTS:
|
|
276
287
|
raise
|
|
277
288
|
logger.warning(
|
|
278
|
-
f"
|
|
279
|
-
f"(attempt {attempt}/{self.
|
|
289
|
+
f"Concurrency conflict on '{self.name}' "
|
|
290
|
+
f"(attempt {attempt}/{self.CONFLICT_MAX_ATTEMPTS}), retrying: {e}"
|
|
280
291
|
)
|
|
281
292
|
try:
|
|
282
293
|
self.rollback()
|
|
283
294
|
except Exception as rollback_error:
|
|
284
|
-
logger.warning(f"Rollback after
|
|
285
|
-
backoff_cap = self.
|
|
295
|
+
logger.warning(f"Rollback after conflict on '{self.name}' failed: {rollback_error}")
|
|
296
|
+
backoff_cap = self.CONFLICT_RETRY_BACKOFF_SECONDS * (2 ** (attempt - 1))
|
|
286
297
|
time.sleep(random.uniform(0, backoff_cap))
|
|
287
298
|
|
|
288
299
|
# Normalize pyodbc.Row objects so downstream consumers see plain tuples.
|
|
@@ -5,10 +5,15 @@ from typing import Optional
|
|
|
5
5
|
|
|
6
6
|
from helpers.data_source_test_helper import DataSourceTestHelper
|
|
7
7
|
from soda_core.common.sql_ast import DROP_TABLE, DROP_VIEW
|
|
8
|
+
from soda_core.common.sql_dialect import SqlDialect
|
|
8
9
|
from soda_sqlserver.common.data_sources.sqlserver_data_source import SqlServerDataSourceImpl, SqlServerSqlDialect
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class SqlServerDataSourceTestHelper(DataSourceTestHelper):
|
|
13
|
+
@classmethod
|
|
14
|
+
def create_sql_dialects(cls) -> list[SqlDialect]:
|
|
15
|
+
return [SqlServerSqlDialect()]
|
|
16
|
+
|
|
12
17
|
def _create_database_name(self) -> Optional[str]:
|
|
13
18
|
return os.getenv("SQLSERVER_DATABASE", "master")
|
|
14
19
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: soda-sqlserver
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.31.0
|
|
4
4
|
Summary: Soda SQL Server V4
|
|
5
5
|
Author-email: "Soda Data N.V." <info@soda.io>
|
|
6
6
|
License: Proprietary
|
|
7
7
|
Requires-Python: >=3.10
|
|
8
|
-
Requires-Dist: soda-core==4.
|
|
8
|
+
Requires-Dist: soda-core==4.31.0
|
|
9
9
|
Requires-Dist: pyodbc
|
|
10
10
|
Requires-Dist: azure-identity<2,>=1.17.1
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{soda_sqlserver-4.30.0 → soda_sqlserver-4.31.0}/src/soda_sqlserver.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|