pingcap / pingcap/tidb

Unexpected Result in Windows Function inTiFlash

Open
#61,664 3 comments 0 reactions 0 assignees View on GitHub
fuzz/sqlancer impact/wrong-result may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/execution type/bug
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 INT);
INSERT INTO t0 (c0) VALUES (1);
ALTER TABLE t0 SET TIFLASH REPLICA 1;
SELECT AVG(0) OVER(ORDER BY c0) FROM t0; -- {20813.5040}
```
This query should return `0`, because ```AVG(0)=0```. However, executing the above query with MPP in TiFlash returns a non-zero number, which is unexpected.

The plan is as follow:
```sql
id estRows task access object operator info
TableReader_25 10000.00 root MppVersion: 3, data:ExchangeSender_24
└─ExchangeSender_24 10000.00 mpp[tiflash] ExchangeType: PassThrough
└─Projection_8 10000.00 mpp[tiflash] Column#4->Column#5
└─Window_23 10000.00 mpp[tiflash] avg(0)->Column#4 over(order by testdb.t0.c0 range between unbounded preceding and current row)
└─Sort_14 10000.00 mpp[tiflash] testdb.t0.c0
└─ExchangeReceiver_13 10000.00 mpp[tiflash]
└─ExchangeSender_12 10000.00 mpp[tiflash] ExchangeType: PassThrough, Compression: FAST
└─TableFullScan_11 10000.00 mpp[tiflash] table:t0 keep order:false, stats:pseudo
```

### 2. What did you expect to see? (Required)
{0}

### 3. What did you see instead (Required)
{20813.5040}

### 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

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.