Skip to content

Commit 2a67df5

Browse files
authored
Merge pull request datafold#333 from datafold/dec6_normalize_path
Fix _normalize_table_path to always return a pair
2 parents 6f5417a + def7d00 commit 2a67df5

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

data_diff/sqeleton/databases/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,11 @@ def _refine_coltypes(self, table_path: DbPath, col_dict: Dict[str, ColType], whe
415415

416416
def _normalize_table_path(self, path: DbPath) -> DbPath:
417417
if len(path) == 1:
418-
if self.default_schema:
419-
return self.default_schema, path[0]
420-
elif len(path) != 2:
421-
raise ValueError(f"{self.name}: Bad table path for {self}: '{'.'.join(path)}'. Expected form: schema.table")
418+
return self.default_schema, path[0]
419+
elif len(path) == 2:
420+
return path
422421

423-
return path
422+
raise ValueError(f"{self.name}: Bad table path for {self}: '{'.'.join(path)}'. Expected form: schema.table")
424423

425424
def parse_table_name(self, name: str) -> DbPath:
426425
return parse_table_name(name)

data_diff/sqeleton/databases/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def query_table_unique_columns(self, path: DbPath) -> List[str]:
158158

159159
def parse_table_name(self, name: str) -> DbPath:
160160
path = parse_table_name(name)
161-
return self._normalize_table_path(path)
161+
return tuple(i for i in self._normalize_table_path(path) if i is not None)
162162

163163
@property
164164
def is_autocommit(self) -> bool:

data_diff/sqeleton/databases/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _process_table_schema(
171171

172172
def parse_table_name(self, name: str) -> DbPath:
173173
path = parse_table_name(name)
174-
return self._normalize_table_path(path)
174+
return tuple(i for i in self._normalize_table_path(path) if i is not None)
175175

176176
@property
177177
def is_autocommit(self) -> bool:

0 commit comments

Comments
 (0)