Skip to content

Commit

Permalink
sample is it's own relation in the join order optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tmonster committed Nov 25, 2024
1 parent 6d725cf commit a25aa83
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/optimizer/join_order/relation_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ static bool OperatorNeedsRelation(LogicalOperatorType op_type) {
case LogicalOperatorType::LOGICAL_DELIM_GET:
case LogicalOperatorType::LOGICAL_AGGREGATE_AND_GROUP_BY:
case LogicalOperatorType::LOGICAL_WINDOW:
case LogicalOperatorType::LOGICAL_SAMPLE:
return true;
default:
return false;
Expand Down
30 changes: 30 additions & 0 deletions test/sql/optimizer/InFilter.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# name: test/sql/optimizer/InFilter.test
# description: Test sampling of larger relations
# group: [sample]

#statement ok
#PRAGMA enable_verification;

statement ok
CREATE TABLE t1 (s UUID, i VARCHAR);

statement ok
INSERT INTO t1 VALUES
('619d9199-bc25-41d7-803e-1fa801b4b952'::UUID, NULL),
('1ada8361-c20b-4e9f-9c8e-15689039cc75'::UUID, '91'),
('f5a8a7d8-6bc5-4337-a296-d52078156051'::UUID, NULL);

statement ok
CREATE TABLE t2 (v VARCHAR);

statement ok
INSERT INTO t2 VALUES
('Int',),
('91',),
('13',),
('sst',);

statement ok
SELECT t1.s
FROM t1
LEFT JOIN t2 ON t1.i = t2.v;
18 changes: 18 additions & 0 deletions test/sql/optimizer/tests_no_pushdown_under_samples.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# name: test/sql/optimizer/tests_no_pushdown_under_samples.test
# group: [optimizer]

statement ok
CREATE OR REPLACE TABLE df AS (SELECT * AS i FROM range(10));

statement ok
CREATE OR REPLACE TABLE wtf AS (SELECT 1 AS i);

query II
explain FROM
df, wtf
SELECT
df.i
WHERE df.i > 8
USING SAMPLE 1;
----
physical_plan <REGEX>:.*FILTER.*RESERVOIR_SAMPLE.*

0 comments on commit a25aa83

Please sign in to comment.