Summary
Add shared expression engine tests that cover parser/evaluator mechanics common to all operators. These should be tested once with a representative operator, not duplicated per-operator.
Per TEST_COVERAGE.md section 3, these are "Expression Engine Tests (under expressions/)" that test shared behavior.
Tests to Add
1. Field Path Resolution
File: expressions/test_field_path_resolution.py
- Simple:
$a on {a: 1}
- Nested object:
$a.b on {a: {b: 1}}
- Deep nested:
$a.b.c.d on {a: {b: {c: {d: 1}}}}
- Array index:
$a.0.b on {a: [{b: 1}, {b: 2}]}
- Composite array traversal:
$a.b on {a: [{b: 1}, {b: 2}]}
- Nested arrays:
$a.b on {a: [[{b: 1}], [{b: 2}]]}
- Non-existent path:
$missing → null
- Non-existent nested:
$x.y.0 on {}
2. Expression Nesting
File: expressions/test_expression_nesting.py
- Expression in object:
{a: {$abs: -1}}
- Expression in array:
[{$abs: -1}]
- Nested expressions:
{$add: [{$abs: "$x"}, {$abs: "$y"}]}
- Deep nesting:
{$add: [1, {$abs: {$ceil: {$sqrt: "$x"}}}]}
- Complex mixed:
{a: [{$add: [1, {$abs: "$x"}]}, {b: {$ceil: "$y"}}]}
3. Invalid Field Paths
File: expressions/test_invalid_field_paths.py
- Empty path:
$
- Empty component:
$a..b
- Trailing dot:
$a.
- Null bytes in path
$$ prefix errors (undefined variables)
- Dollar prefix in field name:
$invalid
Tasks
Test Location
documentdb_tests/compatibility/tests/core/operator/expressions/
Notes
- Use a representative operator (e.g.,
$add or $project) — these test the expression engine, not operator-specific logic
- Per-operator tests should NOT duplicate these; they should only test operator-specific behavior (type acceptance,
$missing handling, argument count, etc.)
- Some per-operator tests currently include invalid field path tests — those can be migrated here over time
Summary
Add shared expression engine tests that cover parser/evaluator mechanics common to all operators. These should be tested once with a representative operator, not duplicated per-operator.
Per TEST_COVERAGE.md section 3, these are "Expression Engine Tests (under
expressions/)" that test shared behavior.Tests to Add
1. Field Path Resolution
File:
expressions/test_field_path_resolution.py$aon{a: 1}$a.bon{a: {b: 1}}$a.b.c.don{a: {b: {c: {d: 1}}}}$a.0.bon{a: [{b: 1}, {b: 2}]}$a.bon{a: [{b: 1}, {b: 2}]}$a.bon{a: [[{b: 1}], [{b: 2}]]}$missing→ null$x.y.0on{}2. Expression Nesting
File:
expressions/test_expression_nesting.py{a: {$abs: -1}}[{$abs: -1}]{$add: [{$abs: "$x"}, {$abs: "$y"}]}{$add: [1, {$abs: {$ceil: {$sqrt: "$x"}}}]}{a: [{$add: [1, {$abs: "$x"}]}, {b: {$ceil: "$y"}}]}3. Invalid Field Paths
File:
expressions/test_invalid_field_paths.py$$a..b$a.$$prefix errors (undefined variables)$invalidTasks
test_field_path_resolution.pytest_expression_nesting.pytest_invalid_field_paths.pyTest Location
Notes
$addor$project) — these test the expression engine, not operator-specific logic$missinghandling, argument count, etc.)