mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
Add data type to redshift query runner (#7109)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -388,12 +388,13 @@ class Redshift(PostgreSQL):
|
||||
SELECT DISTINCT table_name,
|
||||
table_schema,
|
||||
column_name,
|
||||
data_type,
|
||||
ordinal_position AS pos
|
||||
FROM svv_columns
|
||||
WHERE table_schema NOT IN ('pg_internal','pg_catalog','information_schema')
|
||||
AND table_schema NOT LIKE 'pg_temp_%'
|
||||
)
|
||||
SELECT table_name, table_schema, column_name
|
||||
SELECT table_name, table_schema, column_name, data_type
|
||||
FROM tables
|
||||
WHERE
|
||||
HAS_SCHEMA_PRIVILEGE(table_schema, 'USAGE') AND
|
||||
|
||||
@@ -25,3 +25,19 @@ class TestBuildSchema(TestCase):
|
||||
self.assertListEqual(schema["main.users"]["columns"], ["id", "name"])
|
||||
self.assertIn('public."main.users"', schema.keys())
|
||||
self.assertListEqual(schema['public."main.users"']["columns"], ["id"])
|
||||
|
||||
def test_build_schema_with_data_types(self):
|
||||
results = {
|
||||
"rows": [
|
||||
{"table_schema": "main", "table_name": "users", "column_name": "id", "data_type": "integer"},
|
||||
{"table_schema": "main", "table_name": "users", "column_name": "name", "data_type": "varchar"},
|
||||
]
|
||||
}
|
||||
|
||||
schema = {}
|
||||
|
||||
build_schema(results, schema)
|
||||
|
||||
self.assertListEqual(
|
||||
schema["main.users"]["columns"], [{"name": "id", "type": "integer"}, {"name": "name", "type": "varchar"}]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user