Skip to content

[GH-2830] Adds Geography dual-dispatch to ST_Length#2854

Merged
jiayuasu merged 5 commits intoapache:masterfrom
zhangfengcdt:feature/geography.support.st_length
Apr 29, 2026
Merged

[GH-2830] Adds Geography dual-dispatch to ST_Length#2854
jiayuasu merged 5 commits intoapache:masterfrom
zhangfengcdt:feature/geography.support.st_length

Conversation

@zhangfengcdt
Copy link
Copy Markdown
Member

@zhangfengcdt zhangfengcdt commented Apr 22, 2026

Did you read the Contributor Guide?

Is this PR related to a ticket?

  • Yes, and the PR name follows the format [GH-XXX] my subject. Closes #<issue_number>

What changes were proposed in this PR?

  • Adds Geography dual-dispatch to ST_Length — returns geodesic length in meters on the WGS84 spheroid for Geography inputs.
  • Use S2 directly to calculate the length directly.

How was this patch tested?

  • mvn clean test -pl common -am -Dtest=FunctionTest
  • New Spark SQL cases in GeographyFunctionTest
  • mvn spotless:apply run before commit; no format violations.

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Geography support for ST_Length so Spark SQL can return geodesic length (meters, WGS84 spheroid) when the input is a Geography, while preserving existing planar Geometry behavior.

Changes:

  • Add dual-dispatch for ST_Length in Spark SQL expression resolution (Geometry vs Geography).
  • Implement org.apache.sedona.common.geography.Functions.length(Geography) using Spheroid.length(toJTS(g)).
  • Add unit/integration tests and new Geography SQL docs page for ST_Length.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala Adds Geography overload to ST_Length expression via inferred overload resolution.
common/src/main/java/org/apache/sedona/common/geography/Functions.java Introduces geodesic length(Geography) implementation (WGS84 spheroid via Spheroid).
common/src/test/java/org/apache/sedona/common/Geography/FunctionTest.java Adds core-module tests for geodesic length (equator/meridian/point/null).
spark/common/src/test/scala/org/apache/sedona/sql/geography/GeographyFunctionTest.scala Adds Spark SQL integration tests for ST_Length on Geography.
docs/api/sql/geography/Geography-Functions/ST_Length.md Adds Geography function documentation for ST_Length.
docs/api/sql/geography/Geography-Functions.md Adds ST_Length entry to the Geography functions index.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/src/main/java/org/apache/sedona/common/geography/Functions.java Outdated
Comment thread docs/api/sql/geography/Geography-Functions/ST_Length.md Outdated
@zhangfengcdt zhangfengcdt marked this pull request as ready for review April 28, 2026 17:28
@zhangfengcdt zhangfengcdt requested a review from jiayuasu as a code owner April 28, 2026 17:28
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Apr 29, 2026
@jiayuasu jiayuasu merged commit 442bb90 into apache:master Apr 29, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants