这是indexloc提供的服务,不要输入任何密码
Skip to content

unify and optimize count aggregations over grouped and ungrouped data #146

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

Conversation

hallettj
Copy link
Collaborator

The logic for count aggregations for grouped data in #145 was an improvement over what was already in place for ungrouped data. Instead of leaving two separate code paths with different logic I unified logic for both to use the new logic from #145.

This allowed removing unnecessary uses of the $facet stage which forks the aggregation pipeline. Previously every aggregate used a separate facet. Now we only need facets for incompatibly-grouped data - one query that combines ungrouped aggregates with groups, or that combines either of those with field selection. This required additional changes to response processing to remove facet unpacking logic. The new system does mean that there are a couple of places where we have to explicitly fill in null or zero results for aggregate queries with no matching rows.

While I was going over aggregate logic I noticed some unescaped field references when referencing aggregate result names. I fixed these to use ColumnRef which escapes names. While I was at it I removed the last couple of uses of the old getField helper, and replaced them with the new-and-improved ColumnRef.

@hallettj hallettj force-pushed the jessehallett/eng-1568-mongodb-implement-count-for-group-by branch from 0a7a13a to fceb283 Compare March 3, 2025 18:03
Base automatically changed from jessehallett/eng-1568-mongodb-implement-count-for-group-by to main March 3, 2025 18:41
@hallettj hallettj force-pushed the jessehallett/eng-1465-mongodb-make-sure-count-by-distinct-works-correctly branch from 2cb3829 to 1849cbe Compare March 3, 2025 18:49
@hallettj hallettj merged commit 0c5d336 into main Mar 3, 2025
1 check passed
@hallettj hallettj deleted the jessehallett/eng-1465-mongodb-make-sure-count-by-distinct-works-correctly branch March 3, 2025 23:53
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.

2 participants