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 sort_merge_join::SortMergeJoinExec;
28pub use symmetric_hash_join::SymmetricHashJoinExec;
29mod cross_join;
30mod hash_join;
31mod nested_loop_join;
32mod sort_merge_join;
33mod stream_join_utils;
34mod symmetric_hash_join;
35pub mod utils;
36
37mod join_filter;
38mod join_hash_map;
39
40#[cfg(test)]
41pub mod test_utils;
42
43/// The on clause of the join, as vector of (left, right) columns.
44pub type JoinOn = Vec<(PhysicalExprRef, PhysicalExprRef)>;
45/// Reference for JoinOn.
46pub type JoinOnRef<'a> = &'a [(PhysicalExprRef, PhysicalExprRef)];
47
48#[derive(Clone, Copy, Debug, PartialEq, Eq)]
49/// Hash join Partitioning mode
50pub enum PartitionMode {
51    /// Left/right children are partitioned using the left and right keys
52    Partitioned,
53    /// Left side will collected into one partition
54    CollectLeft,
55    /// DataFusion optimizer decides which PartitionMode
56    /// mode(Partitioned/CollectLeft) is optimal based on statistics. It will
57    /// also consider swapping the left and right inputs for the Join
58    Auto,
59}
60
61/// Partitioning mode to use for symmetric hash join
62#[derive(Hash, Clone, Copy, Debug, PartialEq, Eq)]
63pub enum StreamJoinPartitionMode {
64    /// Left/right children are partitioned using the left and right keys
65    Partitioned,
66    /// Both sides will collected into one partition
67    SinglePartition,
68}
69
70/// Shared bitmap for visited left-side indices
71type SharedBitmapBuilder = Mutex<BooleanBufferBuilder>;