Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
Use system.jdbc for Presto tables
Browse files Browse the repository at this point in the history
In lower version of Presto, sometimes the old query will throw
"outputFormat should not be accessed from a null StorageFormat"
error (see prestodb/presto#6972).
  • Loading branch information
ktmud committed Jun 20, 2019
1 parent 27259b5 commit c49277d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions redash/query_runner/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ def type(cls):
def get_schema(self, get_stats=False):
schema = {}
query = """
SELECT table_schema, table_name, column_name
FROM information_schema.columns
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
"""
SELECT
table_schem, table_name, column_name
FROM system.jdbc.columns
WHERE table_cat = '{}'
""".format(self.configuration.get('catalog', 'hive'))

results, error = self.run_query(query, None)

Expand All @@ -88,7 +89,7 @@ def get_schema(self, get_stats=False):
results = json_loads(results)

for row in results['rows']:
table_name = '{}.{}'.format(row['table_schema'], row['table_name'])
table_name = '{}.{}'.format(row['table_schem'], row['table_name'])

if table_name not in schema:
schema[table_name] = {'name': table_name, 'columns': []}
Expand Down

0 comments on commit c49277d

Please sign in to comment.