Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vortex-spatial/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ divan = { workspace = true }
mimalloc = { workspace = true }
rstest = { workspace = true }
vortex-array = { workspace = true, features = ["_test-harness"] }
vortex-file = { workspace = true }
vortex-io = { workspace = true }
vortex-layout = { workspace = true }
vortex-spatial = { path = ".", features = ["_test-harness"] }

Expand Down
8 changes: 7 additions & 1 deletion vortex-spatial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,22 @@ Avoid per-row `scalar_at` or validity lookups in either path. Materialize coordi
The current rules can prune:

- positive `ST_Intersects(geometry_column, constant_geometry)` filters when the boxes are disjoint;
- positive `ST_Contains(geometry_column, constant_geometry)` filters when the file or zone box cannot cover the constant's box;
- positive `ST_Contains(constant_geometry, geometry_column)` filters (equivalently `ST_Within(geometry_column, constant_geometry)`) when the boxes are disjoint;
- `<`, `<=`, `>`, and `>=` comparisons on
`ST_Distance(geometry_column, constant_geometry)` using box-distance bounds.

These proofs are conservative. If the expression has a different shape, the constant is null or empty, or the file has no AABB statistic, the chunk is kept. Box overlap alone never proves that two geometries intersect.

Containment is directional. A file or zone box that extends outside a constant's box may still contain rows within that constant, so that alone cannot prune `ST_Within`. Box coverage does not prove geometry containment either; `NOT ST_Contains` and `NOT ST_Within` have no spatial pruning proof.

The same rules work with file-level AABB statistics, including nested geometry fields. To record file bounds, use `include_nested_statistics().with_file_statistics(...)` with `GeometryAabb.bind(EmptyOptions)` in the aggregate list. This replaces the default file aggregate list. The [containment pruning tests](src/prune/contains.rs) exercise file pruning without zone maps and zone pruning without file statistics.

## Interoperability and limits

Arrow import and export use the standard GeoArrow extension names and preserve CRS metadata. Native import only supports separated coordinates; interleaved GeoArrow arrays are rejected.

DuckDB uses WKB for general geometry values. Its Vortex expression lowering converts supported WKB constants to native scalars and pushes `ST_Contains`, `ST_Distance`, and `ST_Intersects` into a Vortex scan.
DuckDB uses WKB for general geometry values. Its Vortex expression lowering converts supported WKB constants to native scalars and pushes `ST_Contains`, `ST_Within`, `ST_Distance`, and `ST_Intersects` into a Vortex scan. `ST_Within(a, b)` lowers to `ST_Contains(b, a)` and shares its compute and pruning implementation.

Some important limits:

Expand Down
2 changes: 2 additions & 0 deletions vortex-spatial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::extension::Point;
use crate::extension::Polygon;
use crate::extension::Rect;
use crate::extension::WellKnownBinary;
use crate::prune::SpatialContainsPrune;
use crate::prune::SpatialDistancePrune;
use crate::prune::SpatialIntersectsPrune;
use crate::scalar_fn::area::SpatialArea;
Expand Down Expand Up @@ -89,6 +90,7 @@ pub fn initialize(session: &VortexSession) {
session.aggregate_fns().register(GeometryAabb);

// Register the spatial pruning rules that use that AABB.
session.stats().register_rewrite(SpatialContainsPrune);
session.stats().register_rewrite(SpatialDistancePrune);
session.stats().register_rewrite(SpatialIntersectsPrune);

Expand Down
Loading
Loading