Skip to content

fix(spatial): correct MBR predicates for degenerate bounds - #28811

Merged
XuPeng-SH merged 5 commits into
mainfrom
codex/issue-28190-28192-mbr-20260913
Sep 13, 2026
Merged

XuPeng-SH merged 5 commits into
mainfrom
codex/issue-28190-28192-mbr-20260913

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #28190
Fixes #28192

What this PR does / why we need it:

  • Distinguish inclusive MBR coverage from strict containment. MBRContains/MBRWithin now require both closed-box coverage and intersecting relative interiors; MBRCovers/MBRCoveredBy retain inclusive boundary coverage.
  • Define MBRTouches as intersecting MBRs whose relative interiors do not intersect. This handles equal and contained point/line MBRs without treating every zero-area intersection as a touch.
  • Keep MBROverlaps behavior unchanged by retaining the inclusive coverage predicate in its containment exclusion.
  • Add a 28-case evaluator matrix for points, horizontal/vertical lines, rectangles, boundaries, equal bounds, crossings, disjoint inputs, symmetry, and inverse predicate pairs. Extend the SQL BVT with table-column and constant-expression regressions.

Performance and risk:

The new relation checks use a fixed number of scalar comparisons, are O(1), and allocate no memory. Geometry decoding and envelope calculation are unchanged. Boundary results for MBRContains/MBRWithin intentionally become strict; callers that need boundary-inclusive behavior should use MBRCovers/MBRCoveredBy. This does not change optimizer or R-tree index eligibility; MBR functions remain evaluated by their existing function path.

Validation:

  • PASS: exact-main evaluator reproduction failed for the reported cases before the production fix.
  • PASS: focused MBR evaluator UT and full pkg/sql/plan/function UT.
  • PASS: GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function.
  • PASS: incremental golangci-lint (0 issues), gofmt, and git diff --check.
  • Not run locally: public SQL BVT, because the configured host has an unrelated active MatrixOne version; the added BVT is left for exact-head CI. No local BVT pass is claimed.
  • Not run locally: repository SCA. CI results are pending and are not claimed here.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left 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.

GPT-6 medium deep review at current head 05a17f78747ec80f0fb5725f78d9157fd3b7bda7: no verified blocking finding.

Closed coverage plus relative-interior intersection correctly distinguishes MBRContains/Within from MBRCovers/CoveredBy for points, line endpoints/intersections, and area bounds. MBRTouches uses closed intersection without relative-interior intersection. MBROverlaps keeps its prior positive-area rule; bboxCovers is equivalent to the old inclusive containment helper there, so this change preserves its existing results. The changed helpers feed scalar MBR evaluation; no spatial-index pruning consumer depends on this containment behavior. Empty, malformed, null/masked, SRID, and geometry32 handling remain on the existing decode/evaluation paths.

Racing-UT review: the production change adds fixed scalar comparisons without allocations, locks, or shared state. The new cases use one lightweight process and small named inputs; no cluster, goroutine, sleep, retry, or large/repeated workload was added. Exact-head CI run 34769200197 passed with pkg/sql/plan/function selected in the -race stage. PESSIMISTIC BVT ran geo/geo_mbr.sql 15/15 in 0.221s. No mechanism for a material racing-UT time increase was found; no full-suite before/after duration delta is claimed.

@XuPeng-SH
XuPeng-SH merged commit 4d18bee into main Sep 13, 2026
8 of 11 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/issue-28190-28192-mbr-20260913 branch September 13, 2026 17:41
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#28811)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28190
Fixes matrixorigin#28192

## What this PR does / why we need it:

- Distinguish inclusive MBR coverage from strict containment.
MBRContains/MBRWithin now require both closed-box coverage and
intersecting relative interiors; MBRCovers/MBRCoveredBy retain inclusive
boundary coverage.
- Define MBRTouches as intersecting MBRs whose relative interiors do not
intersect. This handles equal and contained point/line MBRs without
treating every zero-area intersection as a touch.
- Keep MBROverlaps behavior unchanged by retaining the inclusive
coverage predicate in its containment exclusion.
- Add a 28-case evaluator matrix for points, horizontal/vertical lines,
rectangles, boundaries, equal bounds, crossings, disjoint inputs,
symmetry, and inverse predicate pairs. Extend the SQL BVT with
table-column and constant-expression regressions.

## Performance and risk:

