Skip to content

Commit

Permalink
Merge pull request getredash#1517 from denisov-vlad/clickhouse_uint64
Browse files Browse the repository at this point in the history
Clickhouse: convert UInt64 columns to integer type
  • Loading branch information
arikfr authored Jan 24, 2017
2 parents 51a35d3 + c1012dc commit 3aaad03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 3aaad03

Please sign in to comment.