12
12
13
13
#include < memory>
14
14
15
+ #include " catalog/column_catalog.h"
15
16
#include " catalog/index_catalog.h"
16
17
#include " catalog/table_catalog.h"
17
- #include " catalog/column_catalog.h"
18
+ #include " optimizer/operators.h"
19
+ #include " optimizer/optimizer_metadata.h"
20
+ #include " optimizer/properties.h"
18
21
#include " optimizer/rule_impls.h"
19
22
#include " optimizer/util.h"
20
- #include " optimizer/operators.h"
21
23
#include " storage/data_table.h"
22
- #include " optimizer/properties.h"
23
- #include " optimizer/optimizer_metadata.h"
24
-
25
24
26
25
namespace peloton {
27
26
namespace optimizer {
@@ -86,7 +85,7 @@ InnerJoinAssociativity::InnerJoinAssociativity() {
86
85
match_pattern->AddChild (right_child);
87
86
}
88
87
89
- // TODO: As far as I know, theres nothing else that needs to be checked
88
+ // TODO: As far as I know, theres nothing else that needs to be checked
90
89
bool InnerJoinAssociativity::Check (std::shared_ptr<OperatorExpression> expr,
91
90
OptimizeContext *context) const {
92
91
(void )context;
@@ -98,10 +97,8 @@ void InnerJoinAssociativity::Transform(
98
97
std::shared_ptr<OperatorExpression> input,
99
98
std::vector<std::shared_ptr<OperatorExpression>> &transformed,
100
99
UNUSED_ATTRIBUTE OptimizeContext *context) const {
101
-
102
-
103
- // NOTE: Transforms (left JOIN middle) JOIN right -> left JOIN (middle JOIN right)
104
- // Variables are named accordingly to above transformation
100
+ // NOTE: Transforms (left JOIN middle) JOIN right -> left JOIN (middle JOIN
101
+ // right) Variables are named accordingly to above transformation
105
102
auto parent_join = input->Op ().As <LogicalInnerJoin>();
106
103
std::vector<std::shared_ptr<OperatorExpression>> children = input->Children ();
107
104
auto child_join = children[0 ]->Op ().As <LogicalInnerJoin>();
@@ -114,7 +111,8 @@ void InnerJoinAssociativity::Transform(
114
111
115
112
// Get Alias sets
116
113
auto &memo = context->metadata ->memo ;
117
- auto middle_group_id = children[0 ]->Children ()[1 ]->Op ().As <LeafOperator>()->origin_group ;
114
+ auto middle_group_id =
115
+ children[0 ]->Children ()[1 ]->Op ().As <LeafOperator>()->origin_group ;
118
116
auto right_group_id = children[1 ]->Op ().As <LeafOperator>()->origin_group ;
119
117
120
118
const auto &middle_group_aliases_set =
@@ -123,19 +121,23 @@ void InnerJoinAssociativity::Transform(
123
121
memo.GetGroupByID (right_group_id)->GetTableAliases ();
124
122
125
123
// Redistribute predicates
126
- auto parent_join_predicates = std::vector<AnnotatedExpression>(parent_join->join_predicates );
127
- auto child_join_predicates = std::vector<AnnotatedExpression>(child_join->join_predicates );
124
+ auto parent_join_predicates =
125
+ std::vector<AnnotatedExpression>(parent_join->join_predicates );
126
+ auto child_join_predicates =
127
+ std::vector<AnnotatedExpression>(child_join->join_predicates );
128
128
129
129
std::vector<AnnotatedExpression> predicates;
130
- predicates.insert (predicates.end (), parent_join_predicates.begin (), parent_join_predicates.end ());
131
- predicates.insert (predicates.end (), child_join_predicates.begin (), child_join_predicates.end ());
130
+ predicates.insert (predicates.end (), parent_join_predicates.begin (),
131
+ parent_join_predicates.end ());
132
+ predicates.insert (predicates.end (), child_join_predicates.begin (),
133
+ child_join_predicates.end ());
132
134
133
135
std::vector<AnnotatedExpression> new_child_join_predicates;
134
136
std::vector<AnnotatedExpression> new_parent_join_predicates;
135
137
136
- // TODO: This assumes that predicate pushdown has not occured yet, as it will put all non-join predicates into parent join
138
+ // TODO: This assumes that predicate pushdown has not occured yet, as it will
139
+ // put all non-join predicates into parent join
137
140
for (auto predicate : predicates) {
138
-
139
141
// New child join predicate must contain middle and right group
140
142
if (util::IsSubset (middle_group_aliases_set, predicate.table_alias_set ) &&
141
143
util::IsSubset (right_group_aliases_set, predicate.table_alias_set ))
@@ -158,13 +160,11 @@ void InnerJoinAssociativity::Transform(
158
160
new_parent_join->PushChild (left);
159
161
new_parent_join->PushChild (new_child_join);
160
162
161
-
162
- LOG_DEBUG (
163
- " Reordered join structured: (%s JOIN %s) JOIN %s" ,
164
- left->Op ().GetName ().c_str (), middle->Op ().GetName ().c_str (), right->Op ().GetName ().c_str ());
163
+ LOG_DEBUG (" Reordered join structured: (%s JOIN %s) JOIN %s" ,
164
+ left->Op ().GetName ().c_str (), middle->Op ().GetName ().c_str (),
165
+ right->Op ().GetName ().c_str ());
165
166
166
167
transformed.push_back (new_parent_join);
167
-
168
168
}
169
169
170
170
// ===--------------------------------------------------------------------===//
@@ -361,8 +361,8 @@ void GetToIndexScan::Transform(
361
361
LOG_TRACE (" Value Type: %d" ,
362
362
static_cast <int >(
363
363
reinterpret_cast <expression::ConstantValueExpression *>(
364
- expr->GetModifiableChild (1 ))
365
- ->GetValueType ()));
364
+ expr->GetModifiableChild (1 ))
365
+ ->GetValueType ()));
366
366
} else {
367
367
value_list.push_back (
368
368
type::ValueFactory::GetParameterOffsetValue (
0 commit comments