pingcap / pingcap/tidb

TiFlash may treats float32 constant value as 0 when type mismatches

Open
#57,851 4 comments 0 reactions 0 assignees View on GitHub
may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
prepare data
```sql
drop table if exists t0;
CREATE TABLE t0(c0 NUMERIC , c1 NUMERIC , c2 TEXT );

INSERT INTO t0 VALUES (1, 1, '1');
ALTER TABLE t0 SET TIFLASH REPLICA 1;
```
execute query
```sql
SELECT /*+ read_from_storage(tikv[t0]) */ t0.c2, t0.c0
FROM t0
WHERE (CASE
(((CASE 'c2'
WHEN t0.c0 THEN t0.c0
ELSE -1
END ))&(((2)NOT LIKE(t0.c1))))
WHEN true
THEN CAST((~ ('1111111111')) AS float )
ELSE false
END );

SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c2, t0.c0
FROM t0
WHERE (CASE
(((CASE 'c2'
WHEN t0.c0 THEN t0.c0
ELSE -1
END ))&(((2)NOT LIKE(t0.c1))))
WHEN true
THEN CAST((~ ('1111111111')) AS float )
ELSE false
END );
```

### 2. What did you expect to see? (Required)
The results of the two queries are equal.

### 3. What did you see instead (Required)
Query1:
![Image](https://github.com/user-attachments/assets/e983e1b8-8456-4486-ad08-935670d02f6e)
Query2: empty
### 4. What is your TiDB version? (Required)

Release Version: v8.4.0
Edition: Community
Git Commit Hash: 1a9f0fa25580907d3266dc3edf000ba24379a600
Git Branch: HEAD
UTC Build Time: 2024-11-07 15:18:43
GoVersion: go1.23.2
Race Enabled: false
Check Table Before Drop: false
Store: tikv

Contributor guide

Open the contributing guide

Research direction

Start by running the TiKV and TiFlash SQL queries from the reproduction against TiDB v8.4.0 and compare their results. Trace the handling of the float32 constant and type mismatch in the TiFlash execution path; done means both queries return equal results for the supplied case.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.