The new relation checks use a fixed number of scalar comparisons, are
O(1), and allocate no memory. Geometry decoding and envelope calculation
are unchanged. Boundary results for MBRContains/MBRWithin intentionally
become strict; callers that need boundary-inclusive behavior should use
MBRCovers/MBRCoveredBy. This does not change optimizer or R-tree index
eligibility; MBR functions remain evaluated by their existing function
path.

## Validation:

- PASS: exact-main evaluator reproduction failed for the reported cases
before the production fix.
- PASS: focused MBR evaluator UT and full `pkg/sql/plan/function` UT.
- PASS: `GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function`.
- PASS: incremental golangci-lint (0 issues), gofmt, and `git diff
--check`.
- Not run locally: public SQL BVT, because the configured host has an
unrelated active MatrixOne version; the added BVT is left for exact-head
CI. No local BVT pass is claimed.
- Not run locally: repository SCA. CI results are pending and are not
claimed here.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#28811)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28190
Fixes matrixorigin#28192

## What this PR does / why we need it:

- Distinguish inclusive MBR coverage from strict containment.
MBRContains/MBRWithin now require both closed-box coverage and
intersecting relative interiors; MBRCovers/MBRCoveredBy retain inclusive
boundary coverage.
- Define MBRTouches as intersecting MBRs whose relative interiors do not
intersect. This handles equal and contained point/line MBRs without
treating every zero-area intersection as a touch.
- Keep MBROverlaps behavior unchanged by retaining the inclusive
coverage predicate in its containment exclusion.
- Add a 28-case evaluator matrix for points, horizontal/vertical lines,
rectangles, boundaries, equal bounds, crossings, disjoint inputs,
symmetry, and inverse predicate pairs. Extend the SQL BVT with
table-column and constant-expression regressions.

## Performance and risk:

The new relation checks use a fixed number of scalar comparisons, are
O(1), and allocate no memory. Geometry decoding and envelope calculation
are unchanged. Boundary results for MBRContains/MBRWithin intentionally
become strict; callers that need boundary-inclusive behavior should use
MBRCovers/MBRCoveredBy. This does not change optimizer or R-tree index
eligibility; MBR functions remain evaluated by their existing function
path.

## Validation:

- PASS: exact-main evaluator reproduction failed for the reported cases
before the production fix.
- PASS: focused MBR evaluator UT and full `pkg/sql/plan/function` UT.
- PASS: `GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function`.
- PASS: incremental golangci-lint (0 issues), gofmt, and `git diff
--check`.
- Not run locally: public SQL BVT, because the configured host has an
unrelated active MatrixOne version; the added BVT is left for exact-head
CI. No local BVT pass is claimed.
- Not run locally: repository SCA. CI results are pending and are not
claimed here.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#28811)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#28190
Fixes matrixorigin#28192

## What this PR does / why we need it:

- Distinguish inclusive MBR coverage from strict containment.
MBRContains/MBRWithin now require both closed-box coverage and
intersecting relative interiors; MBRCovers/MBRCoveredBy retain inclusive
boundary coverage.
- Define MBRTouches as intersecting MBRs whose relative interiors do not
intersect. This handles equal and contained point/line MBRs without
treating every zero-area intersection as a touch.
- Keep MBROverlaps behavior unchanged by retaining the inclusive
coverage predicate in its containment exclusion.
- Add a 28-case evaluator matrix for points, horizontal/vertical lines,
rectangles, boundaries, equal bounds, crossings, disjoint inputs,
symmetry, and inverse predicate pairs. Extend the SQL BVT with
table-column and constant-expression regressions.

## Performance and risk:

The new relation checks use a fixed number of scalar comparisons, are
O(1), and allocate no memory. Geometry decoding and envelope calculation
are unchanged. Boundary results for MBRContains/MBRWithin intentionally
become strict; callers that need boundary-inclusive behavior should use
MBRCovers/MBRCoveredBy. This does not change optimizer or R-tree index
eligibility; MBR functions remain evaluated by their existing function
path.

## Validation:

- PASS: exact-main evaluator reproduction failed for the reported cases
before the production fix.
- PASS: focused MBR evaluator UT and full `pkg/sql/plan/function` UT.
- PASS: `GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function`.
- PASS: incremental golangci-lint (0 issues), gofmt, and `git diff
--check`.
- Not run locally: public SQL BVT, because the configured host has an
unrelated active MatrixOne version; the added BVT is left for exact-head
CI. No local BVT pass is claimed.
- Not run locally: repository SCA. CI results are pending and are not
claimed here.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: MBRWithin treats boundary coverage as strict within [Bug]: MBRTouches returns true for equal points and contained point MBRs

2 participants