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

Wrong Returned Function Result in Tiflash #9664

Closed curry-oss closed 20 hours ago

curry-oss commented 4 days ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS t1;

CREATE TABLE t1 (
  id INT AUTO_INCREMENT PRIMARY KEY,
  col1 DOUBLE,
  INDEX idx_col1 (col1)
);

INSERT INTO t1 (col1) 
VALUES 
  (1.7976931348623157E308),
  (2.2250738585072014E-308),
  (-1.7976931348623157E308),
  (-2.2250738585072014E-308);

ALTER TABLE t1 SET TIFLASH REPLICA 1;

SELECT  /*+ READ_FROM_STORAGE(TIKV[t1]) */ * FROM t1
WHERE col1 <> LOG(1 + col1) * EXP(ROUND(ABS(col1))) + SQRT(ROUND(col1));

SELECT  /*+ READ_FROM_STORAGE(TIFLASH[t1]) */ * FROM t1
WHERE col1 <> LOG(1 + col1) * EXP(ROUND(ABS(col1))) + SQRT(ROUND(col1));

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

I believe that both TiKV and TiFlash should either throw the same errors or return the same accurate values.

3. What did you see instead (Required)

mysql> SELECT  /*+ READ_FROM_STORAGE(TIKV[t1]) */ * FROM    t1 WHERE    col1 <> LOG(1 + col1) * EXP(ROUND(ABS(col1))) + SQRT(ROUND(col1));
ERROR 1690 (22003): DOUBLE value is out of range in 'exp(179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)'
mysql> SELECT  /*+ READ_FROM_STORAGE(TIFLASH[t1]) */ * FROM    t1 WHERE    col1 <>  LOG(1 + col1) * EXP(ROUND(ABS(col1))) + SQRT(ROUND(col1));
+----+--------------------------+
| id | col1                     |
+----+--------------------------+
|  1 |   1.7976931348623157e308 |
|  2 |  2.2250738585072014e-308 |
|  4 | -2.2250738585072014e-308 |
+----+--------------------------+
3 rows in set (0.05 sec)

4. What is your TiDB version? (Required)

TiDB v8.4.0

curry-oss commented 4 days ago

/label affects-8.4 /label affects-8.5

yibin87 commented 20 hours ago

Duplicated with #9654