Conversation
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Use the reported oriented polygon to compare forced primary and inverted scans with both argument orders and sphere/spheroid distance modes. Exercise runtime inverted-join filters with matching, nonmatching, and NULL probes, including NULL and empty indexed values. Release note: None
|
Thank you for updating your pull request. Before a member of our team reviews your PR, I have some potential action items for you:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prevent false negatives when a geography
ST_DWithinquery uses the geography inverted index. The fix keeps the inverted scan and exact residual predicate, but removes two lossy bounding-box assumptions that can discard a true match before exact evaluation.Fixes #80374
What was wrong
Geography is represented on the sphere, and a polygon can describe the large side of its boundary. Its coordinate bounding box does not necessarily contain the represented spherical region. The
DWithincovering path used a bounding-box fallback in this situation, so the generated S2 spans could omit cells that contain a qualifying indexed value.The optional geography pre-filter made the same assumption: it derived a bounding rectangle and rejected candidates from that rectangle before the exact
ST_DWithinresidual predicate ran. For a large-side geography polygon, that rejection is not conservative and can turn a true result into a false negative.Implementation
s2GeographyIndex.DWithinwith the covering produced from the actual S2 region representation.GeographyplusDWithin.Other geometry relationships and other geography relationships retain their existing pre-filter behavior. The inverted index scan remains in the plan for geography
DWithin; only the unsafe bounding-cap pruning is removed. Any extra candidates admitted by the conservative spans are still checked by the exact residual predicate.Why this fixes the reported case
The query-side S2 covering now follows the represented spherical region rather than a coordinate rectangle that may describe only the short side of a polygon boundary. The optional pre-filter can no longer reject a geography
DWithincandidate using that non-conservative rectangle. This removes the false-negative path while preserving exact result filtering and index-based execution.Validation
DWithincases, preserved relationships, and held-out large-side geography cases.