Skip to content

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
# 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: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