Bug Report: Issues with IF function
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Comece carregando os dados anexados de tidb/tpcd.sql e executando ambas as consultas SQL no TiDB 8.3.0, comparando seus conjuntos de resultados e o comportamento das expressões IF/IN. A tarefa estará concluída quando for identificado por que consultas logicamente equivalentes diferem e for confirmado que o mesmo caso produz resultados consistentes após a correção.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
BugReport: Issues with IF function
version
8.3.0
Original sql
SELECT
O_CUSTKEY
FROM
orders
WHERE
(
O_COMMENT IN (
IF(
-1801656545 IS NOT NULL,
-1801656545,
)
)
) = 0.24036834733741486
GROUP BY
O_CUSTKEY ;
return 0 row
Rewritten sql
SELECT O_CUSTKEY
FROM orders
WHERE NOT EXISTS (
SELECT 1
WHERE O_COMMENT <> -1801656545 OR O_COMMENT IS NULL
) = 0.24036834733741486
GROUP BY O_CUSTKEY ;
return 101 row
Analysis
These two queries are logically equivalent, although they are written differently.
Original Query: The original query uses the IF function to check if -1801656545 is not NULL. If it is not NULL, it returns -1801656545; otherwise, it would return NULL (though in this specific query, -1801656545 is never NULL). It then uses IN to check if O_COMMENT matches the returned value and compares the result with 0.24036834733741486 to filter rows.
Rewritten Query: In the rewritten query, the NOT EXISTS subquery is used to check if O_COMMENT is not equal to -1801656545 or is NULL, which is logically equivalent to the IN check in the original query. The final result of the NOT EXISTS subquery is then compared with 0.24036834733741486 to filter the rows.
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) .
- Linguagem predominante
- Python
- Estrelas
- 616
- Forks
- 724
- Merge médio
- 2d 5h
- PRs com merge (30d)
- 168
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de pingcap/docs
-
Weekly keywords check: mismatches foundTalvez já em andamento @saryn17 assumiu há 57 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Broken Link DetectedAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia
-
Weekly keywords check: mismatches foundTalvez já em andamento @saryn17 assumiu há 57 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia
-
Broken Link DetectedAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia
-
tidb-cloud: Terraform import procedures need Terraform v1.5.0 or later, but the prerequisite says >=1.0Talvez já em andamento @yahonda assumiu há 5 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
Todas as issues de pingcap/docs
Issues semelhantes
-
area:security effort:S priority:P3 status:needs-triage type:chore
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
randomparity/kdive#3657 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
aws/mcp-proxy-for-aws#476 ·
Mantenedores costumam responder em até 1 dia
-
fix(cli): a --root that does not exist exits 0 with 'Scanned 0 file(s)', so a wrong path in CI passes silentlyTalvez já em andamento @arpanjot-coding assumiu hoje. Abertaarea: 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
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
ContainsOnly raises TypeError for unhashable input with set-based choicesTalvez já em andamento @prathamchoksi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
marshmallow-code/marshmallow#3115 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia