Skip to content

[GH-3511] Add ST_H3ToPoint - #3512

Merged
jiayuasu merged 1 commit into
apache:masterfrom
simenojensen:codex/h3-to-point
Nov 1, 2026
Merged

jiayuasu merged 1 commit into
apache:masterfrom
simenojensen:codex/h3-to-point

Conversation

@simenojensen

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Yes, I have read the Contributor Rules and Contributor Development Guide.

Is this PR related to a ticket?

Closes #3511.

What changes were proposed in this PR?

Add ST_H3ToPoint(cell) to return an H3 cell center as a point geometry in Spark SQL, the Scala and Python DataFrame APIs, and Flink SQL. This avoids converting the cell to a polygon and computing its centroid, which can differ from H3’s center.

The implementation reuses H3Utils.cellToCoordinate, returns longitude/latitude in degrees, and leaves SRID at 0 to match ST_H3ToGeom. Users can assign WGS 84 with ST_SetSRID(..., 4326). Null input returns null; invalid H3 cell indexes raise an error.

How was this patch tested?

  • Common FunctionsTest: 337 tests passed, including known center coordinates, all 16 resolutions, pentagons, SRID, polygon centroid differences, and invalid IDs.
  • Spark STH3Functions: 23 tests passed, including SQL registration, coordinate order, SRID, and null propagation.
  • Scala dataFrameAPITestScala: 268 tests passed, including column and literal overloads.
  • Focused Flink FunctionTest#testH3ToPoint: passed, including SQL registration, coordinates, SRID, and null input.
  • mvn spotless:apply, Python syntax checks, and git diff --check passed.
  • Python integration test added but not run locally because PySpark is not installed in the available Python interpreter.

Did this PR include necessary documentation updates?

Yes. Added Spark SQL and Flink API documentation and function index entries using the current SNAPSHOT version, v2.0.0, with SQL examples and SRID guidance.

@jiayuasu jiayuasu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. Please update the branch to pick up #3510 and rerun CI.

@jiayuasu
jiayuasu merged commit 9aea327 into apache:master Nov 1, 2026
41 of 43 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.

Add ST_H3ToPoint to return the center of an H3 cell

2 participants