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

Fix Parquet V2 page reading when max def/rep levels are 0 #9939

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions velox/dwio/parquet/reader/PageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,11 @@ void PageReader::prepareDataPageV2(const PageHeader& pageHeader, int64_t row) {
return;
}

uint32_t defineLength = maxDefine_ > 0
? pageHeader.data_page_header_v2.definition_levels_byte_length
: 0;
uint32_t repeatLength = maxRepeat_ > 0
? pageHeader.data_page_header_v2.repetition_levels_byte_length
: 0;
uint32_t defineLength =
pageHeader.data_page_header_v2.definition_levels_byte_length;
uint32_t repeatLength =
pageHeader.data_page_header_v2.repetition_levels_byte_length;

auto bytes = pageHeader.compressed_page_size;
pageData_ = readBytes(bytes, pageBuffer_);

Expand Down
Binary file added velox/dwio/parquet/tests/examples/v2_page.parquet
Binary file not shown.
25 changes: 25 additions & 0 deletions velox/dwio/parquet/tests/reader/ParquetReaderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,3 +1156,28 @@ TEST_F(ParquetReaderTest, readVarbinaryFromFLBA) {
result->as<RowVector>()->childAt(0)->asFlatVector<StringView>()->valueAt(
0));
}

TEST_F(ParquetReaderTest, testV2PageWithZeroMaxDefRep) {
// enum_type.parquet contains 1 column (ENUM) with 3 rows.
const std::string sample(getExampleFilePath("v2_page.parquet"));

facebook::velox::dwio::common::ReaderOptions readerOptions{leafPool_.get()};
auto reader = createReader(sample, readerOptions);
EXPECT_EQ(reader->numberOfRows(), 5ULL);

auto rowType = reader->typeWithId();
EXPECT_EQ(rowType->type()->kind(), TypeKind::ROW);
EXPECT_EQ(rowType->size(), 1ULL);

EXPECT_EQ(rowType->childAt(0)->type()->kind(), TypeKind::BIGINT);

auto outputRowType = ROW({"regionkey"}, {BIGINT()});
auto rowReaderOpts = getReaderOpts(outputRowType);
rowReaderOpts.setScanSpec(makeScanSpec(outputRowType));
auto rowReader = reader->createRowReader(rowReaderOpts);

auto expected = makeRowVector({makeFlatVector<int64_t>({0, 1, 2, 3, 4})});

assertReadWithReaderAndExpected(
outputRowType, *rowReader, expected, *leafPool_);
}
Loading