Repository navigation
fix(spatial): correct MBR predicates for degenerate bounds - #28811
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
…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>
…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>
…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>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28190
Fixes #28192
What this PR does / why we need it:
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:
pkg/sql/plan/functionUT.GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function.git diff --check.