Skip to content

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

Merged
mapleFU merged 6 commits into
apache:mainfrom
adamreeve:validate-repetition
Mar 28, 2025
Merged

mapleFU merged 6 commits into
apache:mainfrom
adamreeve:validate-repetition

Conversation

@adamreeve

@adamreeve adamreeve commented Jan 7, 2025 •

Copy link
Copy Markdown
Contributor

Rationale for this change

See #45185. Invalid repetition levels would previously only cause a fatal error in debug builds.

What changes are included in this PR?

Converts an existing ARROW_DCHECK_EQ of the repetition level with a check that will raise an exception in release builds too.

Are these changes tested?

Yes, using a new example file (apache/parquet-testing#67)

Are there any user-facing changes?

Yes, reading columns with invalid repetition levels as Arrow arrays will now raise an exception.

@raulcd

raulcd commented Jan 7, 2025

Copy link
Copy Markdown
Member

Note for others taking a look, tests won't be successful until we merge the parquet-testing PR

@adamreeve
adamreeve force-pushed the validate-repetition branch from be347da to 22794e2 Compare January 20, 2025 03:21
@adamreeve
adamreeve marked this pull request as ready for review January 20, 2025 10:03
@adamreeve
adamreeve requested a review from wgtmac as a code owner January 20, 2025 10:03
@adamreeve

Copy link
Copy Markdown
Contributor Author

The failing tests all look to be caused by #45305 rather than this change.

Comment thread cpp/src/parquet/column_reader.cc Resolved

@mapleFU mapleFU left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've check the code, and I found that check the rep-levels here is ok, since check it in other places is nearly impossible here 😂

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 done

Comment thread cpp/src/parquet/column_reader.cc Outdated
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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed

@mapleFU

mapleFU commented Mar 28, 2025

Copy link
Copy Markdown
Member

Oh my I found this is not merged...I'll rebase and try to merge this

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 0 benchmarking runs that have been run so far on merge-commit 85779a4.

None of the specified runs were found on the Conbench server.

The full Conbench report has more details.

@adamreeve

Copy link
Copy Markdown
Contributor Author

Thanks!

@adamreeve
adamreeve deleted the validate-repetition branch March 31, 2025 20:30
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Apr 15, 2025
…levels when delimiting records (apache#45186)

### Rationale for this change

See apache#45185. Invalid repetition levels would previously only cause a fatal error in debug builds. 

### What changes are included in this PR?

Converts an existing `ARROW_DCHECK_EQ` of the repetition level with a check that will raise an exception in release builds too.

### Are these changes tested?

Yes, using a new example file (apache/parquet-testing#67)

### Are there any user-facing changes?

Yes, reading columns with invalid repetition levels as Arrow arrays will now raise an exception.
* GitHub Issue: apache#45185

Lead-authored-by: Adam Reeve <[email protected]>
Co-authored-by: mwish <[email protected]>
Signed-off-by: mwish <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants