Skip to content

Add $covariancePop and $covarianceSamp window operator compatibility … - #714

Merged
eerxuan merged 1 commit into
documentdb:mainfrom
Cassie-2025:window-covariance-tests
Aug 8, 2026
Merged

Add $covariancePop and $covarianceSamp window operator compatibility …#714
eerxuan merged 1 commit into
documentdb:mainfrom
Cassie-2025:window-covariance-tests

Conversation

@Cassie-2025

Copy link
Copy Markdown
Contributor

Summary

  • Add comprehensive compatibility tests for $covariancePop and $covarianceSamp window operators
  • Update TEST_COVERAGE.md §22 with overflow requirements for multi-expression operators

Test Coverage

Each operator has 7 test files covering all dimensions from TEST_COVERAGE.md §22 (Window Operator Coverage):

File Dimension
test_window_*_argument_validation.py Valid/invalid expression shapes, structural parse errors
test_window_*_field_paths.py Dotted paths, missing fields, null values, array-of-objects traversal, numeric path components
test_window_*_frame_computation.py Whole-partition, cumulative, reverse-cumulative, sliding frames
test_window_*_non_numeric_handling.py Null, missing, string, boolean, array, object, ObjectId, Regex, Binary, Timestamp, MinKey,
MaxKey
test_window_*_numeric_precision.py Int32/Int64/Double/Decimal128 mixing, overflow (4-case intermediate overflow per §22),
catastrophic cancellation
test_window_*_order_independence.py Same result regardless of sort direction
test_window_*_special_floats.py NaN/Infinity propagation in removable vs non-removable windows

Key behavioral differences tested:

  • $covariancePop: divides by N (single element → 0)
  • $covarianceSamp: divides by N-1 (single element → null)

Test plan

  • All 241 tests pass against the reference server (8.2.4)
  • Pre-commit hooks pass (black, isort, flake8, mypy, forbidden terms, DC

@Cassie-2025
Cassie-2025 requested a review from a team as a code owner August 5, 2026 22:38
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related documentation Improvements or additions to documentation enhancement New feature or request labels Aug 5, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, documentation, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort XL · Status Needs Review
Confidence: 0.88 (mixed)

Reasoning

component from path globs (test-coverage, docs); effort from diff stats (7759+2 LOC, 15 files); LLM: Adds 14 new compatibility test files (241 tests) covering $covariancePop and $covarianceSamp window operators across all §22 dimensions, plus a TEST_COVERAGE.md update — multi-file, one component, important feature coverage.

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.

@eerxuan eerxuan left a comment

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.

Overall good.

Fix before merge:

  • 🟠 negative_correlation_order_independent (Pop & Samp) doesn't test order-independence — it only runs
    the ascending sort and asserts -4.0, never the descending compare. Add the descending run, or rename and
    drop the claim. (Dimension is still covered elsewhere in the file, so not blocking.)

Nits:

  • 🟢 argument_validation and order_independence files hand-roll pipelines where run_window_operator()
    would fit.
  • 🟢 COVAR_DOCS redefined per file — could move to window/utils/.

Strengths: rigorous 4-case overflow coverage with signed ±Infinity assertions; correct single-element
split (Pop→0.0, Samp→None); expected values faithful to the reference server; the §22 doc update is
genuinely good.

…tests

Covers argument validation, field paths, frame computation, non-numeric
handling, numeric precision (incl. Decimal128), order independence, and
special float behavior for both operators.

Uses run_window_operator() from shared utils where applicable and
consolidates COVAR_DOCS into window/utils/window_test_case.py.

Signed-off-by: Cassie Lyu <shanslyu@amazon.com>
@Cassie-2025
Cassie-2025 force-pushed the window-covariance-tests branch from 708ef5c to 9c99837 Compare August 7, 2026 21:23
@eerxuan
eerxuan merged commit 935605a into documentdb:main Aug 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compatibility test Compatibility test related documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants