datafusion_physical_plan/joins/piecewise_merge_join/utils.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
18use datafusion_expr::JoinType;
19
20// Returns boolean for whether the join is a right existence join
21pub(super) fn is_right_existence_join(join_type: JoinType) -> bool {
22 matches!(
23 join_type,
24 JoinType::RightAnti | JoinType::RightSemi | JoinType::RightMark
25 )
26}
27
28// Returns boolean for whether the join is an existence join
29pub(super) fn is_existence_join(join_type: JoinType) -> bool {
30 matches!(
31 join_type,
32 JoinType::LeftAnti
33 | JoinType::RightAnti
34 | JoinType::LeftSemi
35 | JoinType::RightSemi
36 | JoinType::LeftMark
37 | JoinType::RightMark
38 )
39}
40
41// Returns boolean to check if the join type needs to record
42// buffered side matches for classic joins
43pub(super) fn need_produce_result_in_final(join_type: JoinType) -> bool {
44 matches!(join_type, JoinType::Full | JoinType::Left)
45}
46
47// Returns boolean for whether or not we need to build the buffered side
48// bitmap for marking matched rows on the buffered side.
49pub(super) fn build_visited_indices_map(join_type: JoinType) -> bool {
50 matches!(
51 join_type,
52 JoinType::Full
53 | JoinType::Left
54 | JoinType::LeftAnti
55 | JoinType::RightAnti
56 | JoinType::LeftSemi
57 | JoinType::RightSemi
58 | JoinType::LeftMark
59 | JoinType::RightMark
60 )
61}