Bug Report: Issues with CASE operation
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza cargando la base de datos tidpcd.sql adjunta y ejecutando ambas consultas en TiDB 8.3.0, comparando sus resultados y el comportamiento de la reescritura de CASE. Se considera terminado cuando la discrepancia en el número de filas se puede reproducir, se ha identificado su causa y se ha documentado el resultado esperado o la corrección.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
BugReport: Issues with CASE operation
version
8.3.0
Original sql
select all lineitem.l_shipmode as ref0, lineitem.l_tax as ref1 from lineitem
where (lineitem.l_shipinstruct) > 100
group by lineitem.l_shipmode, lineitem.l_tax;
return 0 row
Rewritten sql
SELECT l_extendedprice, l_orderkey, l_discount FROM lineitem
WHERE CASE
WHEN l_quantity IS NOT NULL THEN CAST(l_quantity AS decimal(15,2))
WHEN l_suppkey IS NOT NULL THEN CAST(l_suppkey AS unsigned)
else 0.21501538554113775
END <= l_returnflag
GROUP BY l_orderkey, l_extendedprice, l_discount
return 72 row
Analysis
These two queries are logically equivalent, although they are written differently.
Original Query: The original query filters rows using the condition lineitem.l_shipinstruct > 100 and groups them by lineitem.l_shipmode and lineitem.l_tax. Since 100 is a constant, it is directly used to compare with lineitem.l_shipinstruct.
Rewritten Query: In the rewritten query, a CASE expression is used for conditional checking. It first checks if 100 is NULL, which it isn't, so it directly returns 100. If 100 were NULL (which is not the case here), it would perform further checks and ultimately choose lineitem.l_discount or lineitem.l_commitdate. Therefore, although the rewritten query introduces the CASE statement, the logic is equivalent to the original query, as both compare lineitem.l_shipinstruct with 100.
The two SQL queries are logically equivalent. Unexpectedly, the number of returned rows is different, 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) .
- Lenguaje dominante
- Python
- Estrellas
- 616
- Forks
- 724
- Merge medio
- 2 d 5 h
- PR fusionados (30 d)
- 168
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de pingcap/docs
-
Weekly keywords check: mismatches foundPosiblemente ocupada @saryn17 la tomó hace 57 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Broken Link DetectedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Weekly keywords check: mismatches foundPosiblemente ocupada @saryn17 la tomó hace 57 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Broken Link DetectedAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
tidb-cloud: Terraform import procedures need Terraform v1.5.0 or later, but the prerequisite says >=1.0Posiblemente ocupada @yahonda la tomó hace 5 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
Todos los issues de pingcap/docs
Issues similares
-
area:security effort:S priority:P3 status:needs-triage type:chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
randomparity/kdive#3657 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aws/mcp-proxy-for-aws#476 ·
Los mantenedores suelen responder en 1 día
-
fix(cli): a --root that does not exist exits 0 with 'Scanned 0 file(s)', so a wrong path in CI passes silentlyPosiblemente ocupada @arpanjot-coding la tomó hoy. Abiertoarea: runtime automation bug cli code-scanning consistency developer-experience difficulty: easy github-actions good first issue help wanted json-output priority: P3 python sarif silent-failure static-analysis tests
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
ContainsOnly raises TypeError for unhashable input with set-based choicesPosiblemente ocupada @prathamchoksi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
marshmallow-code/marshmallow#3115 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día