Unexpected Result for RIGHT() function in MPP Execution
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
```sql
CREATE TABLE t0(c0 CHAR(1));
INSERT t0 VALUES('1');
ALTER TABLE t0 SET TIFLASH REPLICA 1;
SELECT * FROM t0 WHERE RIGHT(c0, -1 | 0); -- 0 row, but 1 rows after several seconds
```
This query should return 0 row if we execute the query immediately after `ALTER` statements. It is expected that `RIGHT(c0, -1 | 0)` should not be true. In this case, it uses TiKV storage:
```bash
mysql> EXPLAIN SELECT * FROM t0 WHERE RIGHT(c0, -1 | 0);
+-------------------------+----------+-----------+---------------+-------------------------------------------+
| id | estRows | task | access object | operator info |
+-------------------------+----------+-----------+---------------+-------------------------------------------+
| TableReader_7 | 8000.00 | root | | data:Selection_6 |
| └─Selection_6 | 8000.00 | cop[tikv] | | right(dbtest.t0.c0, 18446744073709551615) |
| └─TableFullScan_5 | 10000.00 | cop[tikv] | table:t0 | keep order:false, stats:pseudo |
+-------------------------+----------+-----------+---------------+-------------------------------------------+
```
However, if we wait until the tables `t0` and `t1` are copied into TIFLASH (5 seconds in my machine) and then execute the query, it returns 1 row.
```bash
mysql> EXPLAIN SELECT * FROM t0 WHERE RIGHT(c0, -1 | 0);
+----------------------------+----------+--------------+---------------+----------------------------------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+----------+--------------+---------------+----------------------------------------------------------+
| TableReader_16 | 8000.00 | root | | MppVersion: 3, data:ExchangeSender_15 |
| └─ExchangeSender_15 | 8000.00 | mpp[tiflash] | | ExchangeType: PassThrough |
| └─Selection_14 | 8000.00 | mpp[tiflash] | | right(dbtest.t0.c0, 18446744073709551615) |
| └─TableFullScan_13 | 10000.00 | mpp[tiflash] | table:t0 | pushed down filter:empty, keep order:false, stats:pseudo |
+----------------------------+----------+--------------+---------------+----------------------------------------------------------+
```
The 1 row is unexpected.
### 2. What did you expect to see? (Required)
{}
### 3. What did you see instead (Required)
{1}
### 4. What is your TiDB version? (Required)
`tiup playground nightly --host 0.0.0.0 --kv 3 --tiflash 3`
```bash
8.0.11-TiDB-v9.0.0-beta.1.pre-554-gb1a5536a64-dirty
```
Contributor guide
Assessment
This issue has not been assessed yet.