Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

BugReport: Issues with COALESCE function

Aperta
#19,478 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
sql
Ambito
databases

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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pingcap/docs

Tutte le issue di pingcap/docs

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.