Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COUNT(1) in pre-agg for AVG is wrong #1300

Closed
anhqle opened this issue Jan 31, 2025 · 0 comments
Closed

COUNT(1) in pre-agg for AVG is wrong #1300

anhqle opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@anhqle
Copy link
Contributor

anhqle commented Jan 31, 2025

Currently, when we perform pre-aggregation for AVG, we use SUM(expression) / COUNT(1).

COUNT(1) will give the count of another column, which may have a different number of non-null values than the one we're interested in.

For example:

day | measure

1 | 1
2 | 1
3 | NULL

The correct COUNT(measure) is 2, but COUNT(1) is 3 instead.

@shangyian shangyian added the bug Something isn't working label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants