Skip to content

[GH-2830] Add Geography support for ST_Equals#2855

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

[GH-2830] Add Geography support for ST_Equals#2855
jiayuasu merged 3 commits intoapache:masterfrom
zhangfengcdt:feature/geography.support.st_equals

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?

  • Converts ST_Equals to InferredExpression for dual-dispatch (Geometry vs Geography)
  • Follow-up to [GH-2830] Improve Geography query support - core #2831; L3 tier. ST_Equals in Predicates.scala is converted from ST_Predicate with CodegenFallback to InferredExpression(Predicates.equals, geography.Functions.equals).
    • JoinQueryDetector: moves ST_Equals out of getJoinDetection (it's no longer an ST_Predicate subtype) and adds a top-level case with the existing isGeographyInput guard, mirroring ST_Contains. Preserves today's Geometry-path join planning; 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.

- Converts ST_Equals to InferredExpression for dual-dispatch (Geometry vs Geography)
- Geography path: uses S2 spherical equality via Predicates.equals
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_Equals by converting it to an InferredExpression (dual-dispatch Geometry vs Geography), while ensuring join planning remains Geometry-only and Geography joins fall back to Spark evaluation.

Changes:

  • Convert ST_Equals from ST_Predicate to InferredExpression wired to both JTS (Predicates.equals) and S2 (geography.Functions.equals).
  • Update JoinQueryDetector to keep Geometry join optimization for ST_Equals while skipping join planning when either side is GeographyUDT.
  • Add Geography equality implementation + unit/integration tests and publish new Geography SQL docs for ST_Equals.

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_Equals to dual-dispatch via InferredExpression (Geometry + Geography).
common/src/main/java/org/apache/sedona/common/geography/Functions.java Add S2-based Functions.equals(Geography, Geography) implementation.
spark/common/src/main/scala/org/apache/spark/sql/sedona_sql/strategy/join/JoinQueryDetector.scala Move ST_Equals join detection to top-level match with Geography guard (no Geography join planning).
common/src/test/java/org/apache/sedona/common/Geography/FunctionTest.java Add unit tests for Functions.equals (points/polygon + null handling).
spark/common/src/test/scala/org/apache/sedona/sql/geography/GeographyFunctionTest.scala Add Spark SQL integration tests for ST_Equals on Geography (point cases).
docs/api/sql/geography/Geography-Functions.md Add ST_Equals to Geography function index.
docs/api/sql/geography/Geography-Functions/ST_Equals.md New Geography SQL docs page for ST_Equals.

💡 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 29, 2026 04:17
@zhangfengcdt zhangfengcdt requested a review from jiayuasu as a code owner April 29, 2026 04:17
@jiayuasu jiayuasu merged commit e7abacd 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