Skip to content

Commit 38f6f82

Browse files
authored
Merge pull request #1517 from denisov-vlad/clickhouse_uint64
Clickhouse: convert UInt64 columns to integer type
2 parents 4f9ffdc + 361abac commit 38f6f82

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

redash/query_runner/clickhouse.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _send_query(self, data, stream=False):
6868
})
6969
if r.status_code != 200:
7070
raise Exception(r.text)
71+
# logging.warning(r.json())
7172
return r.json()
7273

7374
@staticmethod
@@ -89,7 +90,13 @@ def _clickhouse_query(self, query):
8990
result = self._send_query(query)
9091
columns = [{'name': r['name'], 'friendly_name': r['name'],
9192
'type': self._define_column_type(r['type'])} for r in result['meta']]
92-
return {'columns': columns, 'rows': result['data']}
93+
# db converts value to string if its type equals UInt64
94+
columns_uint64 = [r['name'] for r in result['meta'] if r['type'] == 'UInt64']
95+
rows = result['data']
96+
for row in rows:
97+
for column in columns_uint64:
98+
row[column] = int(row[column])
99+
return {'columns': columns, 'rows': rows}
93100

94101
def run_query(self, query, user):
95102
logger.debug("Clickhouse is about to execute query: %s", query)

0 commit comments

Comments
 (0)