Skip to content

fix(spatial): support geodetic discrete distance units - #28830

Merged
XuPeng-SH merged 53 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issues-28194-28200-distance
Sep 20, 2026
Merged

XuPeng-SH merged 53 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issues-28194-28200-distance

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG
  • Compatibility

Which issue(s) this PR fixes

Fixes #28194
Fixes #28200
Fixes #28892

Changes

  • Geodetic SRID4326 distance and discrete Fréchet/Hausdorff semantics, authoritative MySQL length-unit overloads and GEOMETRY32 support, preserving legacy planar execution identities.
  • Preserve prepared source-domain rebinding through numeric/string/NULL/error/reuse, including stacked IP and expression prerequisites.
  • Reduce Fréchet workspace from O(nm) to two O(m) rows; CPU remains O(nm), with an independent full-matrix oracle.
  • Rebase onto main 3ac87c30625fc082391e5384a4c94e50a2916cf6, preserving its precise expression/IP contracts. Integrate the complete fix: support Decimal256 RANGE window bounds #28825 decimal closure, not a partial patch.
  • Enforce cumulative epochs: main integer85 → main expression/IP86 → decimal87 → spatial88. Sender actual-destination recheck, receiver/placement and persisted maximum-epoch admission agree. Existing protobuf field names/tags remain compatible.
  • Remove an identical duplicated test introduced by integration; retain the original assertions. Correct only the added approximate-percentile CTAS result metadata against both actual old/new binaries.

Compatibility acceptance

Actual native D87 (19269e68b2) and C88 (c63ae3db88) binaries were used, without protocol or commit-ID impersonation:

  • Real HAKeeper inventory/queryservice versions; sender C→D destination replacement rejects, stale UUID/address rejects, restoring C succeeds. Decimal87 controls pass on both.
  • Valid legacy wire controls on both receivers; C accepts the new overload, D rejects it with its actual unknown-overload diagnostic, with no row returned. This is D registry rejection, not a spatial88 gate absent from D.
  • A separate D87-source scope encoder and transport sends a non-NULL legacy Fréchet expression to C88; decoded result is exactly FLOAT64 1.
  • Binary prepared reuse alternates unit/numeric-SRID/NULL/invalid-unit and recovers after errors.
  • Actual D87-authored view replays on C88; floor87 rejects spatial88 authoring without publishing a view. All88 creates spatial and combined decimal/spatial views with maximum requirement88; graceful restart preserves values/metadata. Actual D87 rollback exits with required88/local87 before SQL admission.

Existing worker discovery requires identical CommitID, so cross-commit public SQL scheduling is intentionally excluded. Its safe rejection is recorded separately from old-produced wire compatibility; no claim that D87 SQL scheduled onto C88. This boundary is documented in docs/design/pr-28830-compatibility.md. Skipped external upgrade workflows are not counted as evidence.

Validation

  • Full owning packages pass: defines, frontend, geo, pb/plan, compile, planner, function, rule and Substrait. Compile needs GOMAXPROCS=4 for three existing CPU-sensitive Parquet fixtures; all three CPU2 failures reproduce on exact frozen main with identical signatures. Original CPU2 failure is retained, not labeled passing.
  • Verified owned native build; focused compatibility/prepared/geometry/provenance tests pass. Scoped vet and configured golangci pass (0 issues); molint completes with unchanged baseline diagnostics explicitly attributed.
  • Public geo93/93, IP111/111, decimal-literal23/23 and interval11/11 pass; cleanup/reuse repeat238/238 passes.
  • Legacy decimal584/690: all106 failure SQL/expected/actual blocks exactly match the independently checked baseline. Approximate-percentile40/48 after correcting the new CTAS oracle: remaining8 complete failure blocks exactly match actual D87. These two full fixtures are not green, and are not represented as such.
  • Independent full-scope GPT‑6 medium design/source review plus final delta/evidence review: FINAL OVERALL PASS, no unresolved material finding or mandatory validation gap. Final source delta contains only documentation and the single CTAS result metadata correction; tested production binary is unchanged.

Fresh GitHub CI remains authoritative for this pushed revision and is not claimed as passed by local validation. No merge performed.

@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

Copy link
Copy Markdown
Contributor Author

已修复并 rebase 到最新 main(be30a70fe5)。

