From 7175832d1e516754bbdab582e15a78b122818067 Mon Sep 17 00:00:00 2001 From: rzhao Date: Mon, 30 Sep 2019 14:49:51 -0700 Subject: [PATCH 1/2] Vertica: prevent overwriting row data when duplicated column names exist --- redash/query_runner/vertica.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/redash/query_runner/vertica.py b/redash/query_runner/vertica.py index 08f4d616e1..4ec23e115a 100644 --- a/redash/query_runner/vertica.py +++ b/redash/query_runner/vertica.py @@ -128,12 +128,11 @@ def run_query(self, query, user): # TODO - very similar to pg.py if cursor.description is not None: - columns_data = [(i[0], i[1]) for i in cursor.description] + columns_data = [(i[0], types_map.get(i[1], None)) for i in cursor.description] - rows = [dict(zip((c[0] for c in columns_data), row)) for row in cursor.fetchall()] - columns = [{'name': col[0], - 'friendly_name': col[0], - 'type': types_map.get(col[1], None)} for col in columns_data] + columns = self.fetch_columns(column_data) + rows = [dict(zip(([c['name'] for c in columns]), r)) + for i, r in enumerate(cursor.fetchall())] data = {'columns': columns, 'rows': rows} json_data = json_dumps(data) From 8a4a5035bb4cf914241c6bc81af96f2f2f220f7a Mon Sep 17 00:00:00 2001 From: rzhao Date: Tue, 1 Oct 2019 17:21:18 -0700 Subject: [PATCH 2/2] remove enumeration --- redash/query_runner/vertica.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redash/query_runner/vertica.py b/redash/query_runner/vertica.py index 4ec23e115a..21205a3721 100644 --- a/redash/query_runner/vertica.py +++ b/redash/query_runner/vertica.py @@ -132,7 +132,7 @@ def run_query(self, query, user): columns = self.fetch_columns(column_data) rows = [dict(zip(([c['name'] for c in columns]), r)) - for i, r in enumerate(cursor.fetchall())] + for r in cursor.fetchall()] data = {'columns': columns, 'rows': rows} json_data = json_dumps(data)