1#pragma once
2
3#include <Core/SortDescription.h>
4#include <Storages/MergeTree/MergeTreeData.h>
5#include <Storages/SelectQueryInfo.h>
6
7namespace DB
8{
9
10/** Helper class, that can analyze MergeTree order key
11 * and required sort description to get their
12 * common prefix, which is needed for
13 * performing reading in order of PK.
14 */
15class ReadInOrderOptimizer
16{
17public:
18 ReadInOrderOptimizer(
19 const ManyExpressionActions & elements_actions,
20 const SortDescription & required_sort_description,
21 const SyntaxAnalyzerResultPtr & syntax_result);
22
23 InputSortingInfoPtr getInputOrder(const StoragePtr & storage) const;
24
25private:
26 /// Actions for every element of order expression to analyze functions for monotonicicy
27 ManyExpressionActions elements_actions;
28 NameSet forbidden_columns;
29 SortDescription required_sort_description;
30};
31
32}
33