mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Merge pull request #30360 from nikitamikhaylov/allow-graphite-final
Allow to use FINAL clause in SELECT from GraphiteMergeTree
This commit is contained in:
commit
56869c0ec4
@ -20,7 +20,7 @@ Subquery is another `SELECT` query that may be specified in parenthesis inside `
|
||||
|
||||
When `FINAL` is specified, ClickHouse fully merges the data before returning the result and thus performs all data transformations that happen during merges for the given table engine.
|
||||
|
||||
It is applicable when selecting data from tables that use the [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)-engine family (except `GraphiteMergeTree`). Also supported for:
|
||||
It is applicable when selecting data from tables that use the [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)-engine family. Also supported for:
|
||||
|
||||
- [Replicated](../../../engines/table-engines/mergetree-family/replication.md) versions of `MergeTree` engines.
|
||||
- [View](../../../engines/table-engines/special/view.md), [Buffer](../../../engines/table-engines/special/buffer.md), [Distributed](../../../engines/table-engines/special/distributed.md), and [MaterializedView](../../../engines/table-engines/special/materializedview.md) engines that operate over other engines, provided they were created over `MergeTree`-engine tables.
|
||||
|
@ -20,7 +20,7 @@ toc_title: FROM
|
||||
|
||||
Если в запросе используется модификатор `FINAL`, то ClickHouse полностью мёржит данные перед выдачей результата, таким образом выполняя все преобразования данных, которые производятся движком таблиц при мёржах.
|
||||
|
||||
Он применим при выборе данных из таблиц, использующих [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)- семейство движков (кроме `GraphiteMergeTree`). Также поддерживается для:
|
||||
Он применим при выборе данных из таблиц, использующих [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)- семейство движков. Также поддерживается для:
|
||||
|
||||
- [Replicated](../../../engines/table-engines/mergetree-family/replication.md) варианты исполнения `MergeTree` движков.
|
||||
- [View](../../../engines/table-engines/special/view.md), [Buffer](../../../engines/table-engines/special/buffer.md), [Distributed](../../../engines/table-engines/special/distributed.md), и [MaterializedView](../../../engines/table-engines/special/materializedview.md), которые работают поверх других движков, если они созданы для таблиц с движками семейства `MergeTree`.
|
||||
|
@ -20,7 +20,7 @@ toc_title: FROM
|
||||
|
||||
当 `FINAL` 被指定,ClickHouse会在返回结果之前完全合并数据,从而执行给定表引擎合并期间发生的所有数据转换。
|
||||
|
||||
它适用于从使用 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)-引擎族(除了 `GraphiteMergeTree`). 还支持:
|
||||
它适用于从使用 [MergeTree](../../../engines/table-engines/mergetree-family/mergetree.md)-引擎族. 还支持:
|
||||
|
||||
- [Replicated](../../../engines/table-engines/mergetree-family/replication.md) 版本 `MergeTree` 引擎
|
||||
- [View](../../../engines/table-engines/special/view.md), [Buffer](../../../engines/table-engines/special/buffer.md), [Distributed](../../../engines/table-engines/special/distributed.md),和 [MaterializedView](../../../engines/table-engines/special/materializedview.md) 在其他引擎上运行的引擎,只要是它们底层是 `MergeTree`-引擎表即可。
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <Processors/Sources/NullSource.h>
|
||||
#include <Processors/Merges/AggregatingSortedTransform.h>
|
||||
#include <Processors/Merges/CollapsingSortedTransform.h>
|
||||
#include <Processors/Merges/GraphiteRollupSortedTransform.h>
|
||||
#include <Processors/Merges/MergingSortedTransform.h>
|
||||
#include <Processors/Merges/ReplacingSortedTransform.h>
|
||||
#include <Processors/Merges/SummingSortedTransform.h>
|
||||
@ -506,38 +507,39 @@ static void addMergingFinal(
|
||||
const auto & header = pipe.getHeader();
|
||||
size_t num_outputs = pipe.numOutputPorts();
|
||||
|
||||
auto now = time(nullptr);
|
||||
|
||||
auto get_merging_processor = [&]() -> MergingTransformPtr
|
||||
{
|
||||
switch (merging_params.mode)
|
||||
{
|
||||
case MergeTreeData::MergingParams::Ordinary:
|
||||
{
|
||||
return std::make_shared<MergingSortedTransform>(header, num_outputs,
|
||||
sort_description, max_block_size);
|
||||
}
|
||||
sort_description, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::Collapsing:
|
||||
return std::make_shared<CollapsingSortedTransform>(header, num_outputs,
|
||||
sort_description, merging_params.sign_column, true, max_block_size);
|
||||
sort_description, merging_params.sign_column, true, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::Summing:
|
||||
return std::make_shared<SummingSortedTransform>(header, num_outputs,
|
||||
sort_description, merging_params.columns_to_sum, partition_key_columns, max_block_size);
|
||||
sort_description, merging_params.columns_to_sum, partition_key_columns, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::Aggregating:
|
||||
return std::make_shared<AggregatingSortedTransform>(header, num_outputs,
|
||||
sort_description, max_block_size);
|
||||
sort_description, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::Replacing:
|
||||
return std::make_shared<ReplacingSortedTransform>(header, num_outputs,
|
||||
sort_description, merging_params.version_column, max_block_size);
|
||||
sort_description, merging_params.version_column, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::VersionedCollapsing:
|
||||
return std::make_shared<VersionedCollapsingTransform>(header, num_outputs,
|
||||
sort_description, merging_params.sign_column, max_block_size);
|
||||
sort_description, merging_params.sign_column, max_block_size);
|
||||
|
||||
case MergeTreeData::MergingParams::Graphite:
|
||||
throw Exception("GraphiteMergeTree doesn't support FINAL", ErrorCodes::LOGICAL_ERROR);
|
||||
return std::make_shared<GraphiteRollupSortedTransform>(header, num_outputs,
|
||||
sort_description, max_block_size, merging_params.graphite_params, now);
|
||||
}
|
||||
|
||||
__builtin_unreachable();
|
||||
|
@ -406,6 +406,7 @@ public:
|
||||
|| merging_params.mode == MergingParams::Summing
|
||||
|| merging_params.mode == MergingParams::Aggregating
|
||||
|| merging_params.mode == MergingParams::Replacing
|
||||
|| merging_params.mode == MergingParams::Graphite
|
||||
|| merging_params.mode == MergingParams::VersionedCollapsing;
|
||||
}
|
||||
|
||||
|
@ -342,3 +342,347 @@
|
||||
2 sum_2 98950 1 940
|
||||
2 sum_2 108950 1 1040
|
||||
2 sum_2 70170 1 1140
|
||||
1 max_1 9 1 0
|
||||
1 max_1 19 1 10
|
||||
1 max_1 29 1 20
|
||||
1 max_1 39 1 30
|
||||
1 max_1 49 1 40
|
||||
1 max_1 59 1 50
|
||||
1 max_1 69 1 60
|
||||
1 max_1 79 1 70
|
||||
1 max_1 89 1 80
|
||||
1 max_1 99 1 90
|
||||
1 max_1 109 1 100
|
||||
1 max_1 119 1 110
|
||||
1 max_1 129 1 120
|
||||
1 max_1 139 1 130
|
||||
1 max_1 149 1 140
|
||||
1 max_1 159 1 150
|
||||
1 max_1 169 1 160
|
||||
1 max_1 179 1 170
|
||||
1 max_1 189 1 180
|
||||
1 max_1 199 1 190
|
||||
1 max_1 209 1 200
|
||||
1 max_1 219 1 210
|
||||
1 max_1 229 1 220
|
||||
1 max_1 239 1 230
|
||||
1 max_1 249 1 240
|
||||
1 max_1 259 1 250
|
||||
1 max_1 269 1 260
|
||||
1 max_1 279 1 270
|
||||
1 max_1 289 1 280
|
||||
1 max_1 299 1 290
|
||||
1 max_1 39 1 0
|
||||
1 max_1 139 1 40
|
||||
1 max_1 239 1 140
|
||||
1 max_1 339 1 240
|
||||
1 max_1 439 1 340
|
||||
1 max_1 539 1 440
|
||||
1 max_1 639 1 540
|
||||
1 max_1 739 1 640
|
||||
1 max_1 839 1 740
|
||||
1 max_1 939 1 840
|
||||
1 max_1 1039 1 940
|
||||
1 max_1 1139 1 1040
|
||||
1 max_1 1199 1 1140
|
||||
1 max_2 9 1 0
|
||||
1 max_2 19 1 10
|
||||
1 max_2 29 1 20
|
||||
1 max_2 39 1 30
|
||||
1 max_2 49 1 40
|
||||
1 max_2 59 1 50
|
||||
1 max_2 69 1 60
|
||||
1 max_2 79 1 70
|
||||
1 max_2 89 1 80
|
||||
1 max_2 99 1 90
|
||||
1 max_2 109 1 100
|
||||
1 max_2 119 1 110
|
||||
1 max_2 129 1 120
|
||||
1 max_2 139 1 130
|
||||
1 max_2 149 1 140
|
||||
1 max_2 159 1 150
|
||||
1 max_2 169 1 160
|
||||
1 max_2 179 1 170
|
||||
1 max_2 189 1 180
|
||||
1 max_2 199 1 190
|
||||
1 max_2 209 1 200
|
||||
1 max_2 219 1 210
|
||||
1 max_2 229 1 220
|
||||
1 max_2 239 1 230
|
||||
1 max_2 249 1 240
|
||||
1 max_2 259 1 250
|
||||
1 max_2 269 1 260
|
||||
1 max_2 279 1 270
|
||||
1 max_2 289 1 280
|
||||
1 max_2 299 1 290
|
||||
1 max_2 39 1 0
|
||||
1 max_2 139 1 40
|
||||
1 max_2 239 1 140
|
||||
1 max_2 339 1 240
|
||||
1 max_2 439 1 340
|
||||
1 max_2 539 1 440
|
||||
1 max_2 639 1 540
|
||||
1 max_2 739 1 640
|
||||
1 max_2 839 1 740
|
||||
1 max_2 939 1 840
|
||||
1 max_2 1039 1 940
|
||||
1 max_2 1139 1 1040
|
||||
1 max_2 1199 1 1140
|
||||
1 sum_1 45 1 0
|
||||
1 sum_1 145 1 10
|
||||
1 sum_1 245 1 20
|
||||
1 sum_1 345 1 30
|
||||
1 sum_1 445 1 40
|
||||
1 sum_1 545 1 50
|
||||
1 sum_1 645 1 60
|
||||
1 sum_1 745 1 70
|
||||
1 sum_1 845 1 80
|
||||
1 sum_1 945 1 90
|
||||
1 sum_1 1045 1 100
|
||||
1 sum_1 1145 1 110
|
||||
1 sum_1 1245 1 120
|
||||
1 sum_1 1345 1 130
|
||||
1 sum_1 1445 1 140
|
||||
1 sum_1 1545 1 150
|
||||
1 sum_1 1645 1 160
|
||||
1 sum_1 1745 1 170
|
||||
1 sum_1 1845 1 180
|
||||
1 sum_1 1945 1 190
|
||||
1 sum_1 2045 1 200
|
||||
1 sum_1 2145 1 210
|
||||
1 sum_1 2245 1 220
|
||||
1 sum_1 2345 1 230
|
||||
1 sum_1 2445 1 240
|
||||
1 sum_1 2545 1 250
|
||||
1 sum_1 2645 1 260
|
||||
1 sum_1 2745 1 270
|
||||
1 sum_1 2845 1 280
|
||||
1 sum_1 2945 1 290
|
||||
1 sum_1 780 1 0
|
||||
1 sum_1 8950 1 40
|
||||
1 sum_1 18950 1 140
|
||||
1 sum_1 28950 1 240
|
||||
1 sum_1 38950 1 340
|
||||
1 sum_1 48950 1 440
|
||||
1 sum_1 58950 1 540
|
||||
1 sum_1 68950 1 640
|
||||
1 sum_1 78950 1 740
|
||||
1 sum_1 88950 1 840
|
||||
1 sum_1 98950 1 940
|
||||
1 sum_1 108950 1 1040
|
||||
1 sum_1 70170 1 1140
|
||||
1 sum_2 45 1 0
|
||||
1 sum_2 145 1 10
|
||||
1 sum_2 245 1 20
|
||||
1 sum_2 345 1 30
|
||||
1 sum_2 445 1 40
|
||||
1 sum_2 545 1 50
|
||||
1 sum_2 645 1 60
|
||||
1 sum_2 745 1 70
|
||||
1 sum_2 845 1 80
|
||||
1 sum_2 945 1 90
|
||||
1 sum_2 1045 1 100
|
||||
1 sum_2 1145 1 110
|
||||
1 sum_2 1245 1 120
|
||||
1 sum_2 1345 1 130
|
||||
1 sum_2 1445 1 140
|
||||
1 sum_2 1545 1 150
|
||||
1 sum_2 1645 1 160
|
||||
1 sum_2 1745 1 170
|
||||
1 sum_2 1845 1 180
|
||||
1 sum_2 1945 1 190
|
||||
1 sum_2 2045 1 200
|
||||
1 sum_2 2145 1 210
|
||||
1 sum_2 2245 1 220
|
||||
1 sum_2 2345 1 230
|
||||
1 sum_2 2445 1 240
|
||||
1 sum_2 2545 1 250
|
||||
1 sum_2 2645 1 260
|
||||
1 sum_2 2745 1 270
|
||||
1 sum_2 2845 1 280
|
||||
1 sum_2 2945 1 290
|
||||
1 sum_2 780 1 0
|
||||
1 sum_2 8950 1 40
|
||||
1 sum_2 18950 1 140
|
||||
1 sum_2 28950 1 240
|
||||
1 sum_2 38950 1 340
|
||||
1 sum_2 48950 1 440
|
||||
1 sum_2 58950 1 540
|
||||
1 sum_2 68950 1 640
|
||||
1 sum_2 78950 1 740
|
||||
1 sum_2 88950 1 840
|
||||
1 sum_2 98950 1 940
|
||||
1 sum_2 108950 1 1040
|
||||
1 sum_2 70170 1 1140
|
||||
2 max_1 9 1 0
|
||||
2 max_1 19 1 10
|
||||
2 max_1 29 1 20
|
||||
2 max_1 39 1 30
|
||||
2 max_1 49 1 40
|
||||
2 max_1 59 1 50
|
||||
2 max_1 69 1 60
|
||||
2 max_1 79 1 70
|
||||
2 max_1 89 1 80
|
||||
2 max_1 99 1 90
|
||||
2 max_1 109 1 100
|
||||
2 max_1 119 1 110
|
||||
2 max_1 129 1 120
|
||||
2 max_1 139 1 130
|
||||
2 max_1 149 1 140
|
||||
2 max_1 159 1 150
|
||||
2 max_1 169 1 160
|
||||
2 max_1 179 1 170
|
||||
2 max_1 189 1 180
|
||||
2 max_1 199 1 190
|
||||
2 max_1 209 1 200
|
||||
2 max_1 219 1 210
|
||||
2 max_1 229 1 220
|
||||
2 max_1 239 1 230
|
||||
2 max_1 249 1 240
|
||||
2 max_1 259 1 250
|
||||
2 max_1 269 1 260
|
||||
2 max_1 279 1 270
|
||||
2 max_1 289 1 280
|
||||
2 max_1 299 1 290
|
||||
2 max_1 39 1 0
|
||||
2 max_1 139 1 40
|
||||
2 max_1 239 1 140
|
||||
2 max_1 339 1 240
|
||||
2 max_1 439 1 340
|
||||
2 max_1 539 1 440
|
||||
2 max_1 639 1 540
|
||||
2 max_1 739 1 640
|
||||
2 max_1 839 1 740
|
||||
2 max_1 939 1 840
|
||||
2 max_1 1039 1 940
|
||||
2 max_1 1139 1 1040
|
||||
2 max_1 1199 1 1140
|
||||
2 max_2 9 1 0
|
||||
2 max_2 19 1 10
|
||||
2 max_2 29 1 20
|
||||
2 max_2 39 1 30
|
||||
2 max_2 49 1 40
|
||||
2 max_2 59 1 50
|
||||
2 max_2 69 1 60
|
||||
2 max_2 79 1 70
|
||||
2 max_2 89 1 80
|
||||
2 max_2 99 1 90
|
||||
2 max_2 109 1 100
|
||||
2 max_2 119 1 110
|
||||
2 max_2 129 1 120
|
||||
2 max_2 139 1 130
|
||||
2 max_2 149 1 140
|
||||
2 max_2 159 1 150
|
||||
2 max_2 169 1 160
|
||||
2 max_2 179 1 170
|
||||
2 max_2 189 1 180
|
||||
2 max_2 199 1 190
|
||||
2 max_2 209 1 200
|
||||
2 max_2 219 1 210
|
||||
2 max_2 229 1 220
|
||||
2 max_2 239 1 230
|
||||
2 max_2 249 1 240
|
||||
2 max_2 259 1 250
|
||||
2 max_2 269 1 260
|
||||
2 max_2 279 1 270
|
||||
2 max_2 289 1 280
|
||||
2 max_2 299 1 290
|
||||
2 max_2 39 1 0
|
||||
2 max_2 139 1 40
|
||||
2 max_2 239 1 140
|
||||
2 max_2 339 1 240
|
||||
2 max_2 439 1 340
|
||||
2 max_2 539 1 440
|
||||
2 max_2 639 1 540
|
||||
2 max_2 739 1 640
|
||||
2 max_2 839 1 740
|
||||
2 max_2 939 1 840
|
||||
2 max_2 1039 1 940
|
||||
2 max_2 1139 1 1040
|
||||
2 max_2 1199 1 1140
|
||||
2 sum_1 45 1 0
|
||||
2 sum_1 145 1 10
|
||||
2 sum_1 245 1 20
|
||||
2 sum_1 345 1 30
|
||||
2 sum_1 445 1 40
|
||||
2 sum_1 545 1 50
|
||||
2 sum_1 645 1 60
|
||||
2 sum_1 745 1 70
|
||||
2 sum_1 845 1 80
|
||||
2 sum_1 945 1 90
|
||||
2 sum_1 1045 1 100
|
||||
2 sum_1 1145 1 110
|
||||
2 sum_1 1245 1 120
|
||||
2 sum_1 1345 1 130
|
||||
2 sum_1 1445 1 140
|
||||
2 sum_1 1545 1 150
|
||||
2 sum_1 1645 1 160
|
||||
2 sum_1 1745 1 170
|
||||
2 sum_1 1845 1 180
|
||||
2 sum_1 1945 1 190
|
||||
2 sum_1 2045 1 200
|
||||
2 sum_1 2145 1 210
|
||||
2 sum_1 2245 1 220
|
||||
2 sum_1 2345 1 230
|
||||
2 sum_1 2445 1 240
|
||||
2 sum_1 2545 1 250
|
||||
2 sum_1 2645 1 260
|
||||
2 sum_1 2745 1 270
|
||||
2 sum_1 2845 1 280
|
||||
2 sum_1 2945 1 290
|
||||
2 sum_1 780 1 0
|
||||
2 sum_1 8950 1 40
|
||||
2 sum_1 18950 1 140
|
||||
2 sum_1 28950 1 240
|
||||
2 sum_1 38950 1 340
|
||||
2 sum_1 48950 1 440
|
||||
2 sum_1 58950 1 540
|
||||
2 sum_1 68950 1 640
|
||||
2 sum_1 78950 1 740
|
||||
2 sum_1 88950 1 840
|
||||
2 sum_1 98950 1 940
|
||||
2 sum_1 108950 1 1040
|
||||
2 sum_1 70170 1 1140
|
||||
2 sum_2 45 1 0
|
||||
2 sum_2 145 1 10
|
||||
2 sum_2 245 1 20
|
||||
2 sum_2 345 1 30
|
||||
2 sum_2 445 1 40
|
||||
2 sum_2 545 1 50
|
||||
2 sum_2 645 1 60
|
||||
2 sum_2 745 1 70
|
||||
2 sum_2 845 1 80
|
||||
2 sum_2 945 1 90
|
||||
2 sum_2 1045 1 100
|
||||
2 sum_2 1145 1 110
|
||||
2 sum_2 1245 1 120
|
||||
2 sum_2 1345 1 130
|
||||
2 sum_2 1445 1 140
|
||||
2 sum_2 1545 1 150
|
||||
2 sum_2 1645 1 160
|
||||
2 sum_2 1745 1 170
|
||||
2 sum_2 1845 1 180
|
||||
2 sum_2 1945 1 190
|
||||
2 sum_2 2045 1 200
|
||||
2 sum_2 2145 1 210
|
||||
2 sum_2 2245 1 220
|
||||
2 sum_2 2345 1 230
|
||||
2 sum_2 2445 1 240
|
||||
2 sum_2 2545 1 250
|
||||
2 sum_2 2645 1 260
|
||||
2 sum_2 2745 1 270
|
||||
2 sum_2 2845 1 280
|
||||
2 sum_2 2945 1 290
|
||||
2 sum_2 780 1 0
|
||||
2 sum_2 8950 1 40
|
||||
2 sum_2 18950 1 140
|
||||
2 sum_2 28950 1 240
|
||||
2 sum_2 38950 1 340
|
||||
2 sum_2 48950 1 440
|
||||
2 sum_2 58950 1 540
|
||||
2 sum_2 68950 1 640
|
||||
2 sum_2 78950 1 740
|
||||
2 sum_2 88950 1 840
|
||||
2 sum_2 98950 1 940
|
||||
2 sum_2 108950 1 1040
|
||||
2 sum_2 70170 1 1140
|
||||
|
@ -32,6 +32,8 @@ WITH dates AS
|
||||
select 1, 'max_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200) union all
|
||||
select 2, 'max_2', older_date - number * 60 - 30, number, 1, number from dates, numbers(1200);
|
||||
|
||||
select key, Path, Value, Version, col from test_graphite final order by key, Path, Time desc;
|
||||
|
||||
optimize table test_graphite final;
|
||||
|
||||
select key, Path, Value, Version, col from test_graphite order by key, Path, Time desc;
|
||||
|
Loading…
Reference in New Issue
Block a user