Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 8e3084b

Browse files
committed
format
1 parent 9e9a9a1 commit 8e3084b

File tree

9 files changed

+22
-15
lines changed

9 files changed

+22
-15
lines changed

data_diff/databases/_connect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"trino": Trino,
3131
"clickhouse": Clickhouse,
3232
"vertica": Vertica,
33-
"mssql": MsSql
33+
"mssql": MsSql,
3434
}
3535

3636

data_diff/sqeleton/abcs/database_types.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ def current_schema(self) -> str:
224224
"Provide SQL for returning the current default schema."
225225

226226
@abstractmethod
227-
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None) -> str:
227+
def offset_limit(
228+
self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None
229+
) -> str:
228230
"Provide SQL fragment for limit and offset inside a select"
229231

230232
@abstractmethod

data_diff/sqeleton/databases/_connect.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def match_path(self, dsn):
8787
"trino": Trino,
8888
"clickhouse": Clickhouse,
8989
"vertica": Vertica,
90-
"mssql": MsSQL
90+
"mssql": MsSQL,
9191
}
9292

9393

data_diff/sqeleton/databases/base.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ class BaseDialect(AbstractDialect):
155155

156156
PLACEHOLDER_TABLE = None # Used for Oracle
157157

158-
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None) -> str:
158+
def offset_limit(
159+
self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None
160+
) -> str:
159161
if offset:
160162
raise NotImplementedError("No support for OFFSET in query")
161163

data_diff/sqeleton/databases/mssql.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ def normalize_number(self, value: str, coltype: FractionalType) -> str:
5454

5555
return f"FORMAT({value}, 'N{coltype.precision}')"
5656

57+
5758
class Mixin_MD5(AbstractMixin_MD5):
5859
def md5_as_int(self, s: str) -> str:
5960
# TODO FYI
6061
# I didn't see another way to do this
6162
# keep in mind this also required reducing
6263
# CHECKSUM_HEXDIGITS = 15 -> 14 due to the convert needing an even number of hex digits
6364
# (affects all dbs)
64-
return (
65-
f"convert(bigint, convert(varbinary, '0x' + RIGHT(CONVERT(NVARCHAR(32), HashBytes('MD5', {s}), 2), {CHECKSUM_HEXDIGITS}), 1))"
66-
)
65+
return f"convert(bigint, convert(varbinary, '0x' + RIGHT(CONVERT(NVARCHAR(32), HashBytes('MD5', {s}), 2), {CHECKSUM_HEXDIGITS}), 1))"
66+
6767

6868
class Dialect(BaseDialect, Mixin_Schema, Mixin_OptimizerHints):
6969
name = "MsSQL"
@@ -139,11 +139,11 @@ def random(self) -> str:
139139
def is_distinct_from(self, a: str, b: str) -> str:
140140
# IS (NOT) DISTINCT FROM is available only since SQLServer 2022.
141141
# See: https://stackoverflow.com/a/18684859/857383
142-
return (
143-
f"(({a}<>{b} OR {a} IS NULL OR {b} IS NULL) AND NOT({a} IS NULL AND {b} IS NULL))"
144-
)
142+
return f"(({a}<>{b} OR {a} IS NULL OR {b} IS NULL) AND NOT({a} IS NULL AND {b} IS NULL))"
145143

146-
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None) -> str:
144+
def offset_limit(
145+
self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None
146+
) -> str:
147147
if offset:
148148
raise NotImplementedError("No support for OFFSET in query")
149149

data_diff/sqeleton/databases/oracle.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def quote(self, s: str):
104104
def to_string(self, s: str):
105105
return f"cast({s} as varchar(1024))"
106106

107-
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None) -> str:
107+
def offset_limit(
108+
self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None
109+
) -> str:
108110
if offset:
109111
raise NotImplementedError("No support for OFFSET in query")
110112

tests/sqeleton/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
TEST_DUCKDB_CONN_STRING,
3131
N_THREADS,
3232
TEST_ACROSS_ALL_DBS,
33-
TEST_MSSQL_CONN_STRING
33+
TEST_MSSQL_CONN_STRING,
3434
)
3535

3636

tests/sqeleton/test_database.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
TEST_DATABASES = {
1515
# TODO dev
16-
1716
# dbs.MySQL,
1817
# dbs.PostgreSQL,
1918
# dbs.Oracle,

tests/sqeleton/test_query.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def current_database(self) -> str:
4747
def current_schema(self) -> str:
4848
return "current_schema()"
4949

50-
def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None) -> str:
50+
def offset_limit(
51+
self, offset: Optional[int] = None, limit: Optional[int] = None, has_order_by: Optional[bool] = None
52+
) -> str:
5153
x = offset and f"OFFSET {offset}", limit and f"LIMIT {limit}"
5254
return " ".join(filter(None, x))
5355

0 commit comments

Comments
 (0)