`RunArray::try_new` rejects run ends whose null buffer has no nulls

オープン 初心者向け
#12,427 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
data

調査の方向性

arrow-array/src/array/run_array.rs の RunArray::try_new 内にある null チェック(176-182 行目)から始め、null バッファが存在するかどうかではなく run_ends.null_count() != 0 をテストするように変更してください。issue のスニペットで再現し、次に NullBuffer::new_valid を持つ run_ends 配列のテストを追加してください。arrow-data/src/data.rs の ArrayData チェックを読んで、それが依然として成り立つことを確認してください。再現コードが Ok(3) を返し、cargo test -p arrow-array run_array が通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

RunArray::try_new returns "Found null values in run_ends array" when run_ends has a null buffer with a null count of 0. It checks whether a null buffer is present, not whether any value is null. A PrimitiveArray can carry such a buffer: PrimitiveArray::new with NullBuffer::new_valid, slice of an array whose nulls fall outside the slice, and concat of a single array all produce one.

ArrayData validation has the same check, and it holds there, because ArrayDataBuilder::build drops a null buffer with no nulls.

To Reproduce
use arrow_array::types::Int32Type;
use arrow_array::{Array, Int32Array, RunArray};
use arrow_buffer::NullBuffer;

fn main() {
    let run_ends = Int32Array::new(vec![2, 3].into(), Some(NullBuffer::new_valid(2)));
    let values = Int32Array::from(vec![7, 8]);
    println!("{}", run_ends.null_count());
    // 0
    println!("{:?}", RunArray::<Int32Type>::try_new(&run_ends, &values).map(|a| a.len()));
    // Err(InvalidArgumentError("Found null values in run_ends array. The run_ends array should not have null values."))
}
Expected behavior

Ok(3). Checking run_ends.null_count() != 0 instead of run_ends.nulls().is_some() would accept it and still reject run ends that hold a null.

Additional context

#12420 makes cast to the same type, shift by 0, and nullif of an empty array return the input's null buffer instead of dropping one with no nulls, so their output reaches this check more often.

Found while checking #12420 with property-based tests, on main at 6a3f719f.

主要言語
Rust
スター
3.7k
フォーク
1.5k
平均マージ
2日 11時間
マージ済み PR(30日)
195

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/arrow-rs のほかの issue

apache/arrow-rs の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。