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

Commit 2f12e38

Browse files
author
Sergey Vasilyev
committed
Fix the aftermath of refactoring: circular imports between schemas, databases, and compilers
1 parent d95d036 commit 2f12e38

5 files changed

Lines changed: 7 additions & 8 deletions

File tree

data_diff/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def _data_diff(
461461

462462
schemas = list(differ._thread_map(_get_schema, safezip(dbs, table_paths)))
463463
schema1, schema2 = schemas = [
464-
create_schema(db, table_path, schema, case_sensitive)
464+
create_schema(db.name, table_path, schema, case_sensitive)
465465
for db, table_path, schema in safezip(dbs, table_paths, schemas)
466466
]
467467

data_diff/joindiff_tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from data_diff.databases import Database, MsSQL, MySQL, BigQuery, Presto, Oracle, Snowflake
1414
from data_diff.abcs.database_types import NumericType, DbPath
15+
from data_diff.databases.base import Compiler
1516
from data_diff.queries.api import (
1617
table,
1718
sum_,
@@ -23,7 +24,6 @@
2324
rightjoin,
2425
this,
2526
when,
26-
Compiler,
2727
)
2828
from data_diff.queries.ast_classes import Concat, Count, Expr, Random, TablePath, Code, ITable
2929
from data_diff.queries.extras import NormalizeAsString

data_diff/schema.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
from data_diff import Database
43
from data_diff.utils import CaseAwareMapping, CaseInsensitiveDict, CaseSensitiveDict
54
from data_diff.abcs.database_types import DbPath
65

@@ -9,13 +8,13 @@
98
Schema = CaseAwareMapping
109

1110

12-
def create_schema(db: Database, table_path: DbPath, schema: dict, case_sensitive: bool) -> CaseAwareMapping:
13-
logger.debug(f"[{db.name}] Schema = {schema}")
11+
def create_schema(db_name: str, table_path: DbPath, schema: dict, case_sensitive: bool) -> CaseAwareMapping:
12+
logger.debug(f"[{db_name}] Schema = {schema}")
1413

1514
if case_sensitive:
1615
return CaseSensitiveDict(schema)
1716

1817
if len({k.lower() for k in schema}) < len(schema):
19-
logger.warning(f'Ambiguous schema for {db}:{".".join(table_path)} | Columns = {", ".join(list(schema))}')
18+
logger.warning(f'Ambiguous schema for {db_name}:{".".join(table_path)} | Columns = {", ".join(list(schema))}')
2019
logger.warning("We recommend to disable case-insensitivity (set --case-sensitive).")
2120
return CaseInsensitiveDict(schema)

data_diff/table_segment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _where(self):
142142

143143
def _with_raw_schema(self, raw_schema: dict) -> Self:
144144
schema = self.database._process_table_schema(self.table_path, raw_schema, self.relevant_columns, self._where())
145-
return self.new(_schema=create_schema(self.database, self.table_path, schema, self.case_sensitive))
145+
return self.new(_schema=create_schema(self.database.name, self.table_path, schema, self.case_sensitive))
146146

147147
def with_schema(self) -> Self:
148148
"Queries the table schema from the database, and returns a new instance of TableSegment, with a schema."

tests/test_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_correct_timezone(self):
133133
t = table(name)
134134
raw_schema = db.query_table_schema(t.path)
135135
schema = db._process_table_schema(t.path, raw_schema)
136-
schema = create_schema(self.database, t, schema, case_sensitive=True)
136+
schema = create_schema(db.name, t, schema, case_sensitive=True)
137137
t = t.replace(schema=schema)
138138
t.schema["created_at"] = t.schema["created_at"].replace(precision=t.schema["created_at"].precision)
139139

0 commit comments

Comments
 (0)