pingcap / tiflash

The analytical engine for TiDB and TiDB Cloud. Try free: https://tidbcloud.com/free-trial
https://docs.pingcap.com/tidb/stable/tiflash-overview
Apache License 2.0
948 stars 410 forks source link

FROM_UNIXTIME parameter range is inconsistent on tidb and tiflash #6023

Open keeplearning20221 opened 2 years ago

keeplearning20221 commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

> create table tfrom_unixtime(tchar varchar(40));
> ALTER table tfrom_unixtime SET tiflash replica 1;
> insert into tfrom_unixtime values("32536771199.1");
> SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+----------------------+
| FROM_UNIXTIME(tchar) |
+----------------------+
| NULL                 |
+----------------------+
> set @@tidb_allow_mpp=0; set @@tidb_enforce_mpp=0 ;
> SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+----------------------------+
| FROM_UNIXTIME(tchar)       |
+----------------------------+
| 3001-01-19 07:59:59.100000 |
+----------------------------+
1 row in set (0.03 sec)

2. What did you expect to see? (Required)

The results of tidb and tiflash should be same

+----------------------------+
| FROM_UNIXTIME(tchar)       |
+----------------------------+
| 3001-01-19 07:59:59.100000 |
+----------------------------+

3. What did you see instead (Required)

tiflash:

> SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+----------------------+
| FROM_UNIXTIME(tchar) |
+----------------------+
| NULL                 |
+----------------------+

tidb:

> SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+----------------------------+
| FROM_UNIXTIME(tchar)       |
+----------------------------+
| 3001-01-19 07:59:59.100000 |
+----------------------------+

4. What is your TiFlash version? (Required)

TiFlash
Release Version: v6.2.0-alpha-353-gf8ab1f1-dirty
Edition:         Community
Git Commit Hash: f8ab1f179d3273b579520e528ceecdcb79b76d5f
Git Branch:      master
UTC Build Time:  2022-09-15 02:26:04
Enable Features: jemalloc failpoints avx avx512 unwind
Profile:         DEBUG

Raft Proxy
Git Commit Hash:   91c7f1ec241f1e40b76c55c1cde70b048adc4a2f
Git Commit Branch: HEAD
UTC Build Time:    2022-09-15 01:35:32
Rust Version:      rustc 1.60.0-nightly (1e12aef3f 2022-02-13)
Storage Engine:    tiflash
Prometheus Prefix: tiflash_proxy_
Profile:           release
LittleFall commented 2 years ago

plan:

with mpp NULL

mysql> explain SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+---------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
| id                        | estRows | task         | access object        | operator info                                                                  |
+---------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
| TableReader_11            | 1.00    | root         |                      | data:ExchangeSender_10                                                         |
| └─ExchangeSender_10       | 1.00    | mpp[tiflash] |                      | ExchangeType: PassThrough                                                      |
|   └─Projection_4          | 1.00    | mpp[tiflash] |                      | from_unixtime(cast(test.tfrom_unixtime.tchar, decimal(40,0) BINARY))->Column#3 |
|     └─TableFullScan_9     | 1.00    | mpp[tiflash] | table:tfrom_unixtime | keep order:false, stats:pseudo                                                 |
+---------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
4 rows in set (0.00 sec)

without mpp 3001-01-19 07:59:59.000000

mysql> explain SELECT FROM_UNIXTIME(tchar) from tfrom_unixtime ;
+-------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
| id                      | estRows | task         | access object        | operator info                                                                  |
+-------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
| Projection_3            | 1.00    | root         |                      | from_unixtime(cast(test.tfrom_unixtime.tchar, decimal(40,0) BINARY))->Column#3 |
| └─TableReader_7         | 1.00    | root         |                      | data:TableFullScan_6                                                           |
|   └─TableFullScan_6     | 1.00    | cop[tiflash] | table:tfrom_unixtime | keep order:false, stats:pseudo                                                 |
+-------------------------+---------+--------------+----------------------+--------------------------------------------------------------------------------+
3 rows in set (0.00 sec)