Remove $documents dependency from expression test helpers - #715
Open
eerxuan wants to merge 2 commits into
Open
Conversation
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>
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage); effort from diff stats (22+11 LOC, 2 files); LLM: Removes a hard If a label is wrong, remove it manually and ping |
The $documents-removal commit made execute_expression/execute_project
insert a document and aggregate over the whole collection. Two newly
synced system-variable tests relied on the old $documents:[{}] contract
and broke:
- test_root_empty_document: needs a truly field-less input so $$ROOT is
{}, but an inserted doc always carries an auto _id. It now shapes its
own pipeline ($replaceWith:{$literal:{}}) instead of the shared helper.
- test_now_identical_across_getmore_batches: pre-loads 300 docs, so the
whole-collection helper emitted 300 rows. It now uses an inline
pipeline with $limit:1 to collapse to the single expected row.
The shared helpers stay on plain insert_one({}) so the ~359 literal
expression call sites gain no $replaceWith/$limit dependency.
Signed-off-by: Yunxuan Shi <yunxuan@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Remove the dependency on the
$documentsaggregation stage from the sharedexpression test helpers (
execute_expression,execute_project) and twoinline 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 documentinto
$project. They do not test$documentsitself — yet through theshared helpers, ~205 expression test files inherit a hard dependency on
$documentssupport. Any engine that does not implement$documentscannotrun 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
$documentsfeature.How
Swap the scaffold for
collection.insert_one({})plus an aggregate over thenamed collection:
This is logically identical: both feed exactly one empty document into
$project, so literal expressions and field references (which resolve tomissing against an empty document) behave the same. The
collectionfixture isfunction-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$documentssites(
test_let_two_lets_same_projection,test_let_error_cross_let_variable_ref)._with_insertsibling helpers are unchanged (they already insert apopulated document).