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

Method TableScanExecutor

src/QueryPlan/TableScanStep.cpp:272–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270};
271
272TableScanExecutor::TableScanExecutor(TableScanStep & step, const MergeTreeMetaBase & storage_, ContextPtr context_)
273 : storage(storage_)
274 , storage_metadata(storage.getInMemoryMetadataPtr())
275 , merge_tree_reader(storage)
276 , select_query_info(step.getQueryInfo())
277 , context(std::move(context_))
278 , log(&Poco::Logger::get("TableScanExecutor"))
279{
280 if (storage_metadata->projections.empty())
281 return;
282
283 if (step.hasInlineExpressions())
284 return;
285
286 has_aggregate = step.getPushdownAggregation() != nullptr;
287 query_required_columns = step.getRequiredColumns(TableScanStep::OutputAndPrewhere);
288 query_lineage = [&]() {
289 PlanNodePtr node;
290 QueryPlanStepPtr table_scan_without_pushdown_steps = std::make_shared<TableScanStep>(
291 context,
292 step.getStorageID(),
293 step.getColumnAlias(),
294 step.getQueryInfo(),
295 step.getMaxBlockSize());
296 node = PlanNodeBase::createPlanNode(NODE_ID_TABLE_SCAN, table_scan_without_pushdown_steps);
297
298 if (const auto & filter = step.getPushdownFilter())
299 node = PlanNodeBase::createPlanNode(NODE_ID_FILTER, filter, {node});
300
301 if (const auto & projection = step.getPushdownProjection())
302 node = PlanNodeBase::createPlanNode(NODE_ID_PROJECTION, projection, {node});
303
304 if (const auto & aggregation = step.getPushdownAggregation())
305 node = PlanNodeBase::createPlanNode(NODE_ID_AGGREGATION, aggregation, {node});
306
307 return SymbolTransformMap::buildFrom(*node);
308 }();
309
310 if (!query_lineage)
311 return;
312
313 if (has_aggregate)
314 {
315 const auto * query_aggregate = step.getPushdownAggregationCast();
316 column_types_before_agg = query_aggregate->getInputStreams()[0].header.getNamesToTypes();
317
318 for (const auto & origin_grouping_key: query_aggregate->getKeys())
319 aggregate_keys.emplace_back(NameWithAST{origin_grouping_key, query_lineage->inlineReferences(origin_grouping_key)});
320
321 for (const auto & query_aggregate_desc: query_aggregate->getAggregates())
322 aggregate_descs.emplace_back(NameWithAST{query_aggregate_desc.column_name,
323 query_lineage->inlineReferences(query_aggregate_desc.column_name)});
324 }
325
326 if (const auto * query_filter_step = step.getPushdownFilterCast())
327 {
328 const auto & query_filter = query_filter_step->getFilter();
329 flatten_filter = query_lineage->inlineReferences(query_filter);

Callers

nothing calls this directly

Calls 15

getQueryInfoMethod · 0.80
hasInlineExpressionsMethod · 0.80
getPushdownFilterMethod · 0.80
getPushdownProjectionMethod · 0.80
getPushdownFilterCastMethod · 0.80
prewhereMethod · 0.80
shared_from_thisMethod · 0.80
getMaxAddedBlocksMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected