Skip to content

Add $out stage tests#182

Open
alinaliBQ wants to merge 5 commits into
documentdb:mainfrom
alinaliBQ:out
Open

Add $out stage tests#182
alinaliBQ wants to merge 5 commits into
documentdb:mainfrom
alinaliBQ:out

Conversation

@alinaliBQ
Copy link
Copy Markdown
Contributor

@alinaliBQ alinaliBQ commented May 13, 2026

This change adds tests for the $out stage operator.

Add stage operator tests for $out. Tests database $out behavior, output collection, syntax, and expected errors.
Integration tests are in documentdb_tests/compatibility/tests/core/operator/stages/test_stages_combination_out.py

@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels May 13, 2026
@documentdb-triage-tool
Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort XL · Status In Progress
Confidence: 0.90 (mixed)

Reasoning

component from path globs (test-coverage, test-framework); effort from diff stats (5885+0 LOC, 16 files); LLM: Adds new integration test coverage for the $out stage operator, touching the compatibility tests directory.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

@alinaliBQ alinaliBQ marked this pull request as ready for review May 13, 2026 22:53
@alinaliBQ alinaliBQ requested a review from a team as a code owner May 13, 2026 22:53
@alinaliBQ alinaliBQ changed the title Add $out accumulator tests Add $out stage tests May 13, 2026
@alinaliBQ alinaliBQ force-pushed the out branch 3 times, most recently from e23668c to 8dac8d4 Compare May 14, 2026 23:32
Copy link
Copy Markdown

@SaiPradyumn SaiPradyumn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$out + $merge mutual exclusion -> Both are terminal stages. Test confirming [{"$out": "x"}, {"$merge": {...}}] or [{"$merge": ...}, {"$out": "x"}] errors.

Comment on lines +239 to +252
OutTestCase(
"out_then_merge",
docs=[{"_id": 1}],
pipeline=[{"$out": "target"}, {"$merge": {"into": "target2"}}],
msg="$out followed by $merge should produce a pipeline position error",
error_code=OUT_NOT_LAST_STAGE_ERROR,
),
OutTestCase(
"merge_then_out",
docs=[{"_id": 1}],
pipeline=[{"$merge": {"into": "target"}}, {"$out": "target2"}],
msg="$merge followed by $out should produce a pipeline position error",
error_code=OUT_NOT_LAST_STAGE_ERROR,
),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaiPradyumn We have $merge and $out error tests here, is this what you were referring to?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i think that should cover it, i might have missed it. Thanks

alinaliBQ added 4 commits May 15, 2026 15:33
- add out stage tests. squashed commits to rebase onto main

Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
@alinaliBQ
Copy link
Copy Markdown
Contributor Author

Pushed one commit for assertFailureCode style. PR is ready

c.database.drop_collection("schema_val_warn_target"),
c.database.command(
{
"create": "schema_val_warn_target",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded collection name "schema_val_warn_target" makes parallel test runs unsafe (different worker may still own this collection from an earlier run).
use collection.name, or f"{collection.name}_suffix" if you need another one to ensure uniqueness.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have changed to use f"{collection.name}..." with different suffix.
Also separated 2 outlier test cases test_out_lookup_equality and test_out_unionwith_merge.

OutTestCase(
"null_granularity_defaults_to_seconds",
docs=[{"_id": 1, "ts": datetime(2024, 1, 1), "value": 10}],
target_coll="target_gran_null",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion] for the review: consider deriving target_coll from the test ID (f"{ctx.collection}_{test.id}") so future copy-paste mistakes can't cause silent
collision.

Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>

separate outlier cases

Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>

separate outlier cases

Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Copy link
Copy Markdown
Contributor Author

@alinaliBQ alinaliBQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will continue addressing comments next week

c.database.drop_collection("schema_val_warn_target"),
c.database.command(
{
"create": "schema_val_warn_target",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have changed to use f"{collection.name}..." with different suffix.
Also separated 2 outlier test cases test_out_lookup_equality and test_out_unionwith_merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants