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

Incorrect results when using grouping sets with data containing nulls #12570

Closed
eejbyfeldt opened this issue Sep 21, 2024 · 0 comments · Fixed by #12571
Closed

Incorrect results when using grouping sets with data containing nulls #12570

eejbyfeldt opened this issue Sep 21, 2024 · 0 comments · Fixed by #12571
Labels
bug Something isn't working

Comments

@eejbyfeldt
Copy link
Contributor

Describe the bug

When doing a grouping set on columns with null values we produce the incorrect result.

To Reproduce

Run the following in query in datafusion-cli

> CREATE TABLE integers_with_nulls (value INT) as VALUES (1), (NULL);

0 row(s) fetched. 
Elapsed 0.016 seconds.

> SELECT value, min(value) FROM integers_with_nulls GROUP BY CUBE(value);

+-------+--------------------------------+
| value | min(integers_with_nulls.value) |
+-------+--------------------------------+
| 1     | 1                              |
|       | 1                              |
+-------+--------------------------------+

Expected behavior

The expected bevahior is that the null in the data creates a different group from the nulls from the grouping set. The exected results are

> SELECT value, min(value) FROM integers_with_nulls GROUP BY CUBE(value);
+-------+--------------------------------+
| value | min(integers_with_nulls.value) |
+-------+--------------------------------+
| 1     | 1                              |
|       | 1                              |
|       |                                |
+-------+--------------------------------+

This is the behavior in PostgresSQL, Spark and DuckDB (and most likely other query engines).

Additional context

No response

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