From c69f587f8a10a66aea1c366b9723cfbd463b7c6c Mon Sep 17 00:00:00 2001 From: kssenii Date: Thu, 20 May 2021 15:32:18 +0000 Subject: [PATCH] Adjust minMax index --- src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp | 10 ++++++---- src/Storages/MergeTree/MergeTreeDataSelectExecutor.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp index 5f51358a7d2..7e61470c0ec 100644 --- a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp +++ b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.cpp @@ -497,7 +497,7 @@ QueryPlanPtr MergeTreeDataSelectExecutor::readFromParts( DataTypes minmax_columns_types; if (metadata_snapshot_base->hasPartitionKey()) { - const auto & partition_key = metadata_snapshot_base->getPartitionKey(); + const auto & partition_key = MergeTreePartition::adjustPartitionKey(metadata_snapshot_base, context); auto minmax_columns_names = data.getMinMaxColumnsNames(partition_key); minmax_columns_types = data.getMinMaxColumnsTypes(partition_key); @@ -1175,7 +1175,8 @@ QueryPlanPtr MergeTreeDataSelectExecutor::readFromParts( settings, reader_settings, result_projection, - query_id); + query_id, + context); } else if ((settings.optimize_read_in_order || settings.optimize_aggregation_in_order) && input_order_info) { @@ -1676,7 +1677,8 @@ QueryPlanPtr MergeTreeDataSelectExecutor::spreadMarkRangesAmongStreamsFinal( const Settings & settings, const MergeTreeReaderSettings & reader_settings, ActionsDAGPtr & out_projection, - const String & query_id) const + const String & query_id, + ContextPtr context) const { const auto data_settings = data.getSettings(); size_t sum_marks = 0; @@ -1826,7 +1828,7 @@ QueryPlanPtr MergeTreeDataSelectExecutor::spreadMarkRangesAmongStreamsFinal( size_t sort_columns_size = sort_columns.size(); sort_description.reserve(sort_columns_size); - Names partition_key_columns = metadata_snapshot->getPartitionKey().column_names; + Names partition_key_columns = MergeTreePartition::adjustPartitionKey(metadata_snapshot, context).column_names; const auto & header = plan->getCurrentDataStream().header; for (size_t i = 0; i < sort_columns_size; ++i) diff --git a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h index 8335e54213f..cda8026a78d 100644 --- a/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h +++ b/src/Storages/MergeTree/MergeTreeDataSelectExecutor.h @@ -114,7 +114,8 @@ private: const Settings & settings, const MergeTreeReaderSettings & reader_settings, ActionsDAGPtr & out_projection, - const String & query_id) const; + const String & query_id, + ContextPtr context) const; /// Get the approximate value (bottom estimate - only by full marks) of the number of rows falling under the index. size_t getApproximateTotalRowsToRead(