Skip to content

test(integration): geometry results in the parity harness; RS_WorldToRasterCoord + RS_RasterToWorldCoord catalogs - #1264

Merged
james-willis merged 3 commits into
apache:mainfrom
james-willis:jw/parity-worldtorastercoord
Sep 11, 2026
Merged

test(integration): geometry results in the parity harness; RS_WorldToRasterCoord + RS_RasterToWorldCoord catalogs#1264
james-willis merged 3 commits into
apache:mainfrom
james-willis:jw/parity-worldtorastercoord

Conversation

@james-willis

Copy link
Copy Markdown
Contributor

Unblocks geometry-returning raster functions in the spark-parity suite and uses that to catalog the RS_WorldToRasterCoord / RS_RasterToWorldCoord combined forms — including the missing point-geometry overload.

Harness: geometry results (first commit)

Probing showed the two sides fail asymmetrically:

  • SedonaDB needed nothing: its geometry results already arrive as geoarrow.wkb and result_to_tuples already renders them as WKT.
  • Sedona Spark was the broken side: DataFrame.toArrow() ships a GeometryUDT column as the UDT's internal serialization bytes — not ISO WKB — which the tuple path then tried to cast to string ("Invalid UTF8 payload").

SedonaSpark.result_to_table now converts geometry columns to WKB in the JVM (ST_AsBinary, transport-only — the same pattern decode_raster_result uses with RS_AsGeoTiff; the shared test SQL stays RS-only) and re-tags the bytes as geoarrow.wkb, so both engines render WKT through the same geoarrow formatter. Columns are renamed positionally before the select because Spark's generated names (rs_worldtorastercoord(rast, 104.0, 494.0)) contain dots that every name-based lookup re-parses as a nested path; the original names are restored on the Arrow table.

Everything downstream (result_to_tuples, assert_result, WKT expected= anchors, compare()) works unchanged. Full suite on this branch: 174 passed, 84 xfailed — main's counts plus exactly the 7 new xfails.

RS_WorldToRasterCoord (second commit)

All probed, every case an xfail stating both observed behaviors:

RS_RasterToWorldCoord

The input side of #1235: (1, 1) answers POINT (102 497) from SedonaDB (0-based input) and POINT (100 500) — the origin corner — from Spark (1-based input).

Follow-ups this unblocks

The remaining geometry-returning functions can now get parity files the same way: RS_Envelope, RS_ConvexHull, RS_PixelAsPoint / RS_PixelAsCentroid / RS_PixelAsPolygon. (Item-level-CRS geometry outputs may need another look — these fixtures are CRS-less.) The test_rs_worldtorastercoordx/y docstrings still say the combined form is "deferred"; updating that line is left out here because #1262 touches the same sentence — whichever lands second gets the one-line fix.

@james-willis
james-willis marked this pull request as ready for review September 10, 2026 23:57
# (transport-only, like decode_raster_result's RS_AsGeoTiff) and
# re-tag the bytes as geoarrow.wkb — geometry results then render
# WKT through the same geoarrow path as every other engine.
import geoarrow.pyarrow as ga

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.

This one can be a module level import (since pyarrow already is)

Also, isn't there already a "to geoarrow"? I PRed one into Sedona a few years ago but maybe it's gone now.

Review follow-up: sedona.spark.geoarrow.dataframe_to_arrow already does the
EWKB conversion and geoarrow tagging, so the hand-rolled ST_AsBinary + re-tag
path (and its geoarrow.pyarrow import) goes away. The positional rename stays,
now wrapped around the utility: dataframe_to_arrow resolves columns by name
and fails on Spark's dotted generated names (apache/sedona#3351).
@james-willis

Copy link
Copy Markdown
Contributor Author

Follow-up pushed (f7ebe5c): the hand-rolled ST_AsBinary + re-tag path is gone in favor of sedona.spark.geoarrow.dataframe_to_arrow, which was indeed already there and does the EWKB conversion + geoarrow tagging (with CRS inference as a bonus). The geoarrow.pyarrow import disappears with it.

One wrinkle: dataframe_to_arrow resolves columns by name (list(df)__getitem__), so it fails on Spark's dotted generated names like rs_worldtorastercoord(rast, 104.0, 494.0) — filed as apache/sedona#3351 with a repro. Until that lands, the harness renames columns positionally around the call and restores the names on the Arrow table. Full suite unchanged: 174 passed, 84 xfailed.

@james-willis
james-willis merged commit eca0b61 into apache:main Sep 11, 2026
4 checks passed
@james-willis
james-willis deleted the jw/parity-worldtorastercoord branch September 11, 2026 19:09
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