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

Commit e072b35

Browse files
author
Sergey Vasilyev
committed
Remove unneeded "bound" nodes & tables
1 parent 8c072e9 commit e072b35

3 files changed

Lines changed: 6 additions & 105 deletions

File tree

data_diff/bound_exprs.py

Lines changed: 0 additions & 94 deletions
This file was deleted.

data_diff/databases/base.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
AbstractMixin_NormalizeValue,
6060
AbstractMixin_OptimizerHints,
6161
)
62-
from data_diff.bound_exprs import BoundNode, bound_table
6362

6463
logger = logging.getLogger("database")
6564
cv_params = contextvars.ContextVar("params")
@@ -275,8 +274,6 @@ def render_compilable(self, c: Compiler, elem: Compilable) -> str:
275274
return self.render_inserttotable(c, elem)
276275
elif isinstance(elem, Code):
277276
return self.render_code(c, elem)
278-
elif isinstance(elem, BoundNode):
279-
return self.render_boundnode(c, elem)
280277
elif isinstance(elem, _ResolveColumn):
281278
return self.render__resolvecolumn(c, elem)
282279

@@ -424,10 +421,6 @@ def render_tableop(self, parent_c: Compiler, elem: TableOp) -> str:
424421
table_expr = f"({table_expr})"
425422
return table_expr
426423

427-
def render_boundnode(self, c: Compiler, elem: BoundNode) -> str:
428-
assert self is elem.database.dialect
429-
return self.compile(c, elem.node)
430-
431424
def render__resolvecolumn(self, c: Compiler, elem: _ResolveColumn) -> str:
432425
return self.compile(c, elem._get_resolved())
433426

@@ -970,9 +963,6 @@ def close(self):
970963
def list_tables(self, tables_like, schema=None):
971964
return self.query(self.dialect.list_tables(schema or self.default_schema, tables_like))
972965

973-
def table(self, *path, **kw):
974-
return bound_table(self, path, **kw)
975-
976966

977967
class ThreadedDatabase(Database):
978968
"""Access the database through singleton threads.

tests/test_database.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from data_diff import databases as dbs
99
from data_diff.queries.api import table, current_timestamp
1010
from data_diff.queries.extras import NormalizeAsString
11+
from data_diff.schema import create_schema
1112
from tests.common import TEST_MYSQL_CONN_STRING, test_each_database_in_list, get_conn, str_to_checksum, random_table_suffix
1213
from data_diff.abcs.database_types import TimestampTZ
1314

@@ -123,7 +124,11 @@ def test_correct_timezone(self):
123124
db.query(table(name).insert_row(1, now, now))
124125
db.query(db.dialect.set_timezone_to_utc())
125126

126-
t = db.table(name).query_schema()
127+
t = table(name)
128+
raw_schema = db.query_table_schema(t.path)
129+
schema = db._process_table_schema(t.path, raw_schema)
130+
schema = create_schema(self.database, t, schema, case_sensitive=True)
131+
t = t.replace(schema=schema)
127132
t.schema["created_at"] = t.schema["created_at"].replace(precision=t.schema["created_at"].precision)
128133

129134
tbl = table(name, schema=t.schema)

0 commit comments

Comments
 (0)