Aggregation expressions
Use the MongoDB expression reference for syntax and examples. This page records supported operators and Silt-specific restrictions. Expressions run in SQLite and preserve JSON types, ordered embedded objects, and the distinction between missing fields and null.
Unsupported operators throw SILT_UNSUPPORTED; invalid runtime operands fail the SQLite statement. Some operators reject values requiring BSON metadata or producing NaN/infinity. Shared limits are listed in MongoDB compatibility.
Numeric conversions use a strict SQL lexical parser rather than SQLite's permissive cast semantics: whitespace, trailing junk, hex, and decimal/exponent syntax for integer targets are rejected. $convert supports literal bool, string, int, long, and double targets (and their BSON type codes), with lazy onNull and onError. Long conversion is restricted to the JavaScript safe-integer range. Decimal128, dates, ObjectId, binary BSON, numeric subtype identity, and dynamic conversion targets are not supported. $type on a number fails because JSON cannot recover its BSON numeric subtype.
$round and $trunc use SQLite's extended decimal rendering of the binary64 value before decimal quantization. This avoids incorrect results from multiplying by a power of ten first. $substrBytes validates UTF-8 start and end boundaries in SQL. String case conversion follows SQLite's ASCII rules; MongoDB documents these operators as only well-defined for ASCII. Embedded NUL handling is explicitly rejected for trimming and code-point length; byte length and byte slicing retain NUL bytes. Some other SQLite text operations have additional embedded-NUL limitations; this is not full arbitrary BSON string conformance.
$sortArray ranks each element with correlated comparisons, including embedded arrays/objects. This is quadratic in array length; it is intended for bounded document arrays. $min/$max expression selection also uses correlated comparisons. SQL is executed in SQLite, but complex generated expressions and large single-document arrays still consume SQLite memory and SQL planner resources. Collection streaming does not imply a fixed memory bound for every expression.
Unsupported families include BSON/date expressions, bitwise numeric-subtype operators, custom JS functions/accumulators, and the newer optional parameters or operators not listed above. $replaceAll supports an empty search string using a recursive SQL walk over Unicode code points. Runtime finite-number and malformed-operand guards do not imply complete MongoDB error precedence parity.
Validation evidence
Direct SQLite regressions and captured MongoDB comparisons cover invalid operands, precision/conversion boundaries, field order, and expression behavior. See testing and compatibility evidence for the corpus, recorded results, and reproduction.