Skip to content

feat(python/sedonadb): Handle crs-like objects in parameterized queries#660

Merged
paleolimbot merged 2 commits intoapache:mainfrom
paleolimbot:crs-literal-python
Feb 26, 2026
Merged

feat(python/sedonadb): Handle crs-like objects in parameterized queries#660
paleolimbot merged 2 commits intoapache:mainfrom
paleolimbot:crs-literal-python

Conversation

@paleolimbot
Copy link
Member

This PR adds support for literal conversion for the three CRS-like objects I know about, the main one being pyproj.CRS(). This is a nice quality of life improvement for writing SQL against GeoPandas data frames. For example, this is finding all the points within 10 km of some lon/lat:

import geopandas
import sedona.db

url = "https://github.com/geoarrow/geoarrow-data/releases/download/v0.2.0/ns-water_water-point.fgb"
gdf = geopandas.read_file(url)

sd = sedona.db.connect()
sd.create_data_frame(gdf).to_view("gdf", overwrite=True)

sd.sql("""
    SELECT "OBJECTID", "FEAT_CODE", geometry FROM gdf
    WHERE ST_DWithin(ST_Transform(ST_Point(-64, 45, 4326), $1), geometry, 10000)
""", params=(gdf.crs,)).show()
#> ┌──────────┬───────────┬─────────────────────────────────────────────────────────────────┐
#> │ OBJECTID ┆ FEAT_CODE ┆                             geometry                            │
#> │   int64  ┆    utf8   ┆                             geometry                            │
#> ╞══════════╪═══════════╪═════════════════════════════════════════════════════════════════╡
#> │    18927 ┆ WAFA60    ┆ POINT Z(428474.02329999954 4984050.078299999 77.89999999999418) │
#> ├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
#> │    18915 ┆ WADM60    ┆ POINT Z(421205.36319999956 4983412.968 22.89999999999418)       │
#> ├╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
#> │    17112 ┆ WAFA60    ┆ POINT Z(418256.42310000025 4975386.877800001 71.80000000000291) │
#> └──────────┴───────────┴─────────────────────────────────────────────────────────────────┘

@paleolimbot paleolimbot marked this pull request as ready for review February 24, 2026 17:41
return f"<Literal>\n{repr(self._value)}"


def lit(value: Any) -> Literal:
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to add CRS support information here since it is supported literal now?

@paleolimbot paleolimbot merged commit 8c837de into apache:main Feb 26, 2026
5 checks passed
@paleolimbot paleolimbot deleted the crs-literal-python branch February 26, 2026 15:01
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