From 9c674602d072d794dd5a0699786e27bad7161a33 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 12 Dec 2023 22:41:43 +0100 Subject: [PATCH] Fetch collections when api key is access limited When the rockset api key does not have full access to all workspaces the collection fetching fails. --- redash/query_runner/rockset.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/redash/query_runner/rockset.py b/redash/query_runner/rockset.py index 07d3c85e50..6d44e884e5 100644 --- a/redash/query_runner/rockset.py +++ b/redash/query_runner/rockset.py @@ -54,7 +54,8 @@ def list_collections(self, workspace="commons"): def collection_columns(self, workspace, collection): response = self.query('DESCRIBE "{}"."{}" OPTION(max_field_depth=1)'.format(workspace, collection)) - return sorted(set([x["field"][0] for x in response["results"]])) + if "results" in response: + return sorted(set([x["field"][0] for x in response["results"]])) def query(self, sql): query_path = "queries" @@ -100,10 +101,12 @@ def _get_tables(self, schema): for workspace in self.api.list_workspaces(): for collection in self.api.list_collections(workspace): table_name = collection if workspace == "commons" else "{}.{}".format(workspace, collection) - schema[table_name] = { - "name": table_name, - "columns": self.api.collection_columns(workspace, collection), - } + columns = self.api.collection_columns(workspace, collection) + if columns: + schema[table_name] = { + "name": table_name, + "columns": columns, + } return sorted(schema.values(), key=lambda x: x["name"]) def run_query(self, query, user):