pingcap / pingcap/tidb

TiFlash ELT function doesn't handle correctly when Nth argument's null

Open
#57,852 5 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 DOUBLE UNSIGNED NULL , c1 DOUBLE NULL , c2 NUMERIC UNSIGNED );
REPLACE INTO t0 VALUES (0.1, 0.1, 1);
INSERT INTO t0(c0, c2) VALUES (NULL, 1);
INSERT IGNORE INTO t0(c0) VALUES (-1.1), (0.1);
ALTER TABLE t0 SET TIFLASH REPLICA 1;
```
execute query
```sql
SELECT /*+ read_from_storage(tikv[t0]) */ t0.c1 FROM t0 WHERE ELT((t0.c0)<=(t0.c1), t0.c2, t0.c0, 1, CAST(t0.c1 AS DOUBLE), -1);
SELECT /*+ read_from_storage(tiflash[t0]) */ t0.c1 FROM t0 WHERE ELT((t0.c0)<=((t0.c1)), t0.c2, t0.c0, 1, CAST(t0.c1 AS DOUBLE), -1);
```

### 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/eac2386d-206a-4847-a71b-99b87eaeebd6)
Query2:
![Image](https://github.com/user-attachments/assets/51a9f5c7-7718-4ccd-b734-2dea98a5e1be)

### 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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.