-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: 8.3.11
-
Component/s: Query Execution
-
None
-
Query Execution
-
Minor Change
-
ALL
-
-
QE 2026-10-12
-
None
-
None
-
None
-
None
-
None
-
None
-
None
$substrBytes with a non-integral start index (1.5) gives 'bc' in the classic engine (the index is truncated to 1) and missing in SBE. Inside $group the expression runs in SBE under the default engine selection, so $push collects 'bc' with the classic engine and nothing with SBE.
- classic engine: internalQueryFrameworkControl: forceClassicEngine. Check: the explain line in the output shows explainVersion 1, with $group after $cursor.
- SBE: default internalQueryFrameworkControl: trySbeRestricted: the whole pipeline, including $group, runs in SBE. Check: the explain line shows explainVersion 2 with GROUP in the SBE plan.
Expected: The same result with both engines. The documentation asks for a start index and length that are non-negative integers or numbers representable as integers, so 1.5 is outside the contract; an error from both engines, or the same value from both, would be consistent.
Actual: Classic engine: r holds 'bc'. Default (trySbeRestricted, SBE): r is an empty array (the expression is missing), with no error.
The classic engine converts the start index and length with coerceToLong(), which truncates. SBE converts them with convert(…, NumberInt64), which fails for a non-integral value and yields Nothing; builtinSubstrBytes then returns Nothing for a non-Int64 argument. $substrCP agrees between the engines on the same input. master has the same code.
- classic: src/mongo/db/exec/expression/evaluate_string.cpp#L97-L106 — coerceToLong() truncates the start index and the length
- SBE: src/mongo/db/query/stage_builder/sbe/gen_expression.cpp#L2838-L2852 — start index and length go through convert(…, NumberInt64); a non-integral value becomes Nothing, and builtinSubstrBytes returns Nothing (src/mongo/db/exec/sbe/vm/vm_builtin_string.cpp L152-L155)
Related: https://jira.mongodb.org/browse/SERVER-92347
Found with AI assistance.
- is related to
-
SERVER-92347 Refactor $substrBytes expression in SBE aggregation pipeline to use mongo::substr_utils
-
- Open
-