Skip to content

Conversation

@paleolimbot
Copy link
Member

@paleolimbot paleolimbot commented Jan 21, 2026

This PR implements an EWKB writer and uses it to implement ST_AsEWKB.

import sedona.db

sd = sedona.db.connect()

sd.sql("SELECT ST_AsEWKB(ST_GeomFromEWKT('SRID=26920;POINT (0 1)')) as ewkb").show()
#> ┌────────────────────────────────────────────────────┐
#> │                        ewkb                        │
#> │                       binary                       │
#> ╞════════════════════════════════════════════════════╡
#> │ 0101000020286900000000000000000000000000000000f03f │
#> └────────────────────────────────────────────────────┘

# Regular binary is shorter because it doesn't have the embedded SRID
sd.sql("SELECT ST_AsBinary(ST_GeomFromEWKT('SRID=26920;POINT (0 1)')) as ewkb").show()
#> ┌────────────────────────────────────────────┐
#> │                    ewkb                    │
#> │                   binary                   │
#> ╞════════════════════════════════════════════╡
#> │ 01010000000000000000000000000000000000f03f │
#> └────────────────────────────────────────────┘

@paleolimbot paleolimbot requested a review from Copilot January 22, 2026 06:18
Copy link
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

This PR implements the ST_AsEWKB function with support for CRS (Coordinate Reference System) metadata, enabling EWKB (Extended Well-Known Binary) output that includes SRID information.

Changes:

  • Adds EWKB writer implementation with SRID support for all geometry types
  • Implements ST_AsEWKB scalar UDF with both type-level and item-level CRS support
  • Adds comprehensive test coverage for EWKB serialization across geometry types and dimensions

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/sedona-geometry/src/lib.rs Exports new ewkb_factory module
rust/sedona-geometry/src/ewkb_factory.rs Implements EWKB writer with SRID encoding for all geometry types
rust/sedona-functions/src/st_asewkb.rs Implements ST_AsEWKB UDF with CRS support
rust/sedona-functions/src/register.rs Registers ST_AsEWKB function in default function set
rust/sedona-functions/src/lib.rs Declares st_asewkb module
rust/sedona-functions/src/executor.rs Adds support for iterating over item CRS struct types
python/sedonadb/tests/functions/test_wkb.py Adds parametrized tests comparing SedonaDB and PostGIS EWKB output
python/sedonadb/python/sedonadb/testing.py Extends geom_or_null helper to support SRID parameter
python/sedonadb/pyproject.toml Adds pandas version constraint as workaround

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@paleolimbot paleolimbot marked this pull request as ready for review January 22, 2026 06:23
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.

1 participant