根因:本次失败不是测试基础设施问题:

  • SCA 是新增 pkg/geo/distance_units_test.go 缺少完整 Apache license disclaimer;已补齐。
  • Coverage 合并成功但修改行仅 105/149 = 70.47%,低于 75%;不是 coverage producer/harness 故障。已补充有独立 oracle 的覆盖:所有单位别名/大小写、geodetic Frechet/Hausdorff 空几何、registry executor(geometry/geometry32 × 三个函数)、SRID/NULL/mask/malformed/unsupported/empty,以及 prepared SQL/binary-boundary/显式 CAST/缓存 plan 不变性。
  • 同步收紧 preparedParamValueUsesStringDomain 的等价分支,并修正过时注释;不改变生产语义。

最终改动已推送到 PR 分支,HEAD:552c140ad8ed0bd20c089520ab11451a170dbc6d。

验证(rebase 后):

  • 普通 UT:./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/sql/plan/function;./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/sql/plan;go test -mod=readonly -count=1 ./pkg/geo
  • race:上述三个包均通过
  • golangci-lint(CGo flags 按仓库流程设置):0 issues
  • license-eye:10/10 valid
  • go vet:通过

GPT-6 medium 最终复审:PASS,无 P0–P2 blocker。binary protocol 证据是 planner ParamValue 边界测试,不宣称 COM_STMT_EXECUTE 字节解析端到端覆盖。

@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

CI triage and rebase update:

The failed Matrixone Compose CI execution / multi cn e2e bvt test docker compose(PROXY) job was a CI/harness timeout, not a spatial-distance assertion: Start BVT Test remained active for about 63 minutes, the job log endpoint then returned BlobNotFound, and no test failure output or PR-specific error was produced. This PR changes only spatial distance/unit handling and its UT coverage; it does not touch the Compose BVT harness or its SQL fixtures. No reproducible PR/base defect was found, so no issue was opened.

The branch was rebased onto current main (a72a224ce8) and updated in place. New head: f656274a90276aad0e16ac263ac3043bb45009b7. Existing local spatial UT/race/vet evidence remains applicable; no CI wait requested.

Cover Decimal256 interval cast and rounding branches plus decimal cast wrapper clamp and error paths without adding service or slow-suite tests.
@XuPeng-SH

Copy link
Copy Markdown
Contributor Author

Rerun complete. Rebased the full branch onto current main 22d43911d3f6c51872c1852340265a7d3f206925; exact head is 5565ebcde05d36a9308bc1ed0f3096f7971833ac. The plan.proto merge was resolved at source level and plan.pb.go was regenerated with the repository generator. git diff --check passes.

GPT-6 medium final review found no concrete P0-P2 code blockers and confirmed preservation of main v87 grouping and v88 vector-HLL contracts. Exact-head UT/SCA/BVT and mixed-version execution remain pending CI/not locally verified. Historical evidence is not claimed for this head.

Protocol ordering note: this priority-first PR owns decimal v89 and spatial v90. PR #29123 currently also proposes v89 for a different HLL contract; that later PR must be renumbered after this protocol allocation lands. The stale GitHub changes-requested review concerned the unit registry and is already addressed by the current 47-name MySQL-compatible registry.

@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.

COMMENT — PASS at exact head 5565ebcde05d36a9308bc1ed0f3096f7971833ac; self-authored PR, so COMMENT only.

Fresh exact-head review of the current change map and the increment since the last reviewed head found no actionable P0/P1/P2 code defect in the geodetic discrete-distance kernels, unit lookup/conversion, SRID/coordinate validation, GEOMETRY32 path, or the v90 planner/remote-expression fences. The geodetic kernels use the same explicit-vertex and rolling-row semantics as the planar counterparts; antimeridian, high-latitude, pole, antipodal, empty, unit, prepared, and protocol-feature cases have regression coverage. Exact-head CI Required, UT, SCA, coverage, and pessimistic BVT are green.

One P2 validation gap remains, not a confirmed runtime defect: the target/release upgrade checks are skipped, so same-binary protocol simulation does not prove old/new binary expression transport, persisted-plan reload, restart, or mixed-worker fallback/rejection. The compatibility design document already records this acceptance gate; add real mixed-version evidence before treating that gate as closed.

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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

4 participants