pingcap / pingcap/tidb

TiFlash cast as datetime behaves differently with tidb for unnormal cases

Open
#57,740 3 comments 0 reactions 0 assignees View on GitHub
severity/minor 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;
drop table if exists t1;
CREATE TABLE t0(c0 NUMERIC ZEROFILL CHECK (c0) );
CREATE TABLE t1 LIKE t0;
INSERT IGNORE INTO t1(c0) VALUES (-1),(-2), (-3);
INSERT IGNORE INTO t0 VALUES (-395169765);
ALTER TABLE t0 SET TIFLASH REPLICA 1;
ALTER TABLE t1 SET TIFLASH REPLICA 1;
```
execute query
```sql
SELECT /*+ read_from_storage(tikv[t1]) */ t0.c0 FROM t1 RIGHT OUTER JOIN t0 ON (NOT (CAST(CAST(t1.c0 AS SIGNED) AS DATETIME)));
SELECT /*+ read_from_storage(tiflash[t1]) */ t0.c0 FROM t1 RIGHT OUTER JOIN t0 ON (NOT (CAST(CAST(t1.c0 AS SIGNED) AS DATETIME)));
```

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

### 3. What did you see instead (Required)
Query1 result:
![Image](https://github.com/user-attachments/assets/05d4b946-2435-489d-9780-077383fd5f18)

Query2 result:
![Image](https://github.com/user-attachments/assets/0afca810-5f2b-4de3-a722-8b46100f5759)

### 4. What is your TiDB version? (Required)

Release Version: v8.4.0
Edition: Community
Git Commit Hash: https://github.com/pingcap/tidb/commit/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.