Skip to content

[GH-3020] Add ST_H3ToCenterChild - #3481

Merged
jiayuasu merged 2 commits into
apache:masterfrom
simenojensen:codex/gh-3020-h3-center-child
Oct 19, 2026
Merged

jiayuasu merged 2 commits into
apache:masterfrom
simenojensen:codex/gh-3020-h3-center-child

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?

Related to #3020. Continues the incremental H3 hierarchy APIs from #3310, #3470, and #3474. This PR targets master independently of the compact implementation in #3480.

What changes were proposed in this PR?

Add ST_H3ToCenterChild(cell, resolution), backed by the existing H3 cellToCenterChild API. It returns the center descendant at the requested resolution as a long cell ID. Equal resolutions return the input cell; coarser targets and resolutions outside 0–15 propagate H3 errors. Null cell or resolution arguments return null in Spark and Flink SQL.

Expose the function through Spark SQL, the Scala and Python DataFrame APIs, and Flink SQL. Add Spark and Flink API pages and catalog entries for v2.0.0.

Tests cover known center-child IDs, skipping resolutions, consistency between direct and intermediate traversal, pentagons, equal resolutions, boundary resolutions 0 and 15, invalid targets, literal and column null arguments, and all Scala/Python wrapper overloads.

How was this patch tested?

Validated locally with Java 17, Spark 3.5.0 / Scala 2.12, Flink 1.19.0, and Python 3.11:

  • mvn -o spotless:apply and mvn -o spotless:check — passed.
  • mvn -o -pl common -am '-Dtest=org.apache.sedona.common.FunctionsTest#h3ToCenterChild*' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.javadoc.skip=true install — all 4 tests passed.
  • mvn -o -pl spark/common -DskipTests test-compile — production and test sources compiled.
  • mvn -o -pl spark/common -Dsuites=org.apache.sedona.sql.functions.STH3Functions,org.apache.sedona.sql.dataFrameAPITestScala org.scalatest:scalatest-maven-plugin:2.2.0:test — all 282 tests passed (17 H3 tests and 265 Scala DataFrame API tests).
  • mvn -o -pl flink -Dtest=FunctionTest#testH3ToCenterChild test — passed, including nullable arguments supplied through table columns.
  • python -m pytest tests/sql/test_function.py tests/sql/test_dataframe_api.py -k test_st_h3_to_center_child -q — both tests passed against the newly compiled JVM classes and Maven dependency classpath supplied through SPARK_DIST_CLASSPATH.
  • Black checks for all three modified Python files and git diff --check — passed.

Did this PR include necessary documentation updates?

Yes. Added Spark SQL and Flink function pages and updated both API catalogs, using the current SNAPSHOT version v2.0.0.

@jiayuasu jiayuasu added this to the sedona-2.0.0 milestone Oct 19, 2026
@jiayuasu
jiayuasu merged commit eead837 into apache:master Oct 19, 2026
41 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.

2 participants