BugReport: Issues with COALESCE function
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia caricando i dati allegati da tidb/tpcd.sql ed eseguendo entrambe le query su TiDB 8.3.0 per confermare la differenza nei risultati. Confronta il comportamento di NOT IN ed EXCEPT, quindi determina se il problema riguarda TiDB invece di questo repository della documentazione; il lavoro è completato solo quando sono disponibili una diagnosi confermata e un aggiornamento chiaro della documentazione o dell'issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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) .
- Lingua principale
- Python
- Stelle
- 615
- Fork
- 724
- Merge medio
- 1g 4h
- PR unite (30g)
- 521
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pingcap/docs
-
area/docs-efficiency type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Broken Link DetectedAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Broken Link DetectedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pingcap/docs
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Deltares/imod-python#1940 ·
I maintainer di solito rispondono entro 1 giorno
-
effort: low prio: low ready
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
digitalfabrik/integreat-cms#4621 ·
I maintainer di solito rispondono entro 5 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
ioos/compliance-checker#1375 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno