Skip to content

Commit

Permalink
Add data type info into schemas of Trino tables (#6348)
Browse files Browse the repository at this point in the history
The current get_schema method of Trino query runner is missing table columns' data types information, so these data types won't be seen in Queries editing GUI. After the modification, these info are back.

Co-authored-by: V <[email protected]>
  • Loading branch information
konnectr and vnnw authored Aug 5, 2023
1 parent 126fe93 commit 113146e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions redash/query_runner/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def type(cls):

def get_schema(self, get_stats=False):
query = """
SELECT table_schema, table_name, column_name
SELECT table_schema, table_name, column_name, data_type
FROM information_schema.columns
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
"""
Expand All @@ -101,7 +101,8 @@ def get_schema(self, get_stats=False):
if table_name not in schema:
schema[table_name] = {"name": table_name, "columns": []}

schema[table_name]["columns"].append(row["column_name"])
column = {"name": row["column_name"], "type": row["data_type"]}
schema[table_name]["columns"].append(column)

return list(schema.values())

Expand Down

0 comments on commit 113146e

Please sign in to comment.