Skip to content

Commit 10b2695

Browse files
authored
chore: add a setting to disable runtime filter (#17869)
* add a setting to disable runtime filter * fix logic test * rename
1 parent c97c3c0 commit 10b2695

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

src/query/settings/src/settings_default.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,13 @@ impl DefaultSettings {
416416
range: Some(SettingRange::Numeric(0..=u64::MAX)),
417417
}),
418418
("enable_bloom_runtime_filter", DefaultSettingValue {
419+
value: UserSettingValue::UInt64(1),
420+
desc: "Enables bloom runtime filter optimization for JOIN.",
421+
mode: SettingMode::Both,
422+
scope: SettingScope::Both,
423+
range: Some(SettingRange::Numeric(0..=1)),
424+
}),
425+
("enable_join_runtime_filter", DefaultSettingValue {
419426
value: UserSettingValue::UInt64(1),
420427
desc: "Enables runtime filter optimization for JOIN.",
421428
mode: SettingMode::Both,

src/query/settings/src/settings_getter_setter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ impl Settings {
357357
Ok(self.try_get_u64("enable_bloom_runtime_filter")? != 0)
358358
}
359359

360+
pub fn get_enable_join_runtime_filter(&self) -> Result<bool> {
361+
Ok(self.try_get_u64("enable_join_runtime_filter")? != 0)
362+
}
363+
360364
pub fn get_prefer_broadcast_join(&self) -> Result<bool> {
361365
Ok(self.try_get_u64("prefer_broadcast_join")? != 0)
362366
}

src/query/sql/src/executor/physical_plans/physical_join_filter.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ impl JoinRuntimeFilter {
145145
build_keys: &[RemoteExpr],
146146
probe_keys: Vec<Option<(RemoteExpr<String>, usize, usize)>>,
147147
) -> Result<PhysicalRuntimeFilters> {
148+
// Early return if runtime filter is disabled in settings
149+
if !ctx.get_settings().get_enable_join_runtime_filter()? {
150+
return Ok(Default::default());
151+
}
152+
148153
// Early return if runtime filters are not supported for this join type
149154
if !Self::supported_join_type_for_runtime_filter(&join.join_type) {
150155
return Ok(Default::default());

tests/sqllogictests/suites/mode/standalone/explain/join_reorder/chain.test

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,64 @@ HashJoin
8484
├── apply join filters: [#1]
8585
└── estimated rows: 100.00
8686

87+
statement ok
88+
set enable_join_runtime_filter=0
89+
90+
query T
91+
explain select * from t, t1, t2 where t.a = t1.a and t1.a = t2.a
92+
----
93+
HashJoin
94+
├── output columns: [t2.a (#2), t1.a (#1), t.a (#0)]
95+
├── join type: INNER
96+
├── build keys: [t.a (#0)]
97+
├── probe keys: [t2.a (#2)]
98+
├── keys is null equal: [false]
99+
├── filters: []
100+
├── build join filters:
101+
├── estimated rows: 1.00
102+
├── HashJoin(Build)
103+
│ ├── output columns: [t1.a (#1), t.a (#0)]
104+
│ ├── join type: INNER
105+
│ ├── build keys: [t.a (#0)]
106+
│ ├── probe keys: [t1.a (#1)]
107+
│ ├── keys is null equal: [false]
108+
│ ├── filters: []
109+
│ ├── build join filters:
110+
│ ├── estimated rows: 1.00
111+
│ ├── TableScan(Build)
112+
│ │ ├── table: default.join_reorder.t
113+
│ │ ├── output columns: [a (#0)]
114+
│ │ ├── read rows: 1
115+
│ │ ├── read size: < 1 KiB
116+
│ │ ├── partitions total: 1
117+
│ │ ├── partitions scanned: 1
118+
│ │ ├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1>]
119+
│ │ ├── push downs: [filters: [], limit: NONE]
120+
│ │ └── estimated rows: 1.00
121+
│ └── TableScan(Probe)
122+
│ ├── table: default.join_reorder.t1
123+
│ ├── output columns: [a (#1)]
124+
│ ├── read rows: 10
125+
│ ├── read size: < 1 KiB
126+
│ ├── partitions total: 1
127+
│ ├── partitions scanned: 1
128+
│ ├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1>]
129+
│ ├── push downs: [filters: [], limit: NONE]
130+
│ └── estimated rows: 10.00
131+
└── TableScan(Probe)
132+
├── table: default.join_reorder.t2
133+
├── output columns: [a (#2)]
134+
├── read rows: 100
135+
├── read size: < 1 KiB
136+
├── partitions total: 1
137+
├── partitions scanned: 1
138+
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1>]
139+
├── push downs: [filters: [], limit: NONE]
140+
└── estimated rows: 100.00
141+
142+
statement ok
143+
set enable_join_runtime_filter=1
144+
87145
query T
88146
explain select * from t, t2, t1 where t.a = t1.a and t1.a = t2.a
89147
----

0 commit comments

Comments
 (0)