1fanwang commented on code in PR #55704:
URL: https://github.com/apache/arrow/pull/55704#discussion_r4652159734


##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -785,18 +786,63 @@ class PARQUET_NO_EXPORT FixedSizeListReader : public 
ListReader<int32_t> {
             ::arrow::MakeArray(data->child_data[0]->Slice(offsets[start], 
child_length)));
         return Status::OK();
       };
-
-      DCHECK_NE(data->buffers[0], nullptr);
-      RETURN_NOT_OK(::arrow::internal::VisitBitRuns(
-          data->buffers[0]->data(), data->offset, data->length, visit_run));
-
+      RETURN_NOT_OK(visit_runs(visit_run));
       // TODO(GH-50271): Build one padded child array directly instead of 
creating
       // one temporary Array/ArrayData per validity run and concatenating them.
       ARROW_ASSIGN_OR_RAISE(auto child_array_with_padding,
                             ::arrow::Concatenate(child_arrays, ctx_->pool));
       data->child_data[0] = child_array_with_padding->data();
+      return Status::OK();
+    };
+
+    if (data->buffers[0] != nullptr) {
+      // A real validity buffer survived, so at least one row in this batch
+      // is null; rebuild run-by-run so each null run is padded.
+      RETURN_NOT_OK(rebuild_from_runs([&](auto&& visit_run) {
+        return ::arrow::internal::VisitBitRuns(data->buffers[0]->data(), 
data->offset,
+                                               data->length, visit_run);
+      }));
+    } else if (!field()->nullable() && data->length > 0) {
+      // This field is schema non-nullable, so it never has a validity buffer
+      // at all, with or without nulls: a null non-repeated ancestor (e.g. a
+      // struct) still leaves no physical child values for its row, and that
+      // gap can only be detected from the offsets directly.
+      bool any_gap = false;
+      auto scan_offsets = [&](auto&& visit) -> Status {
+        int64_t run_start = 0;
+        bool run_has_elements = true;
+        for (int64_t i = 0; i < data->length; ++i) {
+          const bool has_elements = offsets[i + 1] != offsets[i];

Review Comment:
   Done in 19fe7cbb74. Added a check that def_level > rep_level before scanning 
for gaps: every repeated step raises both equally, so anything beyond that can 
only come from an optional ancestor. A bare REQUIRED top-level list now has 
def_level == rep_level and always validates the whole range in one pass, 
rejecting a present empty list as corrupt. Added 
FixedSizeListRejectsPresentEmptyListAtRequiredTopLevel for exactly that case.



-- 
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