james-willis opened a new pull request, #1163: URL: https://github.com/apache/sedona-db/pull/1163
## What changes were proposed in this PR? Implement `ST_GeoHash(geometry, precision)` returning the base-32 geohash string of the geometry, matching Apache Sedona Spark semantics: - Non-point geometries hash the **center of the bounding box** (GeometryGeoHashEncoder.java:40-41) - Returns null when the bbox falls outside [-180,180]×[-90,90] (GeometryGeoHashEncoder.java:33-38) - `precision <= 0` returns an empty string; precision caps at 20 (PointGeoHashEncoder.java:29-32) - Standard lon-first bit interleaving with the `0123456789bcdefghjkmnpqrstuvwxyz` alphabet The encoder is implemented by hand (~40 lines) — no new crate dependency. Follows crate conventions: `SedonaScalarUDF::new` + `ItemCrsKernel::wrap_impl`, `WkbExecutor`, `ArgMatcher::is_geometry() + is_integer()` with per-row Int64-cast precision (modeled on `st_geometryn`), Utf8 return via `StringBuilder` (modeled on `st_geometrytype`). Two deliberate deviations from Sedona Spark, documented in code: 1. **Empty geometries return null** — Sedona Java hits a JTS null-envelope artifact (`minx=0, maxx=-1`) and accidentally hashes empty geometries as (-0.5, -0.5); returning null is PostGIS-consistent. 2. **Geometry-only** (no geography kernel), matching Sedona Spark's signature; precedent: `st_xmin`/`st_ymin` are geometry-only for the same planar-bbox reason. ## Why are the changes needed? `ST_GeoHash` is used in Sedona Spark pipelines (e.g. for spatial bucketing/partitioning keys); sedona-db currently has no implementation, so such SQL fails with an unknown-function error. ## How was this patch tested? 8 new tests in `st_geohash.rs` with expected values taken from Sedona Spark's `TestStGeoHash.scala` (each vector cited in a comment), including WKB_VIEW_GEOMETRY and ITEM_CRS variants, precision capping, out-of-range nulls, and pole/antimeridian edge cases. `cargo test -p sedona-functions` passes (513 tests), clippy and fmt clean. ## Did this PR include necessary documentation updates? Function-level rustdoc included; happy to add a SQL reference doc page if maintainers point me at the right template. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
