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::{HashExpr, HashJoinExec, HashTableLookupExpr, SeededRandomState};
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;
40/// Hash map implementations for join operations.
41///
42/// Note: This module is public for internal testing purposes only
43/// and is not guaranteed to be stable across versions.
44pub mod join_hash_map;
45
46#[cfg(test)]
47pub mod test_utils;
48
49/// The on clause of the join, as vector of (left, right) columns.
50pub type JoinOn = Vec<(PhysicalExprRef, PhysicalExprRef)>;
51/// Reference for JoinOn.
52pub type JoinOnRef<'a> = &'a [(PhysicalExprRef, PhysicalExprRef)];
53
54#[derive(Clone, Copy, Debug, PartialEq, Eq)]
55/// Hash join Partitioning mode
56pub enum PartitionMode {
57 /// Left/right children are partitioned using the left and right keys
58 Partitioned,
59 /// Left side will collected into one partition
60 CollectLeft,
61 /// DataFusion optimizer decides which PartitionMode
62 /// mode(Partitioned/CollectLeft) is optimal based on statistics. It will
63 /// also consider swapping the left and right inputs for the Join
64 Auto,
65}
66
67/// Partitioning mode to use for symmetric hash join
68#[derive(Hash, Clone, Copy, Debug, PartialEq, Eq)]
69pub enum StreamJoinPartitionMode {
70 /// Left/right children are partitioned using the left and right keys
71 Partitioned,
72 /// Both sides will collected into one partition
73 SinglePartition,
74}
75
76/// Shared bitmap for visited left-side indices
77type SharedBitmapBuilder = Mutex<BooleanBufferBuilder>;