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

AVG(nulls) returns 0 rather than NULL #5007

Closed
alamb opened this issue Jan 20, 2023 · 0 comments · Fixed by #5008
Closed

AVG(nulls) returns 0 rather than NULL #5007

alamb opened this issue Jan 20, 2023 · 0 comments · Fixed by #5008
Labels
bug Something isn't working

Comments

@alamb
Copy link
Contributor

alamb commented Jan 20, 2023

Describe the bug
Calling the avg function with all null values should be null, not 0

To Reproduce
with datafusion-cli

❯ create table foo as values (null::bigint, 1);
0 rows in set. Query took 0.002 seconds.
❯ select avg(column1) from foo group by column2;
+------------------+
| AVG(foo.column1) |
+------------------+
| 0                |
+------------------+

Expected behavior
AVG of all nulls should be null

postgres=# create table foo as values (null::bigint, 1);
SELECT 1
postgres=# select avg(column1) from foo group by column2;
 avg 
-----
    
(1 row)

Additional context

Found when upgrading IOx in https://github.com/influxdata/influxdb_iox/pull/6639

I think the issue is that there was a bug in the Row evaluator that was not being used until after #4924 was merged

I have a fix and will get it up shortly

@alamb alamb added the bug Something isn't working label Jan 20, 2023
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

Successfully merging a pull request may close this issue.

1 participant