Skip to content

Commit a4f92a8

Browse files
Add data type to redshift query runner (#7109)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 51ef625 commit a4f92a8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

redash/query_runner/pg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,13 @@ def _get_tables(self, schema):
388388
SELECT DISTINCT table_name,
389389
table_schema,
390390
column_name,
391+
data_type,
391392
ordinal_position AS pos
392393
FROM svv_columns
393394
WHERE table_schema NOT IN ('pg_internal','pg_catalog','information_schema')
394395
AND table_schema NOT LIKE 'pg_temp_%'
395396
)
396-
SELECT table_name, table_schema, column_name
397+
SELECT table_name, table_schema, column_name, data_type
397398
FROM tables
398399
WHERE
399400
HAS_SCHEMA_PRIVILEGE(table_schema, 'USAGE') AND

tests/query_runner/test_pg.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ def test_handles_dups_between_public_and_other_schemas(self):
2525
self.assertListEqual(schema["main.users"]["columns"], ["id", "name"])
2626
self.assertIn('public."main.users"', schema.keys())
2727
self.assertListEqual(schema['public."main.users"']["columns"], ["id"])
28+
29+
def test_build_schema_with_data_types(self):
30+
results = {
31+
"rows": [
32+
{"table_schema": "main", "table_name": "users", "column_name": "id", "data_type": "integer"},
33+
{"table_schema": "main", "table_name": "users", "column_name": "name", "data_type": "varchar"},
34+
]
35+
}
36+
37+
schema = {}
38+
39+
build_schema(results, schema)
40+
41+
self.assertListEqual(
42+
schema["main.users"]["columns"], [{"name": "id", "type": "integer"}, {"name": "name", "type": "varchar"}]
43+
)

0 commit comments

Comments
 (0)