Skip to content

Commit 098070f

Browse files
committed
refactor: remove semi/anti join support in favor of apply-based subqueries
1 parent cb09bad commit 098070f

File tree

12 files changed

+24
-539
lines changed

12 files changed

+24
-539
lines changed

src/binder/select.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,14 +1253,12 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
12531253
(JoinType::RightOuter, Some(constraint))
12541254
}
12551255
JoinOperator::FullOuter(constraint) => (JoinType::Full, Some(constraint)),
1256-
JoinOperator::Semi(constraint) | JoinOperator::LeftSemi(constraint) => {
1257-
(JoinType::LeftSemi, Some(constraint))
1258-
}
1259-
JoinOperator::Anti(constraint) | JoinOperator::LeftAnti(constraint) => {
1260-
(JoinType::LeftAnti, Some(constraint))
1261-
}
12621256
JoinOperator::CrossJoin(constraint) => (JoinType::Cross, Some(constraint)),
1263-
JoinOperator::RightSemi(_)
1257+
JoinOperator::Semi(_)
1258+
| JoinOperator::LeftSemi(_)
1259+
| JoinOperator::Anti(_)
1260+
| JoinOperator::LeftAnti(_)
1261+
| JoinOperator::RightSemi(_)
12641262
| JoinOperator::RightAnti(_)
12651263
| JoinOperator::CrossApply
12661264
| JoinOperator::OuterApply

src/execution/dql/join/hash/left_anti_join.rs

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/execution/dql/join/hash/left_semi_join.rs

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/execution/dql/join/hash/mod.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@
1414

1515
pub(crate) mod full_join;
1616
pub(crate) mod inner_join;
17-
pub(crate) mod left_anti_join;
1817
pub(crate) mod left_join;
19-
pub(crate) mod left_semi_join;
2018
pub(crate) mod right_join;
2119

2220
use crate::errors::DatabaseError;
2321
use crate::execution::dql::join::hash::full_join::FullJoinState;
2422
use crate::execution::dql::join::hash::inner_join::InnerJoinState;
25-
use crate::execution::dql::join::hash::left_anti_join::LeftAntiJoinState;
2623
use crate::execution::dql::join::hash::left_join::LeftJoinState;
27-
use crate::execution::dql::join::hash::left_semi_join::LeftSemiJoinState;
2824
use crate::execution::dql::join::hash::right_join::RightJoinState;
2925
use crate::execution::dql::join::hash_join::BuildState;
3026
use crate::execution::dql::sort::BumpVec;
@@ -80,8 +76,6 @@ pub(crate) enum JoinProbeStateImpl {
8076
Left(LeftJoinState),
8177
Right(RightJoinState),
8278
Full(FullJoinState),
83-
LeftSemi(LeftSemiJoinState),
84-
LeftAnti(LeftAntiJoinState),
8579
}
8680

8781
impl JoinProbeState for JoinProbeStateImpl {
@@ -104,12 +98,6 @@ impl JoinProbeState for JoinProbeStateImpl {
10498
JoinProbeStateImpl::Full(state) => {
10599
state.probe_next(probe_state, build_state, filter_args)
106100
}
107-
JoinProbeStateImpl::LeftSemi(state) => {
108-
state.probe_next(probe_state, build_state, filter_args)
109-
}
110-
JoinProbeStateImpl::LeftAnti(state) => {
111-
state.probe_next(probe_state, build_state, filter_args)
112-
}
113101
}
114102
}
115103

@@ -123,12 +111,6 @@ impl JoinProbeState for JoinProbeStateImpl {
123111
JoinProbeStateImpl::Left(state) => state.left_drop_next(left_drop_state, filter_args),
124112
JoinProbeStateImpl::Right(state) => state.left_drop_next(left_drop_state, filter_args),
125113
JoinProbeStateImpl::Full(state) => state.left_drop_next(left_drop_state, filter_args),
126-
JoinProbeStateImpl::LeftSemi(state) => {
127-
state.left_drop_next(left_drop_state, filter_args)
128-
}
129-
JoinProbeStateImpl::LeftAnti(state) => {
130-
state.left_drop_next(left_drop_state, filter_args)
131-
}
132114
}
133115
}
134116
}

