-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 8.3.11
-
Component/s: Query Execution
-
None
-
Query Execution
-
ALL
-
-
QE 2026-10-12
-
None
-
None
-
None
-
None
-
None
-
None
-
None
With the default engine selection, when $group runs in SBE and produces MinKey or MaxKey, and a later stage runs in the classic engine (here $project), the value arrives as an object with a single empty-named field holding MinKey/MaxKey instead of MinKey/MaxKey itself. With forceClassicEngine the same pipeline returns MinKey/MaxKey.
- classic engine: internalQueryFrameworkControl: forceClassicEngine. Check: the explain line in the output shows explainVersion 1, with $group and $project after $cursor.
- SBE prefix + classic suffix: default internalQueryFrameworkControl: trySbeRestricted: $group is pushed into SBE, $project stays in the classic engine. Check: the explain line shows explainVersion 2 with GROUP in the SBE plan, then $project.
Expected: mx: MaxKey(), mn: MinKey() and t: 'maxKey' with both engines (the classic engine's result).
Actual: Default (trySbeRestricted): mx and mn are objects with one empty-named field holding MaxKey / MinKey, and $type reports 'object'.
convertToValue, which turns SBE values into a classic Document where the SBE prefix hands results to classic stages, maps MinKey/MaxKey to Value(kMinBSONKey) / Value(kMaxBSONKey). Those constants are BSONObj (an object with one empty-named MinKey/MaxKey field), so the result is an object value instead of Value(MINKEY) / Value(MAXKEY). When SBE returns results straight to the client (convertToBsonObj) the value is correct, so only pipelines with a classic suffix are affected. master has the same code.
- SBE to classic conversion: src/mongo/db/query/plan_executor_sbe.cpp#L473-L477 — convertToValue returns Value(kMinBSONKey) / Value(kMaxBSONKey)
- classic MinKey/MaxKey value: src/mongo/db/exec/document_value/value.h#L146-L147 — Value(MINKEY) / Value(MAXKEY); kMinBSONKey / kMaxBSONKey are BSONObj (src/mongo/bson/bsontypes.cpp L50-L53)
Found with AI assistance.