Skip to content

Add $match stage tests#68

Merged
eerxuan merged 12 commits intodocumentdb:mainfrom
danielfrankcom:dev/frankcom/match-operator-tests
Apr 16, 2026
Merged

Add $match stage tests#68
eerxuan merged 12 commits intodocumentdb:mainfrom
danielfrankcom:dev/frankcom/match-operator-tests

Conversation

@danielfrankcom
Copy link
Copy Markdown
Collaborator

@danielfrankcom danielfrankcom commented Apr 8, 2026

This change adds test cases for the $match aggregation stage, organized into files by property group:

  • test_match_core.py: null/missing field matching, core equality/ordering, predicate semantics, empty predicates, large predicates
  • test_match_query_operators.py: one representative per query operator category (comparison, logical, element, evaluation, array, bitwise, geospatial)
  • test_match_stage_position.py: pipeline position behavior and $text first-stage
  • test_match_errors.py: argument validation (non-object types) and restricted operators

Please note the tests are not intended to exhaustively cover things like BSON equality or other properties that would be thoroughly tested as part of separate query testing.

I also replaced test_match_stage.py with test_smoke_match.py (I think this overlaps with #64) since all of the existing cases were duplicated with the expanded coverage.

As part of this change, I've introduced a StageTestCase dataclass for pipeline stage tests, which should be reusable for other aggregation stage tests.

Depends on #65, #66, #67, #73. Until those changes are merged, I expect any tests run on this branch to fail.

Ref: #34

Add parametrized test cases for the $match aggregation stage,
organized into files by property group:

- test_match_core.py: null/missing, equality, predicates, empty/large
- test_match_query_operators.py: one representative per query category
- test_match_stage_position.py: pipeline position and $text first-stage
- test_match_errors.py: argument validation and restricted operators

Replace test_match_stage.py with test_smoke_match.py. Add StageTestCase
dataclass and new error codes used by the tests.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom danielfrankcom requested a review from a team as a code owner April 8, 2026 19:56
Copy link
Copy Markdown
Collaborator

@eerxuan eerxuan left a comment

Choose a reason for hiding this comment

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

The coverage is overall pretty good. We need to think about how to prevent duplicate testing.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Move tests that combine $match with other stages ($project, $group,
$replaceRoot) to stages/test_stages_position_match.py per FOLDER_STRUCTURE.md
rule that integration tests of same-level features belong in the parent folder.

Rename remaining pure $match tests to test_match_pipeline_semantics.py.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
Copy link
Copy Markdown
Collaborator

@eerxuan eerxuan left a comment

Choose a reason for hiding this comment

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

Please fix CI failures.

@danielfrankcom
Copy link
Copy Markdown
Collaborator Author

Please fix CI failures.

No fixes needed, just waiting on #73

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom danielfrankcom requested a review from manojnks April 15, 2026 00:09
@manojnks
Copy link
Copy Markdown

Please fix CI failures.

Signed-off-by: Daniel Frankcom <frankcom@amazon.com>
@danielfrankcom
Copy link
Copy Markdown
Collaborator Author

Please fix CI failures.

Now that #73 is merged, I merged from upstream and the failures are resolved.

@danielfrankcom danielfrankcom requested a review from manojnks April 15, 2026 17:47
danielfrankcom and others added 2 commits April 15, 2026 15:34
@eerxuan eerxuan self-requested a review April 16, 2026 18:25
@eerxuan eerxuan merged commit 9aeb64c into documentdb:main Apr 16, 2026
5 checks passed
@danielfrankcom danielfrankcom deleted the dev/frankcom/match-operator-tests branch April 16, 2026 18:28
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.

4 participants