-
Type:
Sub-task
-
Resolution: Done
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
Several operators in this ticket have non-trivial Go design considerations:
- $switch requires a new SwitchCase helper type (for branches) to be added alongside the operator. Model it after the SetField/setField sealed-interface pattern if appropriate, or as a simple exported struct — pick whichever is cleaner.
- $let's vars argument maps variable names to expressions. Use map[string]any for the vars parameter, but note in a code comment that Go map iteration is non-deterministic, so tests must construct the expected bson.D with a fixed field order rather than round-tripping through a map.
- $percentile and $median require a method argument that currently must always be "approximate". Hardcode it and leave a TODO comment for when other methods are supported.
Definition of Done
- All of the following operators are implemented in mql/agg/operator.go, each with a one-line doc comment:
-
- Conditional: $cond, $switch (plus exported SwitchCase type and Case constructor)
- Higher-order: $let, $map, $reduce, $function
- Misc: $literal, $rand, $meta, $createObjectId
- Statistical: $percentile, $median
- Similarity: $similarityCosine, $similarityDotProduct, $similarityEuclidean
- Hash/EJSON: $hash, $hexHash, $serializeEJSON, $deserializeEJSON
- Each operator has at least one test in mql/agg/operator_test.go