Skip to content

Remove $documents dependency from expression test helpers - #4

Open
eerxuan wants to merge 1 commit into
feature/add-chimera-enginefrom
remove-documents-dependency-in-expression-helpers
Open

Remove $documents dependency from expression test helpers#4
eerxuan wants to merge 1 commit into
feature/add-chimera-enginefrom
remove-documents-dependency-in-expression-helpers

Conversation

@eerxuan

@eerxuan eerxuan commented Aug 6, 2026

Copy link
Copy Markdown
Owner

What

Remove the dependency on the $documents aggregation stage from the shared
expression test helpers (execute_expression, execute_project) and two
inline call sites in test_expressions_combination_variables.py.

Why

These tests use a collectionless {aggregate: 1} pipeline with
{$documents: [{}]} purely as a scaffold to feed a single empty document
into $project. They do not test $documents itself — yet through the
shared helpers, ~205 expression test files inherit a hard dependency on
$documents support. Any engine that does not implement $documents cannot
run these tests at all, even though the behavior under test has nothing to do
with that stage.

Removing this dependency lets the expression compatibility suite run against
engines that don't yet support the $documents feature.

How

Swap the scaffold for collection.insert_one({}) plus an aggregate over the
named collection:

+    collection.insert_one({})
     return execute_command(
         collection,
         {
-            "aggregate": 1,
+            "aggregate": collection.name,
             "pipeline": [
-                {"$documents": [{}]},
                 {"$project": {"_id": 0, "result": expression}},
             ],
             "cursor": {},
         },
     )

This is logically identical: both feed exactly one empty document into
$project, so literal expressions and field references (which resolve to
missing against an empty document) behave the same. The collection fixture is
function-scoped, so each test still runs against a fresh single-document
collection.

Scope

  • expressions/utils/utils.py — the two shared helpers (execute_expression,
    execute_project) inherited by ~205 files.
  • test_expressions_combination_variables.py — two inline $documents sites
    (test_let_two_lets_same_projection, test_let_error_cross_let_variable_ref).
  • The _with_insert sibling helpers are unchanged (they already insert a
    populated document).

Testing

Full expressions/ subtree run after the change: 6971 passed, 21 failed
(the 21 are unrelated pre-existing engine divergences in $toDate/$convert
year-range and $replaceAll multibyte-empty-find handling — none caused by
this change). No test regressed; all previously-blocked expression tests now
execute.

The expression compatibility tests use a collectionless
`{aggregate: 1}` + `$documents: [{}]` pipeline purely as a scaffold
to feed a single empty document into $project. They do not test
$documents itself, yet they inherit a hard dependency on $documents
support from the shared helpers.

Swap the scaffold for `collection.insert_one({})` plus an aggregate
over the named collection. This is logically identical: both feed
exactly one empty document to $project, so literal expressions and
field references (which resolve to missing against an empty doc)
behave the same. The `collection` fixture is function-scoped, so each
test still runs against a fresh single-document collection.

Updates the two shared helpers (execute_expression, execute_project)
that ~205 files inherit, plus two inline call sites in
test_expressions_combination_variables.py. The _with_insert sibling
helpers are unchanged.

Signed-off-by: Yunxuan Shi <yunxuan@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant