Skip to content

[Compatibility]: spatial distance functions lack MySQL length-unit arguments #28200

Closed

Description

@Ariznawlll

Description

MySQL 的 ST_Distance、ST_FrechetDistance、ST_HausdorffDistance 支持可选长度单位字符串,MO 未注册这些 overload。地理查询无法直接请求 kilometre/foot 等单位;其中 ST_Distance 的第三参数在 MO 被定义成整数 SRID,与 MySQL 接口冲突。

Environment

  • main commit e7bb0572235ec4bac81eb098eb0ad8900f0065ab
  • MatrixOne local single node; MySQL 8.3.0 reference
  • Date: 2026-09-05

Reproduction

SELECT ST_Distance(
  ST_GeomFromText('POINT(0 0)',4326),
  ST_GeomFromText('POINT(0 1)',4326),
  'kilometre'
);
SELECT ST_FrechetDistance(
  ST_GeomFromText('LINESTRING(0 0,1 0)',4326),
  ST_GeomFromText('LINESTRING(0 1,1 1)',4326),
  'kilometre'
);
SELECT ST_HausdorffDistance(
  ST_GeomFromText('LINESTRING(0 0,1 0)',4326),
  ST_GeomFromText('LINESTRING(0 1,1 1)',4326),
  'kilometre'
);

MO 分别返回 string-to-int cast 或 no-overload 错误;MySQL 8.3.0 三者均返回 111.31949079326246。每项重复 3 次;去掉单位参数后 MO 可执行,说明是 overload 缺失。

MySQL reference: https://dev.mysql.com/doc/refman/8.0/en/spatial-relation-functions-object-shapes.html

MO registrations:

// Discrete curve distances: st_frechetdistance, st_hausdorffdistance.
{
functionId: ST_FRECHETDISTANCE,
class: plan.Function_STRICT,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{overloadId: 0, args: []types.T{types.T_geometry, types.T_geometry},
retType: func(parameters []types.Type) types.Type { return types.T_float64.ToType() },
newOp: func() executeLogicOfOverload { return StFrechetDistance }},
{overloadId: 1, args: []types.T{types.T_geometry32, types.T_geometry32},
retType: func(parameters []types.Type) types.Type { return types.T_float32.ToType() },
newOp: func() executeLogicOfOverload { return StFrechetDistance32 }},
},
},
{
functionId: ST_HAUSDORFFDISTANCE,
class: plan.Function_STRICT,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{overloadId: 0, args: []types.T{types.T_geometry, types.T_geometry},
retType: func(parameters []types.Type) types.Type { return types.T_float64.ToType() },
newOp: func() executeLogicOfOverload { return StHausdorffDistance }},
{overloadId: 1, args: []types.T{types.T_geometry32, types.T_geometry32},
retType: func(parameters []types.Type) types.Type { return types.T_float32.ToType() },
newOp: func() executeLogicOfOverload { return StHausdorffDistance32 }},
},
、
// function `st_distance`
{
functionId: ST_DISTANCE,
class: plan.Function_STRICT,
layout: STANDARD_FUNCTION,
checkFn: fixedTypeMatch,
Overloads: []overload{
{
overloadId: 0,
args: []types.T{types.T_geometry, types.T_geometry},
retType: func(parameters []types.Type) types.Type {
return types.T_float64.ToType()
},
newOp: func() executeLogicOfOverload {
return StDistance
},
},
{
overloadId: 1,
args: []types.T{types.T_geometry, types.T_geometry, types.T_int64},
retType: func(parameters []types.Type) types.Type {
return types.T_float64.ToType()
},
newOp: func() executeLogicOfOverload {
return StDistanceWithSRID
},
},
{
overloadId: 2,
args: []types.T{types.T_geometry32, types.T_geometry32},
retType: func(parameters []types.Type) types.Type {
return types.T_float32.ToType()
},
newOp: func() executeLogicOfOverload {
return StDistance32
},

修复时应覆盖 metre/kilometre/foot、未知单位、SRID 0、SRID 4326、NULL、大小写与 Prepared Statement;同时明确兼容现有 MO-specific explicit-SRID overload 的解析规则。

Activity

  1. added this to the MO-202609 milestone on Sep 5, 2026
  2. added
    kind/bug
    on Sep 5, 2026
  3. added theissue type on Sep 5, 2026
  4. self-assigned this
    on Sep 5, 2026
  5. added a commit that references this issue on Sep 20, 2026
    5e1e93a
  6. Ariznawlll commented on Sep 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verified on current main 57c280e.\n\nThe length-unit overloads for ST_Distance, ST_FrechetDistance, and ST_HausdorffDistance are available and execute for SRID 4326. The MOTR regression returns 111.195080 km / 111195.080234 m for the one-degree fixtures, consistently across three runs.\n\nMatrixOne deliberately uses the repository's spherical geodetic model here. This closes the missing-overload/SRID behavior reported by this issue; it does not claim byte-for-byte equality with MySQL's ellipsoidal numeric result.\n\nCoverage: matrixorigin/motr#193,\nsuites/14_issue_regression/t/issue_28200_28194_geodetic_distance_units.test.\n\nClosing as fixed.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions