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

Commit 8c072e9

Browse files
author
Sergey Vasilyev
committed
Remove unused mixin for regexs
1 parent 795bb0e commit 8c072e9

5 files changed

Lines changed: 2 additions & 38 deletions

File tree

data_diff/abcs/mixins.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ def list_tables(self, table_schema: str, like: Compilable = None) -> Compilable:
134134
"""
135135

136136

137-
class AbstractMixin_Regex(AbstractMixin):
138-
@abstractmethod
139-
def test_regex(self, string: Compilable, pattern: Compilable) -> Compilable:
140-
"""Tests whether the regex pattern matches the string. Returns a bool expression."""
141-
142-
143137
class AbstractMixin_RandomSample(AbstractMixin):
144138
@abstractmethod
145139
def random_sample_n(self, tbl: str, size: int) -> str:

data_diff/databases/base.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Join, \
2828
Param, \
2929
Random, \
30-
Root, TableAlias, TableOp, TablePath, TestRegex, \
30+
Root, TableAlias, TableOp, TablePath, \
3131
TimeTravel, TruncateTable, UnaryOp, WhenThen, _ResolveColumn
3232
from data_diff.abcs.database_types import (
3333
AbstractDatabase,
@@ -52,7 +52,7 @@
5252
Boolean,
5353
JSON,
5454
)
55-
from data_diff.abcs.mixins import AbstractMixin_Regex, AbstractMixin_TimeTravel, Compilable
55+
from data_diff.abcs.mixins import AbstractMixin_TimeTravel, Compilable
5656
from data_diff.abcs.mixins import (
5757
AbstractMixin_Schema,
5858
AbstractMixin_RandomSample,
@@ -225,8 +225,6 @@ def render_compilable(self, c: Compiler, elem: Compilable) -> str:
225225
return self.render_checksum(c, elem)
226226
elif isinstance(elem, Concat):
227227
return self.render_concat(c, elem)
228-
elif isinstance(elem, TestRegex):
229-
return self.render_testregex(c, elem)
230228
elif isinstance(elem, Func):
231229
return self.render_func(c, elem)
232230
elif isinstance(elem, WhenThen):
@@ -372,13 +370,6 @@ def render_concat(self, c: Compiler, elem: Concat) -> str:
372370
def render_alias(self, c: Compiler, elem: Alias) -> str:
373371
return f"{self.compile(c, elem.expr)} AS {self.quote(elem.name)}"
374372

375-
def render_testregex(self, c: Compiler, elem: TestRegex) -> str:
376-
# TODO: move this method to that mixin! raise here instead, unconditionally.
377-
if not isinstance(self, AbstractMixin_Regex):
378-
raise NotImplementedError(f"No regex implementation for database '{c.dialect}'")
379-
regex = self.test_regex(elem.string, elem.pattern)
380-
return self.compile(c, regex)
381-
382373
def render_count(self, c: Compiler, elem: Count) -> str:
383374
expr = self.compile(c, elem.expr) if elem.expr else "*"
384375
if elem.distinct:

data_diff/databases/duckdb.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
AbstractMixin_MD5,
2121
AbstractMixin_NormalizeValue,
2222
AbstractMixin_RandomSample,
23-
AbstractMixin_Regex,
2423
)
2524
from data_diff.databases.base import (
2625
Database,
@@ -70,11 +69,6 @@ def random_sample_ratio_approx(self, tbl: AbstractTable, ratio: float) -> Abstra
7069
return code("SELECT * FROM ({tbl}) USING SAMPLE {percent}%;", tbl=tbl, percent=int(100 * ratio))
7170

7271

73-
class Mixin_Regex(AbstractMixin_Regex):
74-
def test_regex(self, string: Compilable, pattern: Compilable) -> Compilable:
75-
return Func("regexp_matches", [string, pattern])
76-
77-
7872
class Dialect(BaseDialect, Mixin_Schema, Mixin_MD5, Mixin_NormalizeValue, AbstractMixin_MD5, AbstractMixin_NormalizeValue):
7973
name = "DuckDB"
8074
ROUNDS_ON_PREC_LOSS = False

data_diff/databases/mysql.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from data_diff.abcs.mixins import (
1515
AbstractMixin_MD5,
1616
AbstractMixin_NormalizeValue,
17-
AbstractMixin_Regex,
1817
)
1918
from data_diff.databases.base import (
2019
Mixin_OptimizerHints,
@@ -61,11 +60,6 @@ def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
6160
return f"TRIM(CAST({value} AS char))"
6261

6362

64-
class Mixin_Regex(AbstractMixin_Regex):
65-
def test_regex(self, string: Compilable, pattern: Compilable) -> Compilable:
66-
return BinBoolOp("REGEXP", [string, pattern])
67-
68-
6963
class Dialect(BaseDialect, Mixin_Schema, Mixin_OptimizerHints, Mixin_MD5, Mixin_NormalizeValue, AbstractMixin_MD5, AbstractMixin_NormalizeValue):
7064
name = "MySQL"
7165
ROUNDS_ON_PREC_LOSS = True

data_diff/queries/ast_classes.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,6 @@ def is_distinct_from(self, other):
218218
def like(self, other):
219219
return BinBoolOp("LIKE", [self, other])
220220

221-
def test_regex(self, other):
222-
return TestRegex(self, other)
223-
224221
def sum(self):
225222
return Func("SUM", [self])
226223

@@ -231,12 +228,6 @@ def min(self):
231228
return Func("MIN", [self])
232229

233230

234-
@dataclass
235-
class TestRegex(ExprNode, LazyOps):
236-
string: Expr
237-
pattern: Expr
238-
239-
240231
@dataclass(eq=False)
241232
class Func(ExprNode, LazyOps):
242233
name: str

0 commit comments

Comments
 (0)