BugReport: Issues with COALESCE function
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず、添付された tidb/tpcd.sql のデータを読み込み、TiDB 8.3.0 に対して両方のクエリを実行して、結果が異なることを確認します。NOT IN と EXCEPT の動作を比較し、そのうえで問題がこのドキュメントリポジトリではなく TiDB にあるのかを判断します。完了とみなすには、診断が確認され、ドキュメントまたは issue が明確に更新されている必要があります。
索引モデルが issue の本文から書いたものです。
説明
BugReport: Issues with COALESCE function
version
8.3.0
Original sql
SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode NOT IN (
SELECT l_commitdate
FROM lineitem
WHERE l_commitdate IS NOT NULL
) AND l_shipmode IS NOT NULL ;
return 0 row
Rewritten sql
SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode IS NOT NULL
AND l_commitdate IS NOT NULL
EXCEPT
SELECT DISTINCT l_shipinstruct, l_extendedprice, l_comment
FROM lineitem
WHERE l_shipmode IN (
SELECT l_commitdate
FROM lineitem
)AND l_shipmode IS NOT NULL
AND l_commitdate IS NOT NULL;
return 5895 row
Analysis
These two queries are logically equivalent, although they are written differently.
The original query uses a NOT IN subquery to filter rows where l_shipmode is not in the set of l_commitdate (where l_commitdate is not NULL) and where l_shipmode is not NULL. Specifically, the query:
- Uses the subquery SELECT l_commitdate FROM lineitem WHERE l_commitdate IS NOT NULL to get all non-NULL values of l_commitdate.
- Excludes rows where l_shipmode is in the result set of this subquery, ensuring that l_shipmode is not in any of those l_commitdate values.
- The condition l_shipmode IS NOT NULL ensures that only rows where l_shipmode is not NULL are returned.
The rewritten query uses an EXCEPT subquery to achieve the same logic:
- The first part of the query returns all rows where both l_shipmode and l_commitdate are not NULL.
- The second part (through EXCEPT) returns all rows where l_shipmode is in the set of l_commitdate, and both l_shipmode and l_commitdate are not NULL.
- The EXCEPT operator excludes the results of the second part, effectively returning all rows where l_shipmode is not in the l_commitdate set and both columns are not NULL.
The two SQL queries are logically equivalent, but they return different results, indicating the presence of a bug.
How to repeat
The exported file for the database is in the attachment. : (https://github.com/LLuopeiqi/newtpcd/blob/main/tidb/tpcd.sql) .
- 主要言語
- Python
- スター
- 616
- フォーク
- 725
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 534
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pingcap/docs のほかの issue
-
scripts/markdownlint deletes the tracked package-lock.json and modifies package.json対応中かも @mjonss が 1 日前に担当しました。 オープンarea/docs-efficiency type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Broken Link Detectedオープン
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
Broken Link Detectedオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsオープンarea: tools documentation good first issue ready for a contributor
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
eyalgolan/statecraft-israel#873 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 5 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信