apache / apache/iotdb

[Bug] 使用 GROUP BY LEVEL 搭配多個聚合函數時,結果出現不一致(sum / avg / count 異常)

Open
#17,409 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.4k
Forks
1.2k
Avg merge
1d 23h
Merged PRs (30d)
115

Description

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/iotdb/issues) and found nothing similar.

### Version

2.0.7

### Describe the bug and provide the minimal reproduce step

在 IoTDB 中使用 GROUP BY LEVEL 查詢時,當同時使用多個聚合函數(如 sum、avg、count)會出現結果不一致的情況。

具體問題如下:

- sum(cpu) 單獨查詢與搭配其他 aggregation 時,結果不同
- avg(cpu) 與 count(cpu) 的結果也會異常變化
- 同一筆資料在不同 aggregation 組合下,計算基準似乎不一致

### Query 1: 僅查 sum(結果正常)
Image

### Query 2: sum + avg(sum 變成 2 倍)
Image

### Query 3: sum + avg + count(全部異常)
Image

### Query 4: sum + count(結果又正常)
Image

### What did you expect to see?

- 不論 aggregation function 組合如何:
- sum(cpu) 應該一致
- count(cpu) 應該一致
- avg(cpu) 應滿足:
👉 avg = sum / count
- 多個 aggregation 應基於同一批資料計算

### What did you see instead?

Image

### Anything else?

_No response_

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the four GROUP BY LEVEL aggregation combinations described for IoTDB 2.0.7, using the screenshots to compare sum, avg, and count. The report does not name source files, tests, or provide executable SQL and sample data; done means the same input produces consistent aggregates across all combinations, with regression coverage added in the relevant query test area.

Written by the indexing model from the issue text.

Assessment

Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.