Skip to content

feat(python/sedonadb): Expose scalar and aggregate udfs from context registry#885

Draft
paleolimbot wants to merge 4 commits into
apache:mainfrom
paleolimbot:python-funcs
Draft

feat(python/sedonadb): Expose scalar and aggregate udfs from context registry#885
paleolimbot wants to merge 4 commits into
apache:mainfrom
paleolimbot:python-funcs

Conversation

@paleolimbot
Copy link
Copy Markdown
Member

@paleolimbot paleolimbot commented May 27, 2026

Still working on the tests, but the idea is to make it more compact to generate expressions:

import sedona.db

sd = sedona.db.connect()
f = sd.funcs

t = sd.funcs.table.sd_random_geometry(num_rows=100)
t.filter(
    f.st_dwithin(t.geometry, f.st_point(50, 50), 10)
).show()
# ┌───────┬────────────────────┬──────────────────────────────────────────────┐
# │   id  ┆        dist        ┆                   geometry                   │
# │ int32 ┆       float64      ┆                   geometry                   │
# ╞═══════╪════════════════════╪══════════════════════════════════════════════╡
# │    54 ┆  59.62435027266706 ┆ POINT(44.832630149284846 42.9320865879236)   │
# ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │    62 ┆ 43.885794593815966 ┆ POINT(54.858587734052435 51.438644994339946) │
# ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │    79 ┆  95.62798350158674 ┆ POINT(54.57939637408915 46.18785999007198)   │
# ├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │    89 ┆  26.04589019859811 ┆ POINT(46.642374405687505 43.235146303817395) │
# └───────┴────────────────────┴──────────────────────────────────────────────┘

t = sd.read_parquet("https://github.com/geoarrow/geoarrow-data/releases/download/v0.2.0/ns-water_elevation.parquet")
t.select(
    t.ZVALUE,
    t.geometry,
    f.st_force2d(t.geometry).alias("geometry2d")
).show()
# ┌─────────┬────────────────────────────────────────────┬───────────────────────────────────────────┐
# │  ZVALUE ┆                  geometry                  ┆                 geometry2d                │
# │ float64 ┆                  geometry                  ┆                  geometry                 │
# ╞═════════╪════════════════════════════════════════════╪═══════════════════════════════════════════╡
# │   452.8 ┆ POINT Z(683614.4199000001 5179827.8823000… ┆ POINT(683614.4199000001 5179827.88230000… │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   452.2 ┆ POINT Z(683612.4199000001 5179875.8823000… ┆ POINT(683612.4199000001 5179875.88230000… │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   454.8 ┆ POINT Z(683692.8198999995 5179860.3823000… ┆ POINT(683692.8198999995 5179860.38230000… │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   456.5 ┆ POINT Z(683691.0198999997 5179897.3823000… ┆ POINT(683691.0198999997 5179897.38230000… │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   461.7 ┆ POINT Z(683774.2198999999 5179837.9823 46… ┆ POINT(683774.2198999999 5179837.9823)     │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   466.7 ┆ POINT Z(683854.5198999997 5179825.4823 46… ┆ POINT(683854.5198999997 5179825.4823)     │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   466.7 ┆ POINT Z(683851.4199000001 5179882.4823 46… ┆ POINT(683851.4199000001 5179882.4823)     │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   463.0 ┆ POINT Z(683772.5198999997 5179873.9823 46… ┆ POINT(683772.5198999997 5179873.9823)     │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   461.8 ┆ POINT Z(683769.3198999995 5179938.8823000… ┆ POINT(683769.3198999995 5179938.88230000… │
# ├╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
# │   460.2 ┆ POINT Z(683767.3198999995 5179989.8823000… ┆ POINT(683767.3198999995 5179989.88230000… │
# └─────────┴────────────────────────────────────────────┴───────────────────────────────────────────┘

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