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

Commit 979f5ec

Browse files
author
Sung Won Chung
committed
Refactor dynamic database clause in DuckDB.py
1 parent a21feac commit 979f5ec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

data_diff/databases/duckdb.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,16 @@ def select_table_schema(self, path: DbPath) -> str:
167167
database, schema, table = self._normalize_table_path(path)
168168

169169
info_schema_path = ["information_schema", "columns"]
170+
170171
if database:
171172
info_schema_path.insert(0, database)
173+
dynamic_database_clause = f"'{database}'"
174+
else:
175+
dynamic_database_clause = "current_catalog()"
172176

173177
return (
174178
f"SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM {'.'.join(info_schema_path)} "
175-
f"WHERE table_name = '{table}' AND table_schema = '{schema}' and table_catalog = '{database}'"
179+
f"WHERE table_name = '{table}' AND table_schema = '{schema}' and table_catalog = {dynamic_database_clause}"
176180
)
177181

178182
def _normalize_table_path(self, path: DbPath) -> DbPath:

0 commit comments

Comments
 (0)