Skip to content

[GH-2830] Adds Geography dual-dispatch to ST_Area#2853

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

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

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_Area — returns geodesic area in square meters on the WGS84 spheroid for Geography inputs.
  • Using S2 library to calculate the area on sphere 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 dual-dispatch support for ST_Area so Geography inputs return geodesic area (m²) on the WGS84 spheroid, aligning with existing Geography metric behavior (e.g., ST_Distance).

Changes:

  • Add org.apache.sedona.common.geography.Functions.area(Geography) backed by Spheroid.area(JTS).
  • Enable Spark SQL ST_Area expression to resolve to either Geometry-area or Geography-area implementation based on input type.
  • Add/extend unit + Spark SQL integration tests and document the Geography ST_Area function.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/expressions/Functions.scala Adds dual-dispatch resolution for ST_Area (Geometry vs Geography).
common/src/main/java/org/apache/sedona/common/geography/Functions.java Introduces Geography area implementation using spheroid/geodesic area calculation.
spark/common/src/test/scala/org/apache/sedona/sql/geography/GeographyFunctionTest.scala Adds Spark SQL integration tests for ST_Area on Geography inputs.
common/src/test/java/org/apache/sedona/common/Geography/FunctionTest.java Adds unit tests for Geography Functions.area behavior (polygon/point/linestring/null).
docs/api/sql/geography/Geography-Functions/ST_Area.md Adds Geography API documentation for ST_Area.
docs/api/sql/geography/Geography-Functions.md Adds ST_Area to the Geography functions index.

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

@zhangfengcdt zhangfengcdt marked this pull request as ready for review April 28, 2026 17:26
@zhangfengcdt zhangfengcdt requested a review from jiayuasu as a code owner April 28, 2026 17:26
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Apr 28, 2026
@jiayuasu jiayuasu merged commit 3fd82e9 into apache:master Apr 28, 2026
44 of 45 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