|
48 | 48 | TableAlias, |
49 | 49 | TableOp, |
50 | 50 | TablePath, |
51 | | - TimeTravel, |
52 | 51 | TruncateTable, |
53 | 52 | UnaryOp, |
54 | 53 | WhenThen, |
|
74 | 73 | Boolean, |
75 | 74 | JSON, |
76 | 75 | ) |
77 | | -from data_diff.abcs.mixins import AbstractMixin_TimeTravel, Compilable |
| 76 | +from data_diff.abcs.mixins import Compilable |
78 | 77 | from data_diff.abcs.mixins import ( |
79 | | - AbstractMixin_Schema, |
80 | | - AbstractMixin_RandomSample, |
81 | 78 | AbstractMixin_NormalizeValue, |
82 | 79 | AbstractMixin_OptimizerHints, |
83 | 80 | ) |
@@ -201,33 +198,6 @@ def apply_query(callback: Callable[[str], Any], sql_code: Union[str, ThreadLocal |
201 | 198 | return callback(sql_code) |
202 | 199 |
|
203 | 200 |
|
204 | | -@attrs.define(frozen=False) |
205 | | -class Mixin_Schema(AbstractMixin_Schema): |
206 | | - def table_information(self) -> Compilable: |
207 | | - return table("information_schema", "tables") |
208 | | - |
209 | | - def list_tables(self, table_schema: str, like: Compilable = None) -> Compilable: |
210 | | - return ( |
211 | | - self.table_information() |
212 | | - .where( |
213 | | - this.table_schema == table_schema, |
214 | | - this.table_name.like(like) if like is not None else SKIP, |
215 | | - this.table_type == "BASE TABLE", |
216 | | - ) |
217 | | - .select(this.table_name) |
218 | | - ) |
219 | | - |
220 | | - |
221 | | -@attrs.define(frozen=False) |
222 | | -class Mixin_RandomSample(AbstractMixin_RandomSample): |
223 | | - def random_sample_n(self, tbl: ITable, size: int) -> ITable: |
224 | | - # TODO use a more efficient algorithm, when the table count is known |
225 | | - return tbl.order_by(Random()).limit(size) |
226 | | - |
227 | | - def random_sample_ratio_approx(self, tbl: ITable, ratio: float) -> ITable: |
228 | | - return tbl.where(Random() < ratio) |
229 | | - |
230 | | - |
231 | 201 | @attrs.define(frozen=False) |
232 | 202 | class Mixin_OptimizerHints(AbstractMixin_OptimizerHints): |
233 | 203 | def optimizer_hints(self, hints: str) -> str: |
@@ -338,8 +308,6 @@ def render_compilable(self, c: Compiler, elem: Compilable) -> str: |
338 | 308 | return self.render_explain(c, elem) |
339 | 309 | elif isinstance(elem, CurrentTimestamp): |
340 | 310 | return self.render_currenttimestamp(c, elem) |
341 | | - elif isinstance(elem, TimeTravel): |
342 | | - return self.render_timetravel(c, elem) |
343 | 311 | elif isinstance(elem, CreateTable): |
344 | 312 | return self.render_createtable(c, elem) |
345 | 313 | elif isinstance(elem, DropTable): |
@@ -616,16 +584,6 @@ def render_explain(self, c: Compiler, elem: Explain) -> str: |
616 | 584 | def render_currenttimestamp(self, c: Compiler, elem: CurrentTimestamp) -> str: |
617 | 585 | return self.current_timestamp() |
618 | 586 |
|
619 | | - def render_timetravel(self, c: Compiler, elem: TimeTravel) -> str: |
620 | | - assert isinstance(c, AbstractMixin_TimeTravel) |
621 | | - return self.compile( |
622 | | - c, |
623 | | - # TODO: why is it c.? why not self? time-trvelling is the dialect's thing, isnt't it? |
624 | | - c.time_travel( |
625 | | - elem.table, before=elem.before, timestamp=elem.timestamp, offset=elem.offset, statement=elem.statement |
626 | | - ), |
627 | | - ) |
628 | | - |
629 | 587 | def render_createtable(self, c: Compiler, elem: CreateTable) -> str: |
630 | 588 | ne = "IF NOT EXISTS " if elem.if_not_exists else "" |
631 | 589 | if elem.source_table: |
@@ -1045,10 +1003,6 @@ def _refine_coltypes( |
1045 | 1003 | assert col_name in col_dict |
1046 | 1004 | col_dict[col_name] = String_VaryingAlphanum() |
1047 | 1005 |
|
1048 | | - # @lru_cache() |
1049 | | - # def get_table_schema(self, path: DbPath) -> Dict[str, ColType]: |
1050 | | - # return self.query_table_schema(path) |
1051 | | - |
1052 | 1006 | def _normalize_table_path(self, path: DbPath) -> DbPath: |
1053 | 1007 | if len(path) == 1: |
1054 | 1008 | return self.default_schema, path[0] |
@@ -1082,9 +1036,6 @@ def close(self): |
1082 | 1036 | self.is_closed = True |
1083 | 1037 | return super().close() |
1084 | 1038 |
|
1085 | | - def list_tables(self, tables_like, schema=None): |
1086 | | - return self.query(self.dialect.list_tables(schema or self.default_schema, tables_like)) |
1087 | | - |
1088 | 1039 | @property |
1089 | 1040 | @abstractmethod |
1090 | 1041 | def dialect(self) -> BaseDialect: |
|
0 commit comments