-
Notifications
You must be signed in to change notification settings - Fork 414
Expand file tree
/
Copy pathJoinBinder.h
More file actions
117 lines (105 loc) · 4.25 KB
/
JoinBinder.h
File metadata and controls
117 lines (105 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2023 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <Debug/MockExecutor/ExecutorBinder.h>
#include <Debug/MockRuntimeFilter.h>
namespace DB::mock
{
class ExchangeSenderBinder;
class ExchangeReceiverBinder;
class JoinBinder : public ExecutorBinder
{
public:
JoinBinder(
size_t & index_,
const DAGSchema & output_schema_,
tipb::JoinType tp_,
const ASTs & join_cols_,
const std::vector<UInt8> & is_null_eq_,
const ASTs & l_conds,
const ASTs & r_conds,
const ASTs & o_conds,
const ASTs & o_eq_conds,
uint64_t fine_grained_shuffle_stream_count_,
bool is_null_aware_semi_join,
int64_t inner_index_ = 1)
: ExecutorBinder(index_, "Join_" + std::to_string(index_), output_schema_)
, tp(tp_)
, join_cols(join_cols_)
, is_null_eq(is_null_eq_)
, left_conds(l_conds)
, right_conds(r_conds)
, other_conds(o_conds)
, other_eq_conds_from_in(o_eq_conds)
, fine_grained_shuffle_stream_count(fine_grained_shuffle_stream_count_)
, is_null_aware_semi_join(is_null_aware_semi_join)
, inner_index(inner_index_)
{}
void addRuntimeFilter(MockRuntimeFilter & rf);
void columnPrune(std::unordered_set<String> & used_columns) override;
static void fillJoinKeyAndFieldType(
ASTPtr key,
const DAGSchema & schema,
tipb::Expr * tipb_key,
tipb::FieldType * tipb_field_type,
int32_t collator_id);
bool toTiPBExecutor(
tipb::Executor * tipb_executor,
int32_t collator_id,
const MPPInfo & mpp_info,
const Context & context) override;
void toMPPSubPlan(
size_t & executor_index,
const DAGProperties & properties,
std::unordered_map<
String,
std::pair<std::shared_ptr<ExchangeReceiverBinder>, std::shared_ptr<ExchangeSenderBinder>>> & exchange_map)
override;
protected:
tipb::JoinType tp;
const ASTs join_cols{};
const std::vector<UInt8> is_null_eq{};
const ASTs left_conds{};
const ASTs right_conds{};
const ASTs other_conds{};
const ASTs other_eq_conds_from_in{};
uint64_t fine_grained_shuffle_stream_count;
bool is_null_aware_semi_join;
int64_t inner_index;
std::vector<std::shared_ptr<MockRuntimeFilter>> rf_list;
};
// compileJoin constructs a mocked Join executor node, note that all conditional expression params can be default
ExecutorBinderPtr compileJoin(
size_t & executor_index,
ExecutorBinderPtr left,
ExecutorBinderPtr right,
tipb::JoinType tp,
const ASTs & join_cols,
const std::vector<UInt8> & is_null_eq = {},
const ASTs & left_conds = {},
const ASTs & right_conds = {},
const ASTs & other_conds = {},
const ASTs & other_eq_conds_from_in = {},
uint64_t fine_grained_shuffle_stream_count = 0,
bool is_null_aware_semi_join = false,
int64_t inner_index = 1);
/// Note: this api is only used by legacy test framework for compatibility purpose, which will be depracated soon,
/// so please avoid using it.
/// Old executor test framework bases on ch's parser to translate sql string to ast tree, then manually to DAGRequest.
/// However, as for join executor, this translation, from ASTTableJoin to tipb::Join, is not a one-to-one mapping
/// because of the different join classification model used by these two structures. Therefore, under old test framework,
/// it is hard to fully test join executor. New framework aims to directly construct DAGRequest, so new framework APIs for join should
/// avoid using ASTTableJoin.
ExecutorBinderPtr compileJoin(size_t & executor_index, ExecutorBinderPtr left, ExecutorBinderPtr right, ASTPtr params);
} // namespace DB::mock