15
15
* limitations under the License.
16
16
*/
17
17
#include " ExpandRelParser.h"
18
- # include < ratio >
18
+
19
19
#include < vector>
20
+ #include < Columns/ColumnAggregateFunction.h>
20
21
#include < Core/Block.h>
21
22
#include < Core/ColumnWithTypeAndName.h>
22
23
#include < Operator/AdvancedExpandStep.h>
@@ -41,9 +42,7 @@ ExpandRelParser::ExpandRelParser(ParserContextPtr parser_context_) : RelParser(p
41
42
void updateType (DB::DataTypePtr & type, const DB::DataTypePtr & new_type)
42
43
{
43
44
if (type == nullptr || (!type->isNullable () && new_type->isNullable ()))
44
- {
45
45
type = new_type;
46
- }
47
46
}
48
47
49
48
DB::QueryPlanPtr
@@ -91,7 +90,8 @@ ExpandField ExpandRelParser::buildExpandField(const DB::Block & header, const su
91
90
fields.push_back (field);
92
91
if (field >= header.columns ())
93
92
{
94
- throw DB::Exception (DB::ErrorCodes::LOGICAL_ERROR, " Field index out of range: {}, header: {}" , field, header.dumpStructure ());
93
+ throw DB::Exception (
94
+ DB::ErrorCodes::LOGICAL_ERROR, " Field index out of range: {}, header: {}" , field, header.dumpStructure ());
95
95
}
96
96
updateType (types[i], header.getByPosition (field).type );
97
97
const auto & name = header.getByPosition (field).name ;
@@ -128,10 +128,8 @@ ExpandField ExpandRelParser::buildExpandField(const DB::Block & header, const su
128
128
}
129
129
130
130
for (int i = 0 ; i < names.size (); ++i)
131
- {
132
131
if (names[i].empty ())
133
132
names[i] = getUniqueName (" expand_" + std::to_string (i));
134
- }
135
133
136
134
ExpandField expand_field (names, types, expand_kinds, expand_fields);
137
135
return expand_field;
@@ -144,10 +142,8 @@ bool ExpandRelParser::isLazyAggregateExpand(const substrait::ExpandRel & expand_
144
142
return false ;
145
143
const auto & aggregate_rel = input_rel.aggregate ();
146
144
for (const auto & measure : aggregate_rel.measures ())
147
- {
148
145
if (measure.measure ().phase () != substrait::AggregationPhase::AGGREGATION_PHASE_INITIAL_TO_INTERMEDIATE)
149
146
return false ;
150
- }
151
147
return true ;
152
148
}
153
149
@@ -172,7 +168,7 @@ DB::QueryPlanPtr ExpandRelParser::lazyAggregateExpandParse(
172
168
auto aggregate_rel = rel.expand ().input ().aggregate ();
173
169
auto aggregate_descriptions = buildAggregations (input_header, expand_field, aggregate_rel);
174
170
175
- size_t grouping_keys = aggregate_rel.groupings (0 ).grouping_expressions_size ();
171
+ size_t grouping_keys = aggregate_rel.groupings (0 ).grouping_expressions_size ();
176
172
177
173
auto expand_step
178
174
= std::make_unique<AdvancedExpandStep>(getContext (), input_header, grouping_keys, aggregate_descriptions, expand_field);
@@ -189,10 +185,8 @@ DB::AggregateDescriptions ExpandRelParser::buildAggregations(
189
185
DB::AggregateDescriptions descriptions;
190
186
DB::ColumnsWithTypeAndName aggregate_columns;
191
187
for (const auto & col : header.getColumnsWithTypeAndName ())
192
- {
193
188
if (typeid_cast<const DB::ColumnAggregateFunction *>(col.column .get ()))
194
189
aggregate_columns.push_back (col);
195
- }
196
190
197
191
for (size_t i = 0 ; i < aggregate_rel.measures_size (); ++i)
198
192
{
0 commit comments