Skip to content

Commit

Permalink
Fix PR #285
Browse files Browse the repository at this point in the history
  • Loading branch information
xzkostyan committed Jan 20, 2022
1 parent d95f14b commit 73c4518
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
12 changes: 5 additions & 7 deletions clickhouse_driver/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ def _pure_mutate_dicts_to_rows(
check_row_type,
):
columns_with_cwt = []
for x in columns_with_types:
for name, type_ in columns_with_types:
cwt = None
if x[1].startswith('Nested'):
cwt = nestedcolumn.get_columns_with_types(x[1])
columns_with_cwt.append((x[0], cwt))
if type_.startswith('Nested'):
cwt = nestedcolumn.get_columns_with_types(type_)
columns_with_cwt.append((name, cwt))

for i, row in enumerate(data):
if check_row_type:
Expand All @@ -185,9 +185,7 @@ def _pure_mutate_dicts_to_rows(
new_data.append(row[name])
else:
new_data.append(self._pure_mutate_dicts_to_rows(
row[name],
cwt,
check_row_type
row[name], cwt, check_row_type
))
data[i] = new_data
# return for recursion
Expand Down
12 changes: 6 additions & 6 deletions clickhouse_driver/columns/nestedcolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ def get_columns_with_types(spec):


def get_inner_spec(spec):
brackets = 1
offset = len('Nested(')
brackets = 0
offset = len('Nested')
i = offset
for i, ch in enumerate(spec[offset:], offset):
if brackets == 0:
break

if ch == '(':
brackets += 1

elif ch == ')':
brackets -= 1

return spec[offset:i]
if brackets == 0:
break

return spec[offset + 1:i]
12 changes: 6 additions & 6 deletions clickhouse_driver/columns/tuplecolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ def create_tuple_column(spec, column_by_spec_getter):


def get_inner_spec(spec):
brackets = 1
offset = len('Tuple(')
brackets = 0
offset = len('Tuple')
i = offset
for i, ch in enumerate(spec[offset:], offset):
if brackets == 0:
break

if ch == '(':
brackets += 1

elif ch == ')':
brackets -= 1

return spec[offset:i]
if brackets == 0:
break

return spec[offset + 1:i]
4 changes: 0 additions & 4 deletions tests/columns/test_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@


class NestedTestCase(BaseTestCase):
def setUp(self):
ret = super(NestedTestCase, self).setUp()
return ret

def entuple(self, lst):
return tuple(
self.entuple(x) if isinstance(x, list) else x for x in lst
Expand Down

0 comments on commit 73c4518

Please sign in to comment.