Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
None
-
Query Optimization
-
Fully Compatible
-
ALL
-
QO 2023-03-06, QO 2023-03-20
Description
During constant evaluation, if we see a variable whos definition is simply another variable, we currently would substitute in the definition. However this causes issues for our projection properties, since the substituted variable may not be allowed in a scope higher up. This is only an issue in the ConstEvalPost phase.
The lowering phase also handles this case. Instead of inlining before lowering, we can avoid doing the rewrite and recomputing the projections, and allow lowering to do the work for us.
repro:
coll.createIndex({a: 1, _id: 1}) |
coll.find({_id : 1}, {a : 1}).hint({a : 1, _id : 1}) |
The error will be "Location4946301 undefined slot accessor:2", caused by a rewrite in ConstEvalPost, which prevents the nested loop join from passing slot2 and slot3 further up in the plan.
slack conversation for reference
As part of this ticket, the SBE consteval equivalent should also be investigated.