← Back to Pull requests

fix: relax validation for missing validity buffer when null_count is -1 #942

Merged
and2049 merged 2 files (44 lines) on Sep 15, 2026 19:09 UTC
View on GitHub
and2049 and2049 commented on Sep 15, 2026 06:03 UTC
Author

Allow a missing validity buffer when the null count is unknown, matching
Arrow C++’s import behavior. Arrays reporting a positive null count still
require a validity buffer.

Add regression coverage for unknown null counts with a missing validity
buffer, including sliced arrays and positive-null-count rejection.

Fixes #855

Diff: 44 lines (+43 / -1) across 2 files Reviewer: paleolimbot Review duration: 785m
All Vouch review confidence checks passed
Residual risk 0.02 = Change Risk (0.27) × (1 − Review Confidence (0.93)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.27 · 44 lines diff across 2 files
0.27
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.94 · 3 substantive comment(s)
0.94
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
92%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.228
Real PR Conversation Timeline
6 items
codecov-commenter codecov-commenter commented on Sep 15, 2026 16:06 UTC
Contributor

Codecov Report


:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 78.19%. Comparing base (b896d19) to head (275705f).

<details><summary>Additional details and impacted files</summary>

@@           Coverage Diff           @@
##             main     #942   +/-   ##
=======================================
  Coverage   78.19%   78.19%           
=======================================
  Files         106      106           
  Lines       16843    16843           
  Branches     1985     1985           
=======================================
  Hits        13170    13170           
  Misses       2439     2439           
  Partials     1234     1234           

</details>

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
<details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • </details>

    paleolimbot paleolimbot commented on code on Sep 15, 2026 17:17 UTC
    Code Review
    src/nanoarrow/common/array_test.cc:1
    @@ -2441,6 +2441,70 @@ TEST(ArrayTest, ArrayViewTestBasic) {
       ArrowArrayViewReset(&array_view);
     }
     
    +TEST(ArrayTest, ArrayViewTestMissingValidityUnknownNullCount) {
    +  struct ArrowError error;
    +
    +  // A missing validity buffer with null_count == -1 is valid
    +  int32_t values[] = {11, 12, 13};
    +  const void* buffers[] = {nullptr, values};
    +
    +  nanoarrow::UniqueArray array;
    +  array->length = 2;
    +  array->offset = 1;
    +  array->null_count = -1;
    +  array->n_buffers = 2;
    +  array->n_children = 0;
    +  array->buffers = buffers;
    +  array->children = nullptr;
    +  array->dictionary = nullptr;
    +  array->release = [](struct ArrowArray*) {};
    +
    +  nanoarrow::UniqueArrayView array_view;
    +  ArrowArrayViewInitFromType(array_view.get(), NANOARROW_TYPE_INT32);
    +  ASSERT_EQ(ArrowArrayViewSetArray(array_view.get(), array.get(), &error), NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(
    +      ArrowArrayViewValidate(array_view.get(), NANOARROW_VALIDATION_LEVEL_FULL, &error),
    +      NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(ArrowArrayViewGetBufferView(array_view.get(), 0).size_bytes, 0);
    +  EXPECT_EQ(ArrowArrayViewComputeNullCount(array_view.get()), 0);
    +  EXPECT_EQ(ArrowArrayViewIsNull(array_view.get(), 0), 0);
    +  EXPECT_EQ(ArrowArrayViewIsNull(array_view.get(), 1), 0);
    +  EXPECT_EQ(ArrowArrayViewGetIntUnsafe(array_view.get(), 0), 12);
    +  EXPECT_EQ(ArrowArrayViewGetIntUnsafe(array_view.get(), 1), 13);
    +
    +  // A missing validity buffer with null_count > 0 is still an error
    +  array->null_count = 1;
    +  EXPECT_EQ(ArrowArrayViewSetArray(array_view.get(), array.get(), &error), EINVAL);
    +  EXPECT_STREQ(error.message,
    +               "Expected int32 array buffer 0 to have size >= 1 bytes but found buffer "
    +               "with 0 bytes");
    +
    +  // Same for a string array (["a", "bb", "ccc"])
    +  int32_t offsets[] = {0, 1, 3, 6};
    +  const void* string_buffers[] = {nullptr, offsets, "abbccc"};
    +  array->null_count = -1;
    +  array->n_buffers = 3;
    +  array->buffers = string_buffers;
    +
    +  nanoarrow::UniqueArrayView string_view;
    +  ArrowArrayViewInitFromType(string_view.get(), NANOARROW_TYPE_STRING);
    +  ASSERT_EQ(ArrowArrayViewSetArray(string_view.get(), array.get(), &error), NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(
    +      ArrowArrayViewValidate(string_view.get(), NANOARROW_VALIDATION_LEVEL_FULL, &error),
    +      NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(ArrowArrayViewGetBufferView(string_view.get(), 0).size_bytes, 0);
    +  EXPECT_EQ(ArrowArrayViewComputeNullCount(string_view.get()), 0);
    +  EXPECT_EQ(ArrowArrayViewGetStringUnsafe(string_view.get(), 0), "bb"_asv);
    +  EXPECT_EQ(ArrowArrayViewGetStringUnsafe(string_view.get(), 1), "ccc"_asv);
    +
    +  array->null_count = 1;
    +  EXPECT_EQ(ArrowArrayViewSetArray(string_view.get(), array.get(), &error), EINVAL);

    Can you to use the exact same array as above and just modify the null count? I don't think we need to use a different type here to cover the changed lines.

    paleolimbot paleolimbot commented on Sep 15, 2026 17:18 UTC
    Reviewer

    Thank you!

    One note on the test here...I think you're testing two things but we only need to update the null count to ensure your change is covered.

    and2049 and2049 commented on code on Sep 15, 2026 17:50 UTC
    Code Review
    src/nanoarrow/common/array_test.cc:1
    @@ -2441,6 +2441,70 @@ TEST(ArrayTest, ArrayViewTestBasic) {
       ArrowArrayViewReset(&array_view);
     }
     
    +TEST(ArrayTest, ArrayViewTestMissingValidityUnknownNullCount) {
    +  struct ArrowError error;
    +
    +  // A missing validity buffer with null_count == -1 is valid
    +  int32_t values[] = {11, 12, 13};
    +  const void* buffers[] = {nullptr, values};
    +
    +  nanoarrow::UniqueArray array;
    +  array->length = 2;
    +  array->offset = 1;
    +  array->null_count = -1;
    +  array->n_buffers = 2;
    +  array->n_children = 0;
    +  array->buffers = buffers;
    +  array->children = nullptr;
    +  array->dictionary = nullptr;
    +  array->release = [](struct ArrowArray*) {};
    +
    +  nanoarrow::UniqueArrayView array_view;
    +  ArrowArrayViewInitFromType(array_view.get(), NANOARROW_TYPE_INT32);
    +  ASSERT_EQ(ArrowArrayViewSetArray(array_view.get(), array.get(), &error), NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(
    +      ArrowArrayViewValidate(array_view.get(), NANOARROW_VALIDATION_LEVEL_FULL, &error),
    +      NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(ArrowArrayViewGetBufferView(array_view.get(), 0).size_bytes, 0);
    +  EXPECT_EQ(ArrowArrayViewComputeNullCount(array_view.get()), 0);
    +  EXPECT_EQ(ArrowArrayViewIsNull(array_view.get(), 0), 0);
    +  EXPECT_EQ(ArrowArrayViewIsNull(array_view.get(), 1), 0);
    +  EXPECT_EQ(ArrowArrayViewGetIntUnsafe(array_view.get(), 0), 12);
    +  EXPECT_EQ(ArrowArrayViewGetIntUnsafe(array_view.get(), 1), 13);
    +
    +  // A missing validity buffer with null_count > 0 is still an error
    +  array->null_count = 1;
    +  EXPECT_EQ(ArrowArrayViewSetArray(array_view.get(), array.get(), &error), EINVAL);
    +  EXPECT_STREQ(error.message,
    +               "Expected int32 array buffer 0 to have size >= 1 bytes but found buffer "
    +               "with 0 bytes");
    +
    +  // Same for a string array (["a", "bb", "ccc"])
    +  int32_t offsets[] = {0, 1, 3, 6};
    +  const void* string_buffers[] = {nullptr, offsets, "abbccc"};
    +  array->null_count = -1;
    +  array->n_buffers = 3;
    +  array->buffers = string_buffers;
    +
    +  nanoarrow::UniqueArrayView string_view;
    +  ArrowArrayViewInitFromType(string_view.get(), NANOARROW_TYPE_STRING);
    +  ASSERT_EQ(ArrowArrayViewSetArray(string_view.get(), array.get(), &error), NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(
    +      ArrowArrayViewValidate(string_view.get(), NANOARROW_VALIDATION_LEVEL_FULL, &error),
    +      NANOARROW_OK)
    +      << error.message;
    +  EXPECT_EQ(ArrowArrayViewGetBufferView(string_view.get(), 0).size_bytes, 0);
    +  EXPECT_EQ(ArrowArrayViewComputeNullCount(string_view.get()), 0);
    +  EXPECT_EQ(ArrowArrayViewGetStringUnsafe(string_view.get(), 0), "bb"_asv);
    +  EXPECT_EQ(ArrowArrayViewGetStringUnsafe(string_view.get(), 1), "ccc"_asv);
    +
    +  array->null_count = 1;
    +  EXPECT_EQ(ArrowArrayViewSetArray(string_view.get(), array.get(), &error), EINVAL);

    I've removed the string-array case, and the test now uses the same int32 array and only changes the null count.

    paleolimbot paleolimbot approved these changes on Sep 15, 2026 19:09 UTC
    Approved Reviewer

    Thank you!

    Reviewers
    Assignees
    and2049 and2049
    Labels
    risk: low confidence: 92.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 27.2% (LOW) · Higher = larger blast radius
    27.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 92.7% · Lower = rushed or shallow review
    92.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 2% · Safe to merge
    2%