pitrou commented on code in PR #41346: URL: https://github.com/apache/arrow/pull/41346#discussion_r1592678422
########## cpp/src/parquet/column_reader.cc: ########## @@ -1028,12 +1030,17 @@ class TypedColumnReaderImpl : public TypedColumnReader<DType>, // and number of values to read. This function is called before reading values. void ReadLevels(int64_t batch_size, int16_t* def_levels, int16_t* rep_levels, int64_t* num_def_levels, int64_t* values_to_read) { - batch_size = - std::min(batch_size, this->num_buffered_values_ - this->num_decoded_values_); + batch_size = std::min(batch_size, this->available_values_current_page()); // If the field is required and non-repeated, there are no definition levels if (this->max_def_level_ > 0 && def_levels != nullptr) { *num_def_levels = this->ReadDefinitionLevels(batch_size, def_levels); + if (ARROW_PREDICT_FALSE(*num_def_levels != batch_size)) { + throw ParquetException( + "Number of decoded definition levels did not match: def_levels: " + + std::to_string(*num_def_levels) + + ", batch_size:" + std::to_string(batch_size)); Review Comment: There are already some details in the error message. I don't think we should go any further. For most users, this is already overly complicated compared to a simpler "invalid Parquet file" message :-) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org