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

Commit 82beb97

Browse files
committed
Add query for redshift external columns
1 parent d01e74b commit 82beb97

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

data_diff/sqeleton/databases/redshift.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,18 @@ def select_table_schema(self, path: DbPath) -> str:
7070
"SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM information_schema.columns "
7171
f"WHERE table_name = '{table.lower()}' AND table_schema = '{schema.lower()}'"
7272
)
73+
74+
def select_external_table_schema(self, path: DbPath) -> str:
75+
schema, table = self._normalize_table_path(path)
76+
77+
return (
78+
f"""SELECT
79+
columnname AS column_name
80+
, CASE WHEN external_type = 'string' THEN 'varchar' ELSE external_type END AS data_type
81+
, NULL AS datetime_precision
82+
, NULL AS numeric_precision
83+
, NULL AS numeric_scale
84+
FROM svv_external_columns
85+
WHERE tablename = '{table.lower()}' AND schemaname = '{schema.lower()}'
86+
"""
87+
)

0 commit comments

Comments
 (0)