src/execution/dql/join/hash_join.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ use crate::catalog::ColumnRef;
1616
use crate::errors::DatabaseError;
1717
use crate::execution::dql::join::hash::full_join::FullJoinState;
1818
use crate::execution::dql::join::hash::inner_join::InnerJoinState;
19-
use crate::execution::dql::join::hash::left_anti_join::LeftAntiJoinState;
2019
use crate::execution::dql::join::hash::left_join::LeftJoinState;
21-
use crate::execution::dql::join::hash::left_semi_join::LeftSemiJoinState;
2220
use crate::execution::dql::join::hash::right_join::RightJoinState;
2321
use crate::execution::dql::join::hash::{
2422
FilterArgs, JoinProbeState, JoinProbeStateImpl, LeftDropState, ProbeState,
@@ -241,15 +239,6 @@ impl HashJoin {
241239
right_schema_len,
242240
bits: FixedBitSet::with_capacity(build_count),
243241
}),
244-
JoinType::LeftSemi => JoinProbeStateImpl::LeftSemi(LeftSemiJoinState {
245-
bits: FixedBitSet::with_capacity(build_count),
246-
}),
247-
JoinType::LeftAnti => JoinProbeStateImpl::LeftAnti(LeftAntiJoinState {
248-
right_schema_len,
249-
inner: LeftSemiJoinState {
250-
bits: FixedBitSet::with_capacity(build_count),
251-
},
252-
}),
253242
JoinType::RightOuter => JoinProbeStateImpl::Right(RightJoinState { left_schema_len }),
254243
JoinType::Full => JoinProbeStateImpl::Full(FullJoinState {
255244
left_schema_len,
@@ -433,12 +422,10 @@ mod test {
433422
use crate::planner::operator::Operator;
434423
use crate::planner::{Childrens, LogicalPlan};
435424
use crate::storage::rocksdb::{RocksStorage, RocksTransaction};
436-
use crate::storage::table_codec::BumpBytes;
437425
use crate::storage::Storage;
438426
use crate::types::value::DataValue;
439427
use crate::types::LogicalType;
440428
use crate::utils::lru::SharedLruCache;
441-
use bumpalo::Bump;
442429
use std::hash::RandomState;
443430
use std::sync::Arc;
444431
use tempfile::TempDir;
@@ -649,47 +636,6 @@ mod test {
649636
build_integers(vec![Some(3), Some(5), Some(7), None, None, None])
650637
);
651638
}
652-
{
653-
let mut executor = HashJoin::from((op.clone(), left.clone(), right.clone()));
654-
executor.ty = JoinType::LeftSemi;
655-
let mut tuples = try_collect(crate::execution::execute(
656-
executor,
657-
(&table_cache, &view_cache, &meta_cache),
658-
&mut transaction,
659-
))?;
660-
661-
let arena = Bump::new();
662-
assert_eq!(tuples.len(), 2);
663-
tuples.sort_by_key(|tuple| {
664-
let mut bytes = BumpBytes::new_in(&arena);
665-
tuple.values[0].memcomparable_encode(&mut bytes).unwrap();
666-
bytes
667-
});
668-
669-
assert_eq!(
670-
tuples[0].values,
671-
build_integers(vec![Some(0), Some(2), Some(4)])
672-
);
673-
assert_eq!(
674-
tuples[1].values,
675-
build_integers(vec![Some(1), Some(3), Some(5)])
676-
);
677-
}
678-
{
679-
let mut executor = HashJoin::from((op, left, right));
680-
executor.ty = JoinType::LeftAnti;
681-
let tuples = try_collect(crate::execution::execute(
682-
executor,
683-
(&table_cache, &view_cache, &meta_cache),
684-
&mut transaction,
685-
))?;
686-
687-
assert_eq!(tuples.len(), 1);
688-
assert_eq!(
689-
tuples[0].values,
690-
build_integers(vec![Some(3), Some(5), Some(7)])
691-
);
692-
}
693639

694640
Ok(())
695641
}

src/execution/dql/join/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) mod nested_loop_join;
2121
pub fn joins_nullable(join_type: &JoinType) -> (bool, bool) {
2222
match join_type {
2323
JoinType::Inner => (false, false),
24-
JoinType::LeftOuter | JoinType::LeftSemi | JoinType::LeftAnti => (false, true),
24+
JoinType::LeftOuter => (false, true),
2525
JoinType::RightOuter => (true, false),
2626
JoinType::Full => (true, true),
2727
JoinType::Cross => (true, true),

0 commit comments

Comments
 (0)