| 230 | using namespace _scan_execute_impl; |
| 231 | |
| 232 | class TableScanExecutor |
| 233 | { |
| 234 | public: |
| 235 | TableScanExecutor(TableScanStep & step, const MergeTreeMetaBase & storage_, ContextPtr context_); |
| 236 | ExecutePlan buildExecutePlan(const DistributedPipelineSettings & distributed_settings); |
| 237 | |
| 238 | private: |
| 239 | bool match(ProjectionMatchContext & candidate) const; |
| 240 | MergeTreeDataSelectAnalysisResultPtr estimateReadMarks(const PartGroup & part_group) const; |
| 241 | void estimateReadMarksForProjection(const PartGroup & part_group, ProjectionMatchContext & candidate) const; |
| 242 | void prunePartsByIndex(MergeTreeData::DataPartsVector & parts) const; |
| 243 | PartGroups groupPartsBySchema(const MergeTreeData::DataPartsVector & parts); |
| 244 | ASTPtr rewriteExpr(ASTPtr expr, ProjectionMatchContext & candidate) const; |
| 245 | |
| 246 | struct NameWithAST |
| 247 | { |
| 248 | String name; |
| 249 | ASTPtr flatten_ast; |
| 250 | }; |
| 251 | |
| 252 | bool match_projection = false; |
| 253 | |
| 254 | const MergeTreeMetaBase & storage; |
| 255 | StorageMetadataPtr storage_metadata; |
| 256 | MergeTreeDataSelectExecutor merge_tree_reader; |
| 257 | const SelectQueryInfo & select_query_info; |
| 258 | ContextPtr context; |
| 259 | Poco::Logger * log; |
| 260 | |
| 261 | bool has_aggregate; |
| 262 | std::optional<SymbolTransformMap> query_lineage; |
| 263 | Names query_required_columns; |
| 264 | NameToType column_types_before_agg; |
| 265 | std::vector<NameWithAST> aggregate_keys; |
| 266 | std::vector<NameWithAST> aggregate_descs; |
| 267 | ASTPtr flatten_filter; |
| 268 | ASTPtr flatten_prewhere; |
| 269 | std::shared_ptr<PartitionIdToMaxBlock> max_added_blocks; |
| 270 | }; |
| 271 | |
| 272 | TableScanExecutor::TableScanExecutor(TableScanStep & step, const MergeTreeMetaBase & storage_, ContextPtr context_) |
| 273 | : storage(storage_) |