Skip to content

Add $centerSphere tests#217

Open
PatersonProjects wants to merge 13 commits into
documentdb:mainfrom
PatersonProjects:center_sphere_tests
Open

Add $centerSphere tests#217
PatersonProjects wants to merge 13 commits into
documentdb:mainfrom
PatersonProjects:center_sphere_tests

Conversation

@PatersonProjects
Copy link
Copy Markdown
Contributor

@PatersonProjects PatersonProjects commented May 20, 2026

This PR adds the compatibility tests for the $centerSphere geospatial specifier:

Ref: Issue #32

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects changed the title Add $center_sphere tests Add $centerSphere tests May 20, 2026
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels May 20, 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 L · Status In Progress
Confidence: 0.85 (mixed)

Reasoning

component from path globs (test-coverage); effort from diff stats (1452+0 LOC, 7 files); LLM: Adds new compatibility tests for the $centerSphere geospatial specifier, expanding test coverage for an existing tracked feature request.

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.

Copy link
Copy Markdown
Collaborator

@vic-tsang vic-tsang left a comment

Choose a reason for hiding this comment

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

consider adding these test cases:

  • LineString with one vertex outside sphere (validates "fully within" semantics)
  • Embedded document with {"x": 0, "y": 0} keys as legacy coordinates
  • 3-element array [0, 0, 0] as location field (uses first two elements)
  • Single-element array [5] as location field (should not match)
  • Decimal128('NaN') as coordinates (should error)
  • Decimal128('Infinity') as radius (should succeed, same as float Infinity)

PatersonProjects and others added 4 commits May 21, 2026 10:06
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects marked this pull request as ready for review May 21, 2026 19:26
@PatersonProjects PatersonProjects requested a review from a team as a code owner May 21, 2026 19:26
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…ects/functional-tests into center_sphere_tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
error_code=BAD_VALUE_ERROR,
msg="Should reject BinData coordinates",
),
QueryTestCase(
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.

Remove Code tests, they are deprecated.

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.

I believe according to the docs the base Code (Javascript) which this test is using still is in use , it is JS with scope that is deprecated

),
QueryTestCase(
id="pole_proximity_north",
filter={"loc": {"$geoWithin": {"$centerSphere": [[0, 90], 200 / 6371]}}},
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.

magic number, extract to a module-level constant like RADIUS_200_KM_IN_RADIANS = 200 / 6371 with a comment.

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.

Added constant, replaced magic numbers in tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects requested a review from eerxuan May 27, 2026 20:14
from documentdb_tests.framework.test_constants import DECIMAL128_INFINITY, FLOAT_INFINITY

# Earth's mean radius in km; used to convert km to radians (km / R)
EARTH_RADIUS_KM = 6371
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.

Other files still have raw number. Can you put this to geospatial/utils/ and update all places.

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.

Removed magic number across all files, moved constant to geospatial/utils/constants.py

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects requested a review from eerxuan May 28, 2026 19:20
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.

4 participants