Wrong results: `ORDER BY ... NULLS LAST` on a running `MAX` window function puts the NULL row first
メンテナーはふだん 1 日以内に返信
@itang06 がすでに取り組んでいます。
2026年11月11日 から。
評価
この issue はまだ評価されていません。
説明
Describe the bug
A query that computes MAX(x) OVER (ORDER BY ts) and then sorts on that column with ASC NULLS LAST returns rows in the wrong order when x contains NULLs. The NULL row is returned first, where the query asked for it last.
The same wrong order appears for:
MIN(x) OVER (ORDER BY ts)sortedDESC NULLS LASTMAX(x) OVER (ORDER BY ts ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)sortedDESC NULLS FIRST
To Reproduce
set datafusion.execution.target_partitions = 1;
CREATE TABLE t(ts INT, x INT) AS VALUES (1, NULL), (2, 3), (3, 1), (4, 5);
SELECT ts, m
FROM (
SELECT ts, MAX(x) OVER (ORDER BY ts) AS m
FROM (SELECT * FROM t ORDER BY ts)
)
ORDER BY m ASC NULLS LAST;
Returns:
+----+------+
| ts | m |
+----+------+
| 1 | NULL | <-- NULL is first, not last!
| 2 | 3 |
| 3 | 3 |
| 4 | 5 |
+----+------+
Expected behavior
NULLS LAST means the NULL row comes after every non-NULL value:
+----+------+
| ts | m |
+----+------+
| 2 | 3 |
| 3 | 3 |
| 4 | 5 |
| 1 | NULL |
+----+------+
Additional context
EXPLAIN shows the final sort on m is removed, so the planner believes the window output already satisfies m ASC NULLS LAST. Reproduced on main at 94486b1e93.
Found by @jayzhan211 while reviewing the EquivalenceProperties docs in #27250. The original report and repro are in this review comment: https://github.com/apache/datafusion/pull/27250#discussion_r4512590554
- 主要言語
- 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
-
P3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
HerringtonDarkholme/hd-lang#1770 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
jonathanong/no-mistakes#3332 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
swc-project/swc-next-issues#310 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
swc-project/swc-ai-issues#653 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
lbjlaq/Antigravity-Manager#3937 ·
メンテナーはふだん 1 日以内に返信