ST_Contains/ST_Within pushdown: vortex.geo.contains kernel, DuckDB lowering#8720
Merged
Conversation
Merging this PR will improve performance by 11.27%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
vortex-geo gains a GeoContains kernel (vortex.geo.contains): OGC containment, boundary excluded, delegating to geo::Contains. Containment is not symmetric, so the constant dispatch keeps the container and contained roles in two distinct helpers, and the asymmetry is pinned by tests. Operands are validated up front in return_dtype via the shared validate_geometry_operands helper: each must be a native geometry type and non-nullable, matching GeoDistance and GeoIntersects. vortex-duckdb lowers both st_contains and st_within to the one kernel: st_within(a, b) is st_contains(b, a), so the shared match arm swaps the operands for the within spelling. Both functions get spatial override rows so their filters push through views, and the e2e pushdown matrix grows to five filters on both routes. SpatialBench itself only uses ST_Within as join conditions, which stay with DuckDB's spatial join; Q1-Q9 row counts validate unchanged with the new overrides. Signed-off-by: Nemo Yu <zyu379@wisc.edu>
ff8336c to
0fecf92
Compare
connortsui20
approved these changes
Jul 13, 2026
HarukiMoriarty
added a commit
that referenced
this pull request
Jul 13, 2026
…wering (#8720) ## Rationale for this change <!-- Why are you proposing this change, and what is its impact? Is it part of a long term effort, or a bigger change? If this PR is related to a tracked effort or an open issue, please link to the relevant issue. --> Adds the third geo predicate kernel: OGC `ST_Contains`, following the `GeoDistance`/`GeoIntersects` pattern from #8704. One kernel serves both SQL spellings, since `ST_Within(a, b)` is `ST_Contains(b, a)`. ## What changes are included in this PR? - `vortex-geo`: `GeoContains` kernel (`vortex.geo.contains`): OGC containment, boundary excluded, delegating to `geo::Contains`. Containment is asymmetric, so the operand roles are kept in separate helpers and pinned by a test. Nullable operands are rejected like the other kernels. - `vortex-duckdb`: `st_contains` and `st_within` both lower to the kernel — within is contains with the operands swapped. Both get spatial override rows so their filters push through views. Signed-off-by: Nemo Yu <zyu379@wisc.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Adds the third geo predicate kernel: OGC
ST_Contains, following theGeoDistance/GeoIntersectspattern from #8704. One kernel serves both SQL spellings, sinceST_Within(a, b)isST_Contains(b, a).What changes are included in this PR?
vortex-geo:GeoContainskernel (vortex.geo.contains): OGC containment, boundary excluded, delegating togeo::Contains. Containment is asymmetric, so the operand roles are kept in separate helpers and pinned by a test. Nullable operands are rejected like the other kernels.vortex-duckdb:st_containsandst_withinboth lower to the kernel — within is contains with the operands swapped. Both get spatial override rows so their filters push through views.