MapBuilder can't build a MapArray with sorted keys
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 68/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Rust の MapBuilder 実装から始めます。finish_helper は keys_sorted に固定値 false を渡して MapArray::new_unchecked を呼び出しており、make_builder は DataType::Map の sorted フラグを無視しています。with_keys_field および with_values_field の隣に with_keys_sorted(bool) メソッドを追加し、フラグを保存して finish_helper に渡してください。issue の StructBuilder の例がパニックなしでビルドでき、結果の MapArray が keys_sorted を true と報告することをテストで確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
MapBuilder always builds maps with keys_sorted = false. finish_helper passes false to MapArray::new_unchecked and there's no way to change it. make_builder also ignores the flag on DataType::Map(field, sorted).
So a builder made from a schema that has a sorted map field produces a column that doesn't match its own field. Inside a struct it panics:
let fields = vec![Field::new_map(
"m",
"entries",
Field::new("keys", DataType::Utf8, false),
Field::new("values", DataType::Int32, true),
true, // keys_sorted
false,
)];
let mut builder = StructBuilder::from_fields(fields, 1);
builder
.field_builder::<MapBuilder<Box<dyn ArrayBuilder>, Box<dyn ArrayBuilder>>>(0)
.unwrap()
.append(true)
.unwrap();
builder.append(true);
builder.finish();
// panics: Incorrect datatype for StructArray field "m", expected a sorted Map, got an unsorted one
The only workaround today is to finish the map, take it apart with into_parts() and rebuild it with MapArray::new(.., true). That doesn't help when the map is a child of a StructBuilder or ListBuilder, because the parent calls ArrayBuilder::finish on the child itself. Downstream crates end up wrapping MapBuilder just to set the flag.
Describe the solution you'd like
- Add
MapBuilder::with_keys_sorted(bool), next towith_keys_fieldandwith_values_field, defaulting tofalse. - Have
make_builderpass the flag fromDataType::Map.
The builder would only set the flag and not check key order, same as MapArray::try_new.
Describe alternatives you've considered
Validating the order in finish when the flag is set. That would need a comparison over arbitrary key types and would make finish fallible or panicking for something MapArray::try_new doesn't check either, so I'd leave it out.
Additional context
Related: #7100 / #7101 (with_keys_field), #11603 (FFI export dropped the keys sorted flag). I have a branch with the change and tests and can open a PR.
- 主要言語
- Rust
- スター
- 3.7k
- フォーク
- 1.5k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 183
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/arrow-rs のほかの issue
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
`RunArray::try_new` rejects run ends whose null buffer has no nulls対応中かも @Surajsuthar が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/arrow-rs#12427 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Variant] `variant_get` string and binary cast errors show Rust builder type names再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
メンテナーはふだん 1 日以内に返信
-
parquet: GZip/Brotli page decompression is not bounded by the page's uncompressed size対応中かも @Subodh-17 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
apache/arrow-rs の issue をすべて見る
似ている issue
-
area:ui effort:medium enhancement P7 source:agent
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
marketing
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousオープンmaintainer-needed p2 remote triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug help wanted ui
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
userFRM/egui-charts#4605 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信