Skip to content

[GH-2830] Adds Geography dual-dispatch to ST_Intersects#2856

Merged
jiayuasu merged 6 commits intoapache:masterfrom
zhangfengcdt:feature/geography.support.st_intersects
Apr 30, 2026
Merged

[GH-2830] Adds Geography dual-dispatch to ST_Intersects#2856
jiayuasu merged 6 commits intoapache:masterfrom
zhangfengcdt:feature/geography.support.st_intersects

Conversation

@zhangfengcdt
Copy link
Copy Markdown
Member

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_Intersects — spherical intersection via S2 boolean operations for Geography inputs; Geometry path unchanged.
  • Follow-up to [GH-2830] Improve Geography query support - core #2831; L3 tier. ST_Intersects in Predicates.scala is converted from ST_Predicate with CodegenFallback to InferredExpression(Predicates.intersects, geography.Functions.intersects).
  • JoinQueryDetector: moves ST_Intersects out of getJoinDetection and adds a top-level case with the isGeographyInput guard, mirroring the ST_Contains / ST_Equals treatment. Geometry-path join planning preserved; Geography inputs fall back to row-by-row evaluation.

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

This PR extends Sedona’s ST_Intersects to support Geography inputs via dual-dispatch: Geometry inputs continue to use the existing JTS implementation, while Geography inputs use S2 boolean operations, and join planning remains geometry-only (geography falls back to row-by-row evaluation).

Changes:

  • Convert ST_Intersects from ST_Predicate to InferredExpression with Geometry/Geography dual-dispatch.
  • Update join detection so ST_Intersects is planned as a spatial join only for non-Geography inputs.
  • Add Geography unit/integration tests and introduce new SQL docs for Geography ST_Intersects.

Reviewed changes

Copilot reviewed 7 out of 7 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/Predicates.scala Switch ST_Intersects to dual-dispatch (InferredExpression) for Geography support.
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinQueryDetector.scala Preserve geometry join planning for ST_Intersects and guard against Geography inputs.
common/src/main/java/org/apache/sedona/common/geography/Functions.java Add S2-based Functions.intersects(Geography, Geography).
common/src/test/java/org/apache/sedona/common/Geography/FunctionTest.java Add Geography-level unit tests for Functions.intersects.
spark/common/src/test/scala/org/apache/sedona/sql/geography/GeographyFunctionTest.scala Add Spark SQL integration tests for Geography ST_Intersects.
docs/api/sql/geography/Geography-Functions/ST_Intersects.md Add Geography SQL API documentation page for ST_Intersects.
docs/api/sql/geography/Geography-Functions.md Add ST_Intersects to the Geography functions index table.

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

Comment thread docs/api/sql/geography/Geography-Functions.md
@zhangfengcdt zhangfengcdt marked this pull request as ready for review April 29, 2026 17:26
@zhangfengcdt zhangfengcdt requested a review from jiayuasu as a code owner April 29, 2026 17:26
Comment thread docs/api/sql/geography/Geography-Functions/ST_Intersects.md
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Apr 30, 2026
@jiayuasu jiayuasu merged commit e0a807f into apache:master Apr 30, 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