Skip to content

Commit

Permalink
Merge pull request #18 from reclosedev/fix-lc-column-args
Browse files Browse the repository at this point in the history
Fix LowCardinalityColumn keys column exception
  • Loading branch information
long2ice authored Jun 2, 2021
2 parents 52c12af + ee0e893 commit 8811235
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asynch/proto/columns/lowcardinalitycolumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async def _read_data(self, n_items, nulls_map=None):

# Lowest byte contains info about key type.
key_type = serialization_type & 0xF
keys_column = self.int_types[key_type]()
keys_column = self.int_types[key_type](reader=self.reader, writer=self.writer)

nullable = self.nested_column.nullable
# Prevent null map reading. Reset nested column nullable flag.
Expand Down
40 changes: 40 additions & 0 deletions tests/test_proto/columns/test_lowcardinalitycolumn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest

from asynch.proto.columns import get_column_by_spec
from asynch.proto.columns.lowcardinalitycolumn import LowCardinalityColumn
from asynch.proto.columns.stringcolumn import String

COLUMN_SPEC = "LowCardinality(String)"


@pytest.fixture
def low_cardinality_column(column_options):
column = get_column_by_spec(COLUMN_SPEC, column_options)
return column


def test_create_lc_column(low_cardinality_column):
assert isinstance(low_cardinality_column, LowCardinalityColumn)
assert isinstance(low_cardinality_column.nested_column, String)


@pytest.mark.asyncio
async def test_lc_column_write_data(low_cardinality_column):
await low_cardinality_column.write_data("")
assert len(low_cardinality_column.writer.buffer) == 0

await low_cardinality_column.write_data(["1234567890"])
assert len(low_cardinality_column.writer.buffer) == 36


@pytest.mark.asyncio
async def test_lc_column_read_data(low_cardinality_column, mocker):
s = "1234567890"
await low_cardinality_column.write_data([s])
mocker.patch.object(
low_cardinality_column.reader.reader,
"read",
return_value=low_cardinality_column.writer.buffer,
)
resp = await low_cardinality_column.read_data(1)
assert resp[0] == s
File renamed without changes.
File renamed without changes.

0 comments on commit 8811235

Please sign in to comment.