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

Return empty results in group by when input is empty #1279

Conversation

forestfang-stripe
Copy link
Contributor

fixes #927

We currently have a fallback check on empty query.groups so that we can populate aggregate function default value in a non-groupby SELECT. i.e. SELECT COUNT(1) as c FROM ? WHERE 1 = 2 should return [{c:0}].

However, query.groups can also be empty if there is no input data to group by. In this case, we would expect AlaSQL (and other SQL engines indeed) to not return anything instead of emitting an undefined group. Add an additional check to verify that allgroups are empty, that is, there were no GROUP BY clause.

@mathiasrw
Copy link
Member

Thank you!

@mathiasrw mathiasrw changed the title return empty results in group by when input is empty Return empty results in group by when input is empty Jan 8, 2021
@mathiasrw mathiasrw merged commit 6ceefd4 into AlaSQL:develop Jan 8, 2021
@forestfang-stripe forestfang-stripe deleted the forestfang--groupby-empty-results branch January 8, 2021 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to return empty array if no results?
2 participants