pingcap / pingcap/tidb

When executing the DATE_FORMAT function, TiDB returns unexpected results

Open
#52,937 3 comments 0 reactions 0 assignees View on GitHub
affects-8.1 may-affects-5.4 may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 severity/moderate 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)

```SQL
CREATE TABLE t0 (
c0 double NOT NULL,
UNIQUE (c0)
);

INSERT INTO t0 VALUES (0), (0.06771666817351274), (748334112), (1747356538);

SELECT t0.c0 FROM t0 GROUP BY t0.c0 HAVING DATE_FORMAT(t0.c0, t0.c0) IS NULL;
```

### 2. What did you expect to see? (Required)
```SQL
+------------+
| c0 |
+------------+
| 748334112 |
| 1747356538 |
+------------+
```
### 3. What did you see instead (Required)
```SQL
MySQL> SELECT t0.c0 FROM t0 GROUP BY t0.c0 HAVING DATE_FORMAT(t0.c0, t0.c0) IS NULL;
+---------------------+
| c0 |
+---------------------+
| 0.06771666817351274 |
| 748334112 |
| 1747356538 |
| 0 |
+---------------------+
4 rows in set, 7 warnings (0.003 sec)
```

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

```SQL
MySQL> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.0.0
Edition: Community
Git Commit Hash: 8ba1fa452b1ccdbfb85879ea94b9254aabba2916
Git Branch: HEAD
UTC Build Time: 2024-03-28 14:22:04
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.002 sec)
```

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.