Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an extras field for Presto connection #3909

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions redash/query_runner/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ def configuration_schema(cls):
'password': {
'type': 'string'
},
'extras': {
'type': 'string',
'default': '{"requests_kwargs": null}'
}
},
'order': ['host', 'protocol', 'port', 'username', 'password', 'schema', 'catalog'],
'order': ['host', 'protocol', 'port', 'username', 'password', 'schema', 'catalog', 'extras'],
'required': ['host']
}

Expand All @@ -75,10 +79,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 +93,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 All @@ -105,7 +110,8 @@ def run_query(self, query, user):
username=self.configuration.get('username', 'redash'),
password=(self.configuration.get('password') or None),
catalog=self.configuration.get('catalog', 'hive'),
schema=self.configuration.get('schema', 'default'))
schema=self.configuration.get('schema', 'default'),
**json_loads(self.configuration.get('extras') or '{}'))

cursor = connection.cursor()

Expand Down