From 361abac7ad28a567c6aefa1853bdb6ac1090525e Mon Sep 17 00:00:00 2001 From: Vladislav Denisov Date: Thu, 12 Jan 2017 14:09:37 +0300 Subject: [PATCH] clickhouse: convert UInt64 to integer type --- redash/query_runner/clickhouse.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/redash/query_runner/clickhouse.py b/redash/query_runner/clickhouse.py index 9bc8b3f424..c22f9dd57c 100644 --- a/redash/query_runner/clickhouse.py +++ b/redash/query_runner/clickhouse.py @@ -68,6 +68,7 @@ def _send_query(self, data, stream=False): }) if r.status_code != 200: raise Exception(r.text) + # logging.warning(r.json()) return r.json() @staticmethod @@ -89,7 +90,13 @@ def _clickhouse_query(self, query): result = self._send_query(query) columns = [{'name': r['name'], 'friendly_name': r['name'], 'type': self._define_column_type(r['type'])} for r in result['meta']] - return {'columns': columns, 'rows': result['data']} + # db converts value to string if its type equals UInt64 + columns_uint64 = [r['name'] for r in result['meta'] if r['type'] == 'UInt64'] + rows = result['data'] + for row in rows: + for column in columns_uint64: + row[column] = int(row[column]) + return {'columns': columns, 'rows': rows} def run_query(self, query, user): logger.debug("Clickhouse is about to execute query: %s", query)