Skip to content

replace filter projection map after filter pullup #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
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
8 changes: 8 additions & 0 deletions src/spatial/index/rtree/rtree_index_plan_scan.cpp
Original file line number Diff line number Diff line change
@@ -200,6 +200,14 @@ class RTreeIndexScanOptimizer : public OptimizerExtension {
if (get.table_filters.filters.empty()) {
return true;
}

// Before we clear projection ids, replace projection map in the filter
if (!get.projection_ids.empty()) {
for (auto &id : filter.projection_map) {
id = get.projection_ids[id];
}
}

get.projection_ids.clear();
get.types.clear();

17 changes: 17 additions & 0 deletions test/sql/index/rtree_filter_pullup_2.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require spatial

# This test only really works on release builds, where the column lifetime optimizers
# doesnt pollute the plan (but still applies)

statement ok
CREATE TABLE t1 AS
SELECT st_point(i, j) as pt, row_number() over () as i, row_number () over () as j
FROM range(0, 3) as r(i), range(0, 3) as rr(j);

statement ok
CREATE INDEX my_idx ON t1 USING RTREE (pt);

query I rowsort
SELECT i FROM t1 WHERE j = 5 AND ST_Contains(ST_GeomFromText('POLYGON((0 0, 0 50, 50 50, 50 0, 0 0))'), pt);
----
5

Unchanged files with check annotations Beta