`split_part` with position 0 errors on a NULL string only when the position is a literal
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- backend, databases, testing-qa
調査の方向性
Start with datafusion/functions/src/string/split_part.rs, especially the fast path and the array path identified in the issue, then review the expr.slt case around the reported test. Decide how the fast path should behave when every string is NULL, using the stated PostgreSQL strictness expectation and the prior review discussion as context. Update the regression test to reflect the chosen behavior and verify the literal and column position cases agree.
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
split_part(s, delimiter, 0) on a row where s is NULL returns NULL when the position comes from a column, and errors with "field position must not be zero" when the position is a literal. The fast path for an array string with a scalar delimiter and position rejects position 0 before it looks at any row. The array path skips rows where any argument is NULL, so it errors only on a row whose three arguments are all non-NULL. The two paths disagree whenever no row has a non-NULL string, such as a batch whose strings are all NULL.
To Reproduce
-- Literal delimiter and position: the fast path
SELECT split_part(s, '.', 0) AS r FROM (VALUES (NULL::text)) AS t(s);
-- Execution error: field position must not be zero
-- The same row with the position from a column: the array path
SELECT split_part(s, '.', p) AS r FROM (VALUES (NULL::text, 0)) AS t(s, p);
-- NULL
-- Only literals
SELECT split_part(NULL::text, '.', 0) AS r;
-- NULL
Expected behavior
All three return NULL. PostgreSQL's split_part is strict: its pg_proc entry leaves proisstrict at its default of true, so a NULL argument returns NULL without calling the function.
expr.slt expects the first query's error ("Position 0 with column input errors even for empty/null inputs"), while the review of #21238 asked for the fast path to match the array path (discussion_r3030106101). Which behavior is intended? If it is NULL, the fast path could return all NULLs when the string array has no valid row before checking the position, and the expr.slt case would expect NULL.
Additional context
Property-based tests found this on main at 14b3edd9a3: calling split_part with an array string and scalar delimiter and position gave an error, and the same call with every argument as an array gave NULL. The reproduction runs on main at 14b3edd9a3. The fast path came with #21238.
- 主要言語
- Rust
- スター
- 9.6k
- フォーク
- 2.6k
- 平均マージ
- 3日 4時間
- マージ済み PR(30日)
- 345
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#27315 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#27094 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yaml対応中かも @jonasHanhan が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#27059 ·
メンテナーはふだん 1 日以内に返信
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column stats対応中かも @joseph-isaacs が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#27050 ·
メンテナーはふだん 1 日以内に返信
-
physical-plan: decoding an Unnest or Explain node with an unset field panics対応中かも @geoHeil が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/datafusion#26999 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion の issue をすべて見る
似ている issue
-
area:schema documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ElectronicWave/Elemental#252 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dekobon/big-code-analysis#1887 ·
メンテナーはふだん 1 日以内に返信
-
Shell中文符号输入异常オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信