mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2025-07-23 06:19:57 +03:00
Merge branch 'with-totals-fix' of https://github.com/pilosus/infi.clickhouse_orm into pilosus-with-totals-fix
This commit is contained in:
commit
b27756d44b
|
@ -96,7 +96,9 @@ class Database(object):
|
|||
field_types = parse_tsv(next(lines))
|
||||
model_class = model_class or ModelBase.create_ad_hoc_model(zip(field_names, field_types))
|
||||
for line in lines:
|
||||
yield model_class.from_tsv(line, field_names, self.server_timezone, self)
|
||||
# skip blank line left by WITH TOTALS modifier
|
||||
if line:
|
||||
yield model_class.from_tsv(line, field_names, self.server_timezone, self)
|
||||
|
||||
def raw(self, query, settings=None, stream=False):
|
||||
"""
|
||||
|
|
|
@ -38,7 +38,14 @@ def unescape(value):
|
|||
def parse_tsv(line):
|
||||
if PY3 and isinstance(line, binary_type):
|
||||
line = line.decode()
|
||||
if line[-1] == '\n':
|
||||
# GROUP BY WITH TOTALS modifier contains a blank line (second last row)
|
||||
# separating normal result from the totals (last row)
|
||||
# Let's skip the blank line
|
||||
try:
|
||||
last_element = line[-1]
|
||||
except IndexError:
|
||||
return
|
||||
if last_element == '\n':
|
||||
line = line[:-1]
|
||||
return [unescape(value) for value in line.split('\t')]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user