MCPcopy Create free account
hub / github.com/ByConity/ByConity / executeImpl

Method executeImpl

src/Interpreters/InterpreterSelectQuery.cpp:1185–1698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1183
1184
1185void InterpreterSelectQuery::executeImpl(QueryPlan & query_plan, const BlockInputStreamPtr & prepared_input, std::optional<Pipe> prepared_pipe)
1186{
1187 /** Streams of data. When the query is executed in parallel, we have several data streams.
1188 * If there is no GROUP BY, then perform all operations before ORDER BY and LIMIT in parallel, then
1189 * if there is an ORDER BY, then glue the streams using ResizeProcessor, and then MergeSorting transforms,
1190 * if not, then glue it using ResizeProcessor,
1191 * then apply LIMIT.
1192 * If there is GROUP BY, then we will perform all operations up to GROUP BY, inclusive, in parallel;
1193 * a parallel GROUP BY will glue streams into one,
1194 * then perform the remaining operations with one resulting stream.
1195 */
1196
1197 /// Now we will compose block streams that perform the necessary actions.
1198 auto & query = getSelectQuery();
1199
1200 const Settings & settings = context->getSettingsRef();
1201 auto & expressions = analysis_result;
1202 auto & subqueries_for_sets = query_analyzer->getSubqueriesForSets();
1203 bool intermediate_stage = false;
1204 bool to_aggregation_stage = false;
1205 bool from_aggregation_stage = false;
1206
1207 /// Do I need to aggregate in a separate row rows that have not passed max_rows_to_group_by.
1208 bool aggregate_overflow_row =
1209 expressions.need_aggregate &&
1210 query.group_by_with_totals &&
1211 settings.max_rows_to_group_by &&
1212 settings.group_by_overflow_mode == OverflowMode::ANY &&
1213 settings.totals_mode != TotalsMode::AFTER_HAVING_EXCLUSIVE;
1214
1215 /// Do I need to immediately finalize the aggregate functions after the aggregation?
1216 bool aggregate_final =
1217 expressions.need_aggregate &&
1218 options.to_stage > QueryProcessingStage::WithMergeableState &&
1219 !query.group_by_with_totals && !query.group_by_with_rollup && !query.group_by_with_cube;
1220
1221 bool use_grouping_set_key = expressions.use_grouping_set_key;
1222
1223 if (query.group_by_with_grouping_sets && query.group_by_with_totals)
1224 throw Exception("WITH TOTALS and GROUPING SETS are not supported together", ErrorCodes::NOT_IMPLEMENTED);
1225
1226 if (query_info.projection && query_info.projection->desc->type == ProjectionDescription::Type::Aggregate)
1227 {
1228 query_info.projection->aggregate_overflow_row = aggregate_overflow_row;
1229 query_info.projection->aggregate_final = aggregate_final;
1230 }
1231
1232 if (options.only_analyze)
1233 {
1234 auto read_nothing = std::make_unique<ReadNothingStep>(source_header);
1235 query_plan.addStep(std::move(read_nothing));
1236
1237 if (expressions.filter_info)
1238 {
1239 auto row_level_security_step = std::make_unique<FilterStep>(
1240 query_plan.getCurrentDataStream(),
1241 expressions.filter_info->actions,
1242 expressions.filter_info->column_name,

Callers

nothing calls this directly

Calls 15

setStepDescriptionMethod · 0.80
hasHavingMethod · 0.80
hasLimitByMethod · 0.80
getJoinedPlanMethod · 0.80
unitePlansMethod · 0.80
hasWindowMethod · 0.80
hasGlobalSubqueriesMethod · 0.80
ExceptionClass · 0.70
toStringFunction · 0.70
QueryPlanClass · 0.70
getSortDescriptionFunction · 0.70

Tested by

no test coverage detected