-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Query Integration
-
Fully Compatible
-
ALL
-
v8.0, v7.0
-
4
Tripwire assertion error: {'code': 7349401, 'codeName': 'Location7349401', 'errmsg': 'Was not able to re-parse queryStats key when reading queryStats.Status Location17390: $group does not support inclusion-style expressions Hash: 1070139331129839062 Query Shape: { cmdNs: { db: "test", coll: "jstests_indexu_NaN" }, command: "aggregate", pipeline: [ { $group: { _id: { by: 1 }, count: { $sum: 1 } } }, { $sort: { count: -1 } } ] }'} location: {fileName:"src/mongo/db/pipeline/document_source_query_stats.cpp", line:255, functionName:"toDocument"}
The failing query:
db.c.aggregate([{ $sortByCount: { $expr: { 'by': 22 } } }])
which desugars to
db.c.aggregate([{ $group: { _id: {$expr: { 'by': 22 }, count: { $sum: 1 } } }, { $sort: { count: -1 } } ])
It's hitting this assertion. This is happening because when we parse $expr: { 'by': 22 } we drop the $expr and by: 22 looks like a group expression on the field name "by" with the expression being "22". This is not allowed per the assertion we hit. What we really want is pre-SERVER-84159 behavior that serializes constant expressions with $const in the representative shape so that they are not interpreted as raw constants in cases when that's not allowed during the re-parsing step.
- is related to
-
SERVER-84159 Variadic expressions have inconsistent query shapes
- Closed
-
SERVER-85376 Accumulators don't re-parse correctly with $queryStats
- Closed