Skip to content

Commit 8985595

Browse files
authored
Merge pull request #60 from jcrobak/indexerror-fix
IndexError fix for zero width
2 parents 3e29700 + 92b6d14 commit 8985595

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

parquet/encoding.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def read_bitpacked(file_obj, header, width, debug_logging):
147147
if debug_logging:
148148
logger.debug("Reading a bit-packed run with: %s groups, count %s, bytes %s",
149149
num_groups, count, byte_count)
150+
if width == 0:
151+
return [0 for _ in range(count)]
150152
raw_bytes = array.array(ARRAY_BYTE_STR, file_obj.read(byte_count)).tolist()
151153
current_byte = 0
152154
data = raw_bytes[current_byte]

test/test_encoding.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ def testFromExample(self):
117117
res = parquet.encoding.read_bitpacked(fo, count, 3, True)
118118
self.assertEqual(list(range(8)), res)
119119

120+
def test_width_zero(self):
121+
"""Test a zero-width item."""
122+
fo = io.BytesIO()
123+
count = 1 << 1
124+
res = parquet.encoding.read_bitpacked(fo, count, 0, True)
125+
self.assertEqual([0] * 8, res)
126+
120127

121128
class TestBitPackedDeprecated(unittest.TestCase):
122129
"""Test reading the deprecated bit-packed encoded data."""

0 commit comments

Comments
 (0)