Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clickhouse] Change: convert UInt64 columns to integer type #1517

Merged
merged 1 commit into from
Jan 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion redash/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