Uh oh!
There was an error while loading. Please reload this page.
[feature](geo) support 3 spatial functions: ST_Distance, ST_GeometryType, ST_Length - #60170
Conversation
…; run clang-format.sh to format code
Thearas
commented
Jan 23, 2026
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
zxc20041
commented
Jan 23, 2026
run buildall |
There was a problem hiding this comment.
Pull request overview
This PR implements three spatial SQL functions (ST_Distance, ST_GeometryType, ST_Length) to improve compatibility with other database systems like Trino, Presto, and PostgreSQL, as part of the broader effort outlined in issue #48203.
Changes:
- Adds ST_Length function to calculate the length/perimeter of geometry objects (in meters for LineString/Polygon/Circle, 0 for Point)
- Adds ST_GeometryType function to return the geometry type name (e.g., "ST_POINT", "ST_LINESTRING")
- Adds ST_Distance function to calculate the geodesic distance between two geometry objects (in meters)
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| be/src/geo/geo_types.h | Adds virtual method declarations for GeometryType(), Length(), and Distance() to the GeoShape base class and implements them in all derived classes |
| be/src/geo/st_length.cpp | Implements Length() calculations for all geometry types using S2Earth library for geodesic measurements |
| be/src/geo/st_distance.cpp | Implements Distance() calculations between all geometry type combinations with helper functions for point-to-segment, point-to-polyline, and point-to-polygon distances |
| be/src/geo/CMakeLists.txt | Updates build configuration to include the new st_length.cpp and st_distance.cpp source files |
| be/src/vec/functions/functions_geo.cpp | Registers the three new functions (StLength, StGeometryType, StDistance) with the function factory |
| be/test/geo/geo_types_test.cpp | Adds comprehensive C++ unit tests covering all geometry types and type combinations for the new functions |
| fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StLength.java | Frontend scalar function class for ST_Length with proper signature (VARCHAR -> DOUBLE) |
| fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StGeometryType.java | Frontend scalar function class for ST_GeometryType with proper signature (VARCHAR -> VARCHAR) |
| fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/StDistance.java | Frontend scalar function class for ST_Distance with proper signature (VARCHAR, VARCHAR -> DOUBLE) |
| fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/visitor/ScalarFunctionVisitor.java | Adds visitor methods for the three new function types |
| fe/fe-core/src/main/java/org/apache/doris/catalog/BuiltinScalarFunctions.java | Registers the three new scalar functions in the builtin function catalog |
| regression-test/suites/nereids_p0/sql_functions/spatial_functions/test_gis_function.groovy | Adds extensive regression test cases covering all geometry type combinations for the new functions |
| regression-test/data/nereids_p0/sql_functions/spatial_functions/test_gis_function.out | Expected output for the regression tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
doris-robot
commented
Jan 23, 2026
TPC-H: Total hot run time: 31037 ms |
zxc20041
commented
Jan 23, 2026
oops, I forgot to modify be-ut testcase after changing geometry_type |
doris-robot
commented
Jan 23, 2026
TPC-DS: Total hot run time: 172396 ms |
doris-robot
commented
Jan 23, 2026
ClickBench: Total hot run time: 26.78 s |
hello-stephen
commented
Jan 23, 2026
FE UT Coverage ReportIncrement line coverage |
hello-stephen
commented
Jan 23, 2026
FE Regression Coverage ReportIncrement line coverage |
zxc20041
commented
Jan 23, 2026
run buildall |
doris-robot
commented
Jan 23, 2026
TPC-H: Total hot run time: 31328 ms |
doris-robot
commented
Jan 23, 2026
TPC-DS: Total hot run time: 172939 ms |
doris-robot
commented
Jan 23, 2026
ClickBench: Total hot run time: 26.8 s |
hello-stephen
commented
Jan 23, 2026
FE UT Coverage ReportIncrement line coverage |
doris-robot
commented
Jan 23, 2026
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Jan 23, 2026
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Jan 23, 2026
FE Regression Coverage ReportIncrement line coverage |
doris-robot
commented
Jan 29, 2026
TPC-H: Total hot run time: 31658 ms |
hello-stephen
commented
Jan 29, 2026
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
doris-robot
commented
Jan 29, 2026
ClickBench: Total hot run time: 28.5 s |
hello-stephen
commented
Jan 29, 2026
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
linrrzqqq
commented
Feb 6, 2026
run nonConcurrent |
PR approved by anyone and no changes requested. |
zxc20041
commented
Feb 8, 2026
run buildall |
doris-robot
commented
Feb 8, 2026
TPC-H: Total hot run time: 30043 ms |
doris-robot
commented
Feb 8, 2026
ClickBench: Total hot run time: 28.08 s |
hello-stephen
commented
Feb 8, 2026
FE UT Coverage ReportIncrement line coverage |
doris-robot
commented
Feb 8, 2026
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Feb 8, 2026
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
hello-stephen
commented
Feb 8, 2026
FE Regression Coverage ReportIncrement line coverage |
PR approved by at least one committer and no changes requested. |
Uh oh!
There was an error while loading. Please reload this page.
…ST_GeometryType, ST_Length apache#60170 (apache#60748) Cherry-picked from apache#60170 Co-authored-by: Xichun Zhao <111703876+zxc20041@users.noreply.github.com>
What problem does this PR solve?
Issue Number: close#48203
Related PR: #48695
Problem Summary:
Support for ST_Distance, ST_GeometryType, ST_Length sql functions.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)