@@ -92,6 +92,66 @@ void ComputeJoinConditions(const TCoEquiJoinTuple& joinTuple,
92
92
}
93
93
}
94
94
95
+ bool IsLookupJoinApplicable (std::shared_ptr<IBaseOptimizerNode> left,
96
+ std::shared_ptr<IBaseOptimizerNode> right,
97
+ const std::set<std::pair<TJoinColumn, TJoinColumn>>& joinCondition) {
98
+
99
+
100
+ }
101
+
102
+ bool IsJoinApplicable (std::shared_ptr<IBaseOptimizerNode> left,
103
+ std::shared_ptr<IBaseOptimizerNode> right,
104
+ const std::set<std::pair<TJoinColumn, TJoinColumn>>& joinConditions,
105
+ EJoinImplType joinImpl) {
106
+
107
+ swtich (joinImpl) {
108
+ case EJoinImplType::LookupJoin:
109
+ return IsLookupJoinApplicable (left,right,joinConditions);
110
+ default :
111
+ return true ;
112
+ }
113
+ }
114
+
115
+ std::shared_ptr<TJoinOptimizerNode> PickBestJoin (std::shared_ptr<IBaseOptimizerNode> left,
116
+ std::shared_ptr<IBaseOptimizerNode> right,
117
+ const std::set<std::pair<TJoinColumn, TJoinColumn>>& leftJoinConditions,
118
+ const std::set<std::pair<TJoinColumn, TJoinColumn>>& rightJoinConditions,
119
+ const std::shared_ptr<TOptimizerStatistics> leftStats,
120
+ const std::shared_ptr<TOptimizerStatistics> rightStats) {
121
+
122
+ auto res = std::shared_ptr<TJoinOptimizerNode>();
123
+
124
+ for ( auto joinType : AllJoinTypes ) {
125
+ auto p1 = IsJoinApplicable (left, right, leftJoinConditions, joinType) ?
126
+ MakeJoin (left, right, leftJoinConditions, joinType ) :
127
+ std::shared_ptr<TJoinOptimizerNode>();
128
+ auto p2 = IsJoinApplicable (right, left, rightJoinConditions, joinType) ?
129
+ MakeJoin (right, left, rightJoinConditions, joinType ) :
130
+ std::shared_ptr<TJoinOptimizerNode>();
131
+
132
+ if (p1) {
133
+ if (res) {
134
+ if (p1->Cost < res->Cost ) {
135
+ res = p1;
136
+ }
137
+ } else {
138
+ res = p1;
139
+ }
140
+ }
141
+ if (p2) {
142
+ if (res) {
143
+ if (p2->Cost < res->Cost ) {
144
+ res = p2;
145
+ }
146
+ } else {
147
+ res = p2;
148
+ }
149
+ }
150
+ }
151
+
152
+ return res;
153
+ }
154
+
95
155
/* *
96
156
* Create a new join and compute its statistics and cost
97
157
*/
0 commit comments