From 7175832d1e516754bbdab582e15a78b122818067 Mon Sep 17 00:00:00 2001 From: rzhao Date: Mon, 30 Sep 2019 14:49:51 -0700 Subject: [PATCH] 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)