datafusion_physical_plan/joins/mod.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! DataFusion Join implementations
19
20use arrow::array::BooleanBufferBuilder;
21pub use cross_join::CrossJoinExec;
22use datafusion_physical_expr::PhysicalExprRef;
23pub use hash_join::HashJoinExec;
24pub use nested_loop_join::NestedLoopJoinExec;
25use parking_lot::Mutex;
26// Note: SortMergeJoin is not used in plans yet
27pub use piecewise_merge_join::PiecewiseMergeJoinExec;
28pub use sort_merge_join::SortMergeJoinExec;
29pub use symmetric_hash_join::SymmetricHashJoinExec;
30mod cross_join;
31mod hash_join;
32mod nested_loop_join;
33mod piecewise_merge_join;
34mod sort_merge_join;
35mod stream_join_utils;
36mod symmetric_hash_join;
37pub mod utils;
38
39mod join_filter;
40mod join_hash_map;
41
42#[cfg(test)]
43pub mod test_utils;
44
45/// The on clause of the join, as vector of (left, right) columns.
46pub type JoinOn = Vec<(PhysicalExprRef, PhysicalExprRef)>;
47/// Reference for JoinOn.
48pub type JoinOnRef<'a> = &'a [(PhysicalExprRef, PhysicalExprRef)];
49
50#[derive(Clone, Copy, Debug, PartialEq, Eq)]
51/// Hash join Partitioning mode
52pub enum PartitionMode {
53 /// Left/right children are partitioned using the left and right keys
54 Partitioned,
55 /// Left side will collected into one partition
56 CollectLeft,
57 /// DataFusion optimizer decides which PartitionMode
58 /// mode(Partitioned/CollectLeft) is optimal based on statistics. It will
59 /// also consider swapping the left and right inputs for the Join
60 Auto,
61}
62
63/// Partitioning mode to use for symmetric hash join
64#[derive(Hash, Clone, Copy, Debug, PartialEq, Eq)]
65pub enum StreamJoinPartitionMode {
66 /// Left/right children are partitioned using the left and right keys
67 Partitioned,
68 /// Both sides will collected into one partition
69 SinglePartition,
70}
71
72/// Shared bitmap for visited left-side indices
73type SharedBitmapBuilder = Mutex<BooleanBufferBuilder>;