Copilot commented on code in PR #55704:
URL: https://github.com/apache/arrow/pull/55704#discussion_r4652103418
##########
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:
The nullable-field guard still allows present empty lists to be silently
padded when the field is required. For example, a top-level REQUIRED LIST with
stored Arrow size 2 and rows `[1, 2], [], [3, 4]` produces offsets `[0, 2, 2,
4]`; this branch returns `[1, 2], [null, null], [3, 4]` instead of the previous
size-mismatch error, even though no ancestor can be null. Please use definition
levels or ancestor validity to distinguish absent ancestors from present empty
lists, and extend the rejection regression to a REQUIRED list.
--
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]