Skip to content

feat(r/sedonadb): Add spatial join syntax and join type helpers#814

Merged
paleolimbot merged 12 commits into
apache:mainfrom
paleolimbot:r-join-df-syntax
May 8, 2026
Merged

feat(r/sedonadb): Add spatial join syntax and join type helpers#814
paleolimbot merged 12 commits into
apache:mainfrom
paleolimbot:r-join-df-syntax

Conversation

@paleolimbot
Copy link
Copy Markdown
Member

@paleolimbot paleolimbot commented May 5, 2026

This PR adds friendlier syntax for using geometry columns as join conditions, including helpers for joining by spatial predicates:

library(sedonadb)

cities <- sd_read_parquet(system.file(
  "files/natural-earth_cities_geo.parquet",
  package = "sedonadb"
))
countries <- sd_read_parquet(system.file(
  "files/natural-earth_countries_geo.parquet",
  package = "sedonadb"
))

cities |> sd_left_join(countries, by = sd_join_intersects())
#> <sedonab_dataframe: NA x 4>
#> ┌──────────────┬───────────────────────────────┬────────────┬───────────┐
#> │    name.x    ┆            geometry           ┆   name.y   ┆ continent │
#> │     utf8     ┆            geometry           ┆    utf8    ┆    utf8   │
#> ╞══════════════╪═══════════════════════════════╪════════════╪═══════════╡
#> │ Lobamba      ┆ POINT(31.1999971 -26.4666675) ┆ eSwatini   ┆ Africa    │
#> ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
#> │ Vaduz        ┆ POINT(9.5166695 47.1337238)   ┆ Austria    ┆ Europe    │
#> ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
#> │ Luxembourg   ┆ POINT(6.1300028 49.6116604)   ┆ Luxembourg ┆ Europe    │
#> ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
#> │ Vatican City ┆ POINT(12.4533865 41.9032822)  ┆ Italy      ┆ Europe    │
#> ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
#> │ San Marino   ┆ POINT(12.4417702 43.9360958)  ┆ Italy      ┆ Europe    │
#> ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┤
#> │ Palikir      ┆ POINT(158.1499743 6.9166437)  ┆            ┆           │
#> └──────────────┴───────────────────────────────┴────────────┴───────────┘
#> Preview of up to 6 row(s)

Created on 2026-05-04 with reprex v2.1.1

paleolimbot and others added 8 commits May 3, 2026 23:19
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@github-actions github-actions Bot requested a review from zhangfengcdt May 5, 2026 03:23
Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
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 extends the R sedonadb API with dplyr-style join helper functions and spatial join shorthands, and updates the join-expression machinery so spatial predicates can participate in default join column selection.

Changes:

  • Added R join helpers such as sd_left_join(), sd_right_join(), sd_inner_join(), sd_full_join(), sd_semi_join(), sd_anti_join(), and sd_cross_join(), plus a new keep argument on sd_join().
  • Added spatial join helpers (sd_join_intersects(), sd_join_contains(), etc.), .tables pronoun support, and x$geom()/y$geom() shorthand handling in join expressions.
  • Updated expression parsing and tests/docs to support treating spatial predicate calls as join-key-like expressions for default projection behavior.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
r/sedonadb/tests/testthat/test-pkg-dplyr.R Swaps direct sd_join() calls for helper joins and adds keep = TRUE parity checks vs dplyr.
r/sedonadb/tests/testthat/test-join-expression.R Adds coverage for .tables, geom() shorthand, spatial function parsing, and renamed join-key extraction helper.
r/sedonadb/tests/testthat/test-expression.R Expands expression parsing tests to cover scalar-function calls as binary-like expressions.
r/sedonadb/tests/testthat/test-dataframe.R Removes join tests that were moved into a dedicated join-focused test file.
r/sedonadb/tests/testthat/test-dataframe-join.R New join test file covering select behavior, join types, and default geometry-column selection for spatial joins.
r/sedonadb/tests/testthat/_snaps/join-expression.md Updates snapshots for new join-expression evaluation cases and errors.
r/sedonadb/src/rust/src/expression.rs Extends parse_binary() to expose scalar functions with 2+ args as binary-like parsed expressions.
r/sedonadb/R/join-expression.R Adds spatial join helper APIs, .tables, geom() handling, join-function evaluation changes, and new default-select logic.
r/sedonadb/R/dataframe.R Removes the original sd_join() implementation after moving join logic into a dedicated file.
r/sedonadb/R/dataframe-join.R New home for sd_join() plus new dplyr-style join helper wrappers and keep support.
r/sedonadb/NAMESPACE Exports the new join helpers, .tables, and $ method for sedonadb_table_ref.
r/sedonadb/man/sd_join.Rd Regenerated docs for join helpers and the new keep argument.
r/sedonadb/man/sd_join_by.Rd Regenerated docs for spatial join shorthands and .tables/geom() join-expression syntax.
r/sedonadb/man/dot-tables.Rd Adds documentation for the exported .tables pronoun.

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

Comment thread r/sedonadb/R/dataframe-join.R Outdated
Comment thread r/sedonadb/R/join-expression.R
Comment thread r/sedonadb/R/join-expression.R Outdated
Comment thread r/sedonadb/R/join-expression.R
Comment thread r/sedonadb/tests/testthat/test-dataframe-join.R Outdated
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@paleolimbot paleolimbot requested a review from Copilot May 5, 2026 19:35
Copy link
Copy Markdown
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

Copilot reviewed 14 out of 14 changed files in this pull request and generated 11 comments.


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

Comment thread r/sedonadb/R/join-expression.R
Comment thread r/sedonadb/R/dataframe-join.R Outdated
Comment thread r/sedonadb/R/dataframe-join.R Outdated
Comment thread r/sedonadb/R/dataframe-join.R
Comment thread r/sedonadb/R/dataframe-join.R Outdated
Comment thread r/sedonadb/R/join-expression.R
Comment thread r/sedonadb/R/dataframe-join.R
Comment thread r/sedonadb/R/join-expression.R Outdated
Comment thread r/sedonadb/R/join-expression.R Outdated
Comment thread r/sedonadb/R/join-expression.R
@paleolimbot paleolimbot marked this pull request as ready for review May 6, 2026 02:04
Copy link
Copy Markdown
Member

@zhangfengcdt zhangfengcdt left a comment

Choose a reason for hiding this comment

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

LGTM

@paleolimbot paleolimbot merged commit f0aa476 into apache:main May 8, 2026
9 checks passed
@paleolimbot paleolimbot deleted the r-join-df-syntax branch May 8, 2026 17:43
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.

3 participants