@@ -36,7 +36,7 @@ TMaybeNode<TKqlKeyInc> GetRightTableKeyPrefix(const TKqlKeyRange& range) {
36
36
/* *
37
37
* KQP specific rule to check if a LookupJoin is applicable
38
38
*/
39
- bool IsLookupJoinApplicableDetailed (const std::shared_ptr<NYql::TRelOptimizerNode>& node, const TVector<TString >& joinColumns, const TKqpProviderContext& ctx) {
39
+ bool IsLookupJoinApplicableDetailed (const std::shared_ptr<NYql::TRelOptimizerNode>& node, const TVector<TJoinColumn >& joinColumns, const TKqpProviderContext& ctx) {
40
40
41
41
auto rel = std::static_pointer_cast<TKqpRelOptimizerNode>(node);
42
42
auto expr = TExprBase (rel->Node );
@@ -45,7 +45,7 @@ bool IsLookupJoinApplicableDetailed(const std::shared_ptr<NYql::TRelOptimizerNod
45
45
return false ;
46
46
}
47
47
48
- if (find_if (joinColumns.begin (), joinColumns.end (), [&] (const TString& s ) { return node->Stats ->KeyColumns ->Data [0 ] == s ;}) != joinColumns.end ()) {
48
+ if (std:: find_if (joinColumns.begin (), joinColumns.end (), [&] (const TJoinColumn& c ) { return node->Stats ->KeyColumns ->Data [0 ] == c. AttributeName ;}) != joinColumns.end ()) {
49
49
return true ;
50
50
}
51
51
@@ -97,8 +97,8 @@ bool IsLookupJoinApplicableDetailed(const std::shared_ptr<NYql::TRelOptimizerNod
97
97
return false ;
98
98
}
99
99
100
- if (prefixSize < node->Stats ->KeyColumns ->Data .size () && (find_if (joinColumns.begin (), joinColumns.end (), [&] (const TString& s ) {
101
- return node->Stats ->KeyColumns ->Data [prefixSize] == s ;
100
+ if (prefixSize < node->Stats ->KeyColumns ->Data .size () && (std:: find_if (joinColumns.begin (), joinColumns.end (), [&] (const TJoinColumn& c ) {
101
+ return node->Stats ->KeyColumns ->Data [prefixSize] == c. AttributeName ;
102
102
}) == joinColumns.end ())){
103
103
return false ;
104
104
}
@@ -108,12 +108,11 @@ bool IsLookupJoinApplicableDetailed(const std::shared_ptr<NYql::TRelOptimizerNod
108
108
109
109
bool IsLookupJoinApplicable (std::shared_ptr<IBaseOptimizerNode> left,
110
110
std::shared_ptr<IBaseOptimizerNode> right,
111
- const std::set<std::pair<TJoinColumn, TJoinColumn>>& joinConditions,
112
- const TVector<TString>& leftJoinKeys,
113
- const TVector<TString>& rightJoinKeys,
111
+ const TVector<TJoinColumn>& leftJoinKeys,
112
+ const TVector<TJoinColumn>& rightJoinKeys,
114
113
TKqpProviderContext& ctx
115
114
) {
116
- Y_UNUSED (left, joinConditions, leftJoinKeys);
115
+ Y_UNUSED (left, leftJoinKeys);
117
116
118
117
if (!(right->Stats ->StorageType == EStorageType::RowStorage)) {
119
118
return false ;
@@ -130,7 +129,7 @@ bool IsLookupJoinApplicable(std::shared_ptr<IBaseOptimizerNode> left,
130
129
}
131
130
132
131
for (auto rightCol : rightJoinKeys) {
133
- if (std:: find (rightStats->KeyColumns ->Data .begin (), rightStats->KeyColumns ->Data .end (), rightCol) == rightStats->KeyColumns ->Data .end ()) {
132
+ if (find (rightStats->KeyColumns ->Data .begin (), rightStats->KeyColumns ->Data .end (), rightCol. AttributeName ) == rightStats->KeyColumns ->Data .end ()) {
134
133
return false ;
135
134
}
136
135
}
@@ -142,18 +141,17 @@ bool IsLookupJoinApplicable(std::shared_ptr<IBaseOptimizerNode> left,
142
141
143
142
bool TKqpProviderContext::IsJoinApplicable (const std::shared_ptr<IBaseOptimizerNode>& left,
144
143
const std::shared_ptr<IBaseOptimizerNode>& right,
145
- const std::set<std::pair<NDq::TJoinColumn, NDq::TJoinColumn>>& joinConditions,
146
- const TVector<TString>& leftJoinKeys,
147
- const TVector<TString>& rightJoinKeys,
144
+ const TVector<TJoinColumn>& leftJoinKeys,
145
+ const TVector<TJoinColumn>& rightJoinKeys,
148
146
EJoinAlgoType joinAlgo,
149
- EJoinKind joinKind) {
147
+ EJoinKind joinKind) {
150
148
151
149
switch ( joinAlgo ) {
152
150
case EJoinAlgoType::LookupJoin:
153
151
if ((OptLevel != 3 ) && (left->Stats ->Nrows > 1000 )) {
154
152
return false ;
155
153
}
156
- return IsLookupJoinApplicable (left, right, joinConditions, leftJoinKeys, rightJoinKeys, *this );
154
+ return IsLookupJoinApplicable (left, right, leftJoinKeys, rightJoinKeys, *this );
157
155
158
156
case EJoinAlgoType::LookupJoinReverse:
159
157
if (joinKind != EJoinKind::LeftSemi) {
@@ -162,7 +160,7 @@ bool TKqpProviderContext::IsJoinApplicable(const std::shared_ptr<IBaseOptimizerN
162
160
if ((OptLevel != 3 ) && (right->Stats ->Nrows > 1000 )) {
163
161
return false ;
164
162
}
165
- return IsLookupJoinApplicable (right, left, joinConditions, rightJoinKeys, leftJoinKeys, *this );
163
+ return IsLookupJoinApplicable (right, left, rightJoinKeys, leftJoinKeys, *this );
166
164
167
165
case EJoinAlgoType::MapJoin:
168
166
return joinKind != EJoinKind::OuterJoin && joinKind != EJoinKind::Exclusion && right->Stats ->ByteSize < 1e6 ;
0 commit comments