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

Method ExpressionAnalysisResult

src/Interpreters/ExpressionAnalyzer.cpp:2072–2425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2070}
2071
2072ExpressionAnalysisResult::ExpressionAnalysisResult(
2073 SelectQueryExpressionAnalyzer & query_analyzer,
2074 const StorageMetadataPtr & metadata_snapshot,
2075 bool first_stage_,
2076 bool second_stage_,
2077 bool only_types,
2078 const FilterDAGInfoPtr & filter_info_,
2079 const Block & source_header,
2080 const std::vector<ASTPtr> & additional_predicates)
2081 : first_stage(first_stage_)
2082 , second_stage(second_stage_)
2083 , need_aggregate(query_analyzer.hasAggregation())
2084 , has_window(query_analyzer.hasWindow())
2085 , use_grouping_set_key(query_analyzer.useGroupingSetKey())
2086{
2087 /// first_stage: Do I need to perform the first part of the pipeline - running on remote servers during distributed processing.
2088 /// second_stage: Do I need to execute the second part of the pipeline - running on the initiating server during distributed processing.
2089
2090 /** First we compose a chain of actions and remember the necessary steps from it.
2091 * Regardless of from_stage and to_stage, we will compose a complete sequence of actions to perform optimization and
2092 * throw out unnecessary columns based on the entire query. In unnecessary parts of the query, we will not execute subqueries.
2093 */
2094
2095 const ASTSelectQuery & query = *query_analyzer.getSelectQuery();
2096 auto context = query_analyzer.getContext();
2097 const Settings & settings = context->getSettingsRef();
2098 const ConstStoragePtr & storage = query_analyzer.storage();
2099 Block precomputed_header;
2100 auto index_context = query_analyzer.getIndexContext();
2101 if (auto * bitmap_index_info = dynamic_cast<BitmapIndexInfo *>(index_context->get(MergeTreeIndexInfo::Type::BITMAP).get()))
2102 {
2103 for (auto & ele : bitmap_index_info->return_types)
2104 {
2105 if (ele.second == BitmapIndexReturnType::EXPRESSION)
2106 precomputed_header.insert({std::make_shared<DataTypeUInt8>(), ele.first});
2107 }
2108 }
2109
2110 bool finalized = false;
2111 size_t where_step_num = 0;
2112
2113 auto finalize_chain = [&](ExpressionActionsChain & chain) {
2114 chain.finalize();
2115
2116 if (!finalized)
2117 {
2118 finalize(chain, where_step_num, query);
2119 finalized = true;
2120 }
2121
2122 // fmt::print("After finallize ---------- \n{}\n", chain.dumpChain());
2123
2124 chain.clear();
2125 };
2126
2127 if (storage)
2128 {
2129 query_analyzer.makeSetsForIndex(query.where());

Callers

nothing calls this directly

Calls 15

sanitizeBlockFunction · 0.85
sanitizeDataTypeFunction · 0.85
makeASTFunctionFunction · 0.85
hasWindowMethod · 0.80
useGroupingSetKeyMethod · 0.80
getIndexContextMethod · 0.80
prewhereMethod · 0.80
sampleSizeMethod · 0.80

Tested by

no test coverage detected