[SERVER-59303] Support limit expression for $filter in SBE Created: 11/Aug/21  Updated: 06/Dec/22  Resolved: 18/Aug/21

Status: Closed
Project: Core Server
Component/s: Query Execution
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Eric Cox (Inactive) Assignee: Backlog - Query Execution
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-32739 allow limit in $filter expression Closed
Assigned Teams:
Query Execution
Participants:

 Description   

This invariant is firing in the visit overload for ExpressionFilter during translation of a $filter during work in SERVER-32739.

https://github.com/10gen/mongo/blob/master/src/mongo/db/query/sbe_stage_builder_expression.cpp#L522

A possible explanation for this is that the expression walker will make the following calls since $filter has multiple children,

preVisit(), inVisit(), inVisit(), postVisit.

On the first inVisit() call we pull the variableId from the ExpressionFilter instance that we are translating, and stick it in _context->environment. Then on the second inVisit call we pull the same variableId from the ExpressionFilter instance and since we have already inserted the variableId into the environment, we trip the invariant.

This work should support translation of a limit expression in $filter.



 Comments   
Comment by Eric Cox (Inactive) [ 18/Aug/21 ]

anton.korshunov Closing as a duplicate and can do the work in SERVER-32739.

Comment by Anton Korshunov [ 16/Aug/21 ]

eric.cox Yeah, it wasn't obvious from the description that the $filter expression has been changed by adding a new argument. I agree that this ticket is not a bug and a fix should be part of SERVER-32739.

Comment by Eric Cox (Inactive) [ 12/Aug/21 ]

anton.korshunov I should have been more clear in the description. The changes in SERVER-32739 added a new expression for a `limit` parameter to $filter. That would add a third expression.  I pulled in Maddie's change and saw two calls to inVisit(). I suppose this ticket could be converted to a regular SERVER ticket to support a limit expression to $filter instead of it being a bug?

Generated at Thu Feb 08 05:46:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.