emkornfield commented on code in PR #41346:
URL: https://github.com/apache/arrow/pull/41346#discussion_r1593193605


##########
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:
   I think for the purposes of bug reports, it can help narrow down issues, 
this is a fine starting point but getting just "invalid parquet file" means 
users reporting bugs upstream will always need to provide the exact file, at 
least there is some small hope with enough error details this wouldn't be 
necessary.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to