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

refactor "group by" to use embedded documents #168

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

WaVEV
Copy link
Collaborator

@WaVEV WaVEV commented Oct 21, 2024

A new approach to compute group by using get project. This implementation simplifies group by, now it does not need GROUP_SEPARATOR and fold and unfold method.

Currently the foreign field are compute like:

'_id': {'T3___age': '$T3.age', 'age': '$age', 'name': '$name'}

With this changes:
'_id': {'T3': {'age': '$T3.age'}, 'age': '$age', 'name': '$name'}

@WaVEV WaVEV requested a review from timgraham October 21, 2024 04:23
@timgraham timgraham changed the title Refactor group by as embedded doc. refactor "group by" to use embedded documents Oct 21, 2024
@@ -526,11 +494,13 @@ def get_combinator_queries(self):
for alias, expr in main_query_columns:
# Unfold foreign fields.
if isinstance(expr, Col) and expr.alias != self.collection_name:
ids[self._unfold_column(expr)] = expr.as_mql(self, self.connection)
if expr.alias not in ids:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ids = defaultdict(dict) to avoid this?

@timgraham timgraham merged commit 56cd604 into mongodb-labs:main Oct 21, 2024
3 checks passed
@WaVEV WaVEV deleted the refactor-group-by-as-embedded-doc branch October 21, 2024 23:13
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