Summary
Add comprehensive test coverage for aggregation system variables. This includes feature tree entries, smoke tests, and detailed compatibility tests.
System Variables to Cover
Variable
Context
Priority
$$ROOT
Full current document
High
$$CURRENT
Current document (equivalent to field paths)
High
$$REMOVE
Remove field from output
High
$$NOW
Current datetime
High
$$CLUSTER_TIME
Current cluster time (replica set)
Medium
$$DESCEND
$redact stage
Medium
$$PRUNE
$redact stage
Medium
$$KEEP
$redact stage
Medium
$$USER_ROLES
Current user roles
Low
Tasks
Add feature tree entries under core,operator,expressions,variable,system-variables
Add smoke tests for each supported variable
Add shared expression engine tests under expressions/variable/system-variables/:
$$ROOT — in $project, $addFields, nested paths ($$ROOT.a.b), inside $cond
$$CURRENT — equivalence with field paths, in various expression contexts
$$REMOVE — in $project, $addFields, conditional removal ($cond + $$REMOVE), nested fields
$$NOW — type verification, consistency within a pipeline, usage in date expressions
$$DESCEND/$$PRUNE/$$KEEP — with $redact stage
$$CLUSTER_TIME — type verification, availability
Test Location
documentdb_tests/compatibility/tests/core/operator/expressions/variable/system-variables/
Notes
$let variable scoping is already covered in PR Add $let and $literal tests #102
Per TEST_COVERAGE.md, system variables are shared expression engine behavior — test once with a representative operator, not per-operator
Summary
Add comprehensive test coverage for aggregation system variables. This includes feature tree entries, smoke tests, and detailed compatibility tests.
System Variables to Cover
$$ROOT$$CURRENT$$REMOVE$$NOW$$CLUSTER_TIME$$DESCEND$redactstage$$PRUNE$redactstage$$KEEP$redactstage$$USER_ROLESTasks
core,operator,expressions,variable,system-variablesexpressions/variable/system-variables/:$$ROOT— in$project,$addFields, nested paths ($$ROOT.a.b), inside$cond$$CURRENT— equivalence with field paths, in various expression contexts$$REMOVE— in$project,$addFields, conditional removal ($cond+$$REMOVE), nested fields$$NOW— type verification, consistency within a pipeline, usage in date expressions$$DESCEND/$$PRUNE/$$KEEP— with$redactstage$$CLUSTER_TIME— type verification, availabilityTest Location
Notes
$letvariable scoping is already covered in PR Add $let and $literal tests #102