Add $last accumulator tests#231
Conversation
|
🤖 Auto-triaged by documentdb-triage-tool. Applied: Reasoningcomponent from path globs (test-coverage); effort from diff stats (1520+4 LOC, 7 files); LLM: Adds new integration test coverage for the $last accumulator operator under the compatibility tests path, expanding functional test surface for an important aggregation feature. If a label is wrong, remove it manually and ping |
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>
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>
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>
|
applied #214 (review): Add tests: arity error tests, BSON constant tests, expression tests, and empty-group behavior tests. Removed |
Add tests: arity error tests, BSON constant tests, expression tests, empty-group behavior, and order dependence tests. Removed tests. Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
| "expr_error_divide_by_zero", | ||
| docs=[{"v": 1}], | ||
| pipeline=[ | ||
| {"$group": {"_id": None, "result": {"$last": {"$divide": ["$v", 0]}}}}, |
There was a problem hiding this comment.
Can you add a field path trigger error?
{"$divide": [1, "$v"]} with docs=[{"v": 0}].
and test if docs before last can trigger it. docs=[{"v": 1}, {"v": 0}]
There was a problem hiding this comment.
added the suggested tests
| {"$group": {"_id": None, "result": {"$last": "$v"}}}, | ||
| {"$project": {"_id": 0, "result": 1}}, | ||
| ], | ||
| expected=[{"result": pytest.approx(math.nan, nan_ok=True)}], |
There was a problem hiding this comment.
pytest.approx(math.nan, nan_ok=True) is wrong helper here, The framework already has its own NaN-equality handling — _replace_nan at assertions.py:323
There was a problem hiding this comment.
fixed to use assertSuccessNaN
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
Signed-off-by: Alina (Xi) Li <Alina.Li@improving.com>
alinaliBQ
left a comment
There was a problem hiding this comment.
addressed comments
| {"$group": {"_id": None, "result": {"$last": "$v"}}}, | ||
| {"$project": {"_id": 0, "result": 1}}, | ||
| ], | ||
| expected=[{"result": pytest.approx(math.nan, nan_ok=True)}], |
There was a problem hiding this comment.
fixed to use assertSuccessNaN
| "expr_error_divide_by_zero", | ||
| docs=[{"v": 1}], | ||
| pipeline=[ | ||
| {"$group": {"_id": None, "result": {"$last": {"$divide": ["$v", 0]}}}}, |
There was a problem hiding this comment.
added the suggested tests
This change adds tests for the $last accumulator operator.
Add accumulator operator tests for $last. Tests database $last behavior, output collection, syntax, and expected errors.
Integration tests are in
documentdb_tests/compatibility/tests/core/operator/accumulators/test_accumulators_last_integration.py