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

Adjustment to PR #348 #350

Merged
merged 3 commits into from
Dec 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions data_diff/sqeleton/databases/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,30 @@ def close(self):
self._client.close()

def select_table_schema(self, path: DbPath) -> str:
schema, name = self._normalize_table_path(path)

project, schema, name = self._normalize_table_path(path)
return (
"SELECT column_name, data_type, 6 as datetime_precision, 38 as numeric_precision, 9 as numeric_scale "
f"FROM {schema}.INFORMATION_SCHEMA.COLUMNS "
f"FROM `{project}`.`{schema}`.INFORMATION_SCHEMA.COLUMNS "
f"WHERE table_name = '{name}' AND table_schema = '{schema}'"
)

def query_table_unique_columns(self, path: DbPath) -> List[str]:
return []

def _normalize_table_path(self, path: DbPath) -> DbPath:
if len(path) == 0:
raise ValueError(f"{self.name}: Bad table path for {self}: ()")
elif len(path) == 1:
return (self.project, self.default_schema, path[0])
elif len(path) == 2:
return (self.project,) + path
elif len(path) == 3:
return path
else:
raise ValueError(
f"{self.name}: Bad table path for {self}: '{'.'.join(path)}'. Expected form: [project.]schema.table"
)

def parse_table_name(self, name: str) -> DbPath:
path = parse_table_name(name)
return tuple(i for i in self._normalize_table_path(path) if i is not None)
Expand Down