Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GH-45185: [C++][Parquet] Raise an error for invalid repetition levels when delimiting records #45186

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions cpp/src/parquet/arrow/arrow_reader_writer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3990,6 +3990,12 @@ TEST(TestArrowReaderAdHoc, CorruptedSchema) {
TryReadDataFile(path, ::arrow::StatusCode::IOError);
}

TEST(TestArrowReaderAdHoc, InvalidRepetitionLevels) {
// GH-45185 - Repetition levels start with 1 instead of 0
auto path = test::get_data_file("ARROW-GH-45185.parquet", /*is_good=*/false);
TryReadDataFile(path, ::arrow::StatusCode::IOError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind also check the status is "The repetition level at the start of a record must be 0 but got ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 done

}

TEST(TestArrowReaderAdHoc, LARGE_MEMORY_TEST(LargeStringColumn)) {
// ARROW-3762
::arrow::StringBuilder builder;
Expand Down
7 changes: 6 additions & 1 deletion cpp/src/parquet/column_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,12 @@ class TypedRecordReader : public TypedColumnReaderImpl<DType>,
// another record start or exhausting the ColumnChunk
int64_t level = levels_position_;
if (at_record_start_) {
ARROW_DCHECK_EQ(0, rep_levels[levels_position_]);
if (rep_levels[levels_position_] != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ARROW_PREDICT_FALSE to check it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed

std::stringstream ss;
ss << "The repetition level at the start of a record must be 0 but got "
<< rep_levels[levels_position_];
throw ParquetException(ss.str());
}
++levels_position_;
// We have decided to consume the level at this position; therefore we
// must advance until we find another record boundary
Expand Down
Loading