`lpad` and `rpad` with a literal length above `i32::MAX` error on a NULL string or fill
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 77/100
調査の方向性
datafusion/functions/src/unicode/pad.rsから始め、スカラー長の高速パスと配列パスのNULL処理を比較します。既存のstring_literal.sltのケースと、issueで言及されている関連するsplit_partの修正を確認します。NULL文字列またはNULLの埋め込み文字列がある行では、lpadとrpadが大きすぎるリテラル長に対してNULLを返し、関連する引数がNULLでない行では引き続きエラーになる状態を完了条件とします。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
lpad(s, n) on a row where s is NULL and n is above i32::MAX errors when n is a literal, and returns NULL when n comes from a column. A NULL fill behaves the same, and so does rpad. The fast path for a scalar length rejects a length above i32::MAX before it looks at any row. The array path skips rows where any argument is NULL before it checks the length, so it errors only on a row whose string and fill are both non-NULL.
To Reproduce
-- Literal length: the fast path
SELECT lpad(s, 2147483648) AS r FROM (VALUES (NULL::text)) AS t(s);
-- Execution error: lpad requested length 2147483648 too large, maximum allowed length is 2147483647
-- The same row with the length from a column: the array path
SELECT lpad(s, n) AS r FROM (VALUES (NULL::text, 2147483648)) AS t(s, n);
-- NULL
-- A NULL fill with a literal length
SELECT lpad(s, 2147483648, f) AS r FROM (VALUES ('a', NULL::text)) AS t(s, f);
-- Execution error: lpad requested length 2147483648 too large, maximum allowed length is 2147483647
-- The same row with the length from a column
SELECT lpad(s, n, f) AS r FROM (VALUES ('a', 2147483648, NULL::text)) AS t(s, n, f);
-- NULL
The same four queries with rpad give the same results.
Expected behavior
All four return NULL, as the array path does. string_literal.slt already expects NULL for a NULL string or fill with a literal length in range, and #27352 made split_part's fast path return NULL in the same situation (#27276).
Could the fast path skip a length above i32::MAX, as it already skips one above MAX_SCALAR_TARGET_LEN, instead of returning the error? The array path would then return the error for the first row whose string and fill are non-NULL, and NULL for the other rows.
Additional context
Property-based tests found this on main at e2dc8b048b: one row of a call with an array of lengths returned NULL, and the same row called with every argument as a scalar returned the error. The reproduction runs on main at e2dc8b048b. The check in the fast path came with #20657 and moved to pad.rs in #26367.
- 主要言語
- Rust
- スター
- 9.6k
- フォーク
- 2.6k
- 平均マージ
- 3日 5時間
- マージ済み PR(30日)
- 352
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/datafusion のほかの issue
-
`verify-release-candidate.sh` version check doesn't catch `-dev` versions and is skipped on macOS対応中かも @vinycalves が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion#27563 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`MoveTowardsLeafNodes` placement implies speculative evaluation, but the docs don't say so対応中かも @Inf1mum が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/datafusion#27487 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Window constructors panic when the expression list is empty対応中かも @abp002 が 4 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/datafusion#27315 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 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 が 15 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
apache/datafusion#27059 ·
メンテナーはふだん 1 日以内に返信
apache/datafusion の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tinystream-dev/tinystream#132 ·
-
contract good first issue testing
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Emmyt24/nova-launch#2436 ·
メンテナーはふだん 1 日以内に返信