|
39 | 39 | #include <Processors/QueryPlan/WindowStep.h> |
40 | 40 | #include <Processors/QueryPlan/ReadNothingStep.h> |
41 | 41 | #include <Processors/QueryPlan/ReadFromRecursiveCTEStep.h> |
| 42 | +#include <Processors/QueryPlan/ObjectFilterStep.h> |
42 | 43 | #include <QueryPipeline/QueryPipelineBuilder.h> |
43 | 44 |
|
44 | 45 | #include <Interpreters/Context.h> |
|
53 | 54 | #include <Storages/StorageDummy.h> |
54 | 55 | #include <Storages/StorageMerge.h> |
55 | 56 | #include <Storages/ObjectStorage/StorageObjectStorageCluster.h> |
| 57 | +#include <Storages/IStorageCluster.h> |
56 | 58 |
|
57 | 59 | #include <AggregateFunctions/IAggregateFunction.h> |
58 | 60 |
|
@@ -144,6 +146,7 @@ namespace Setting |
144 | 146 | extern const SettingsUInt64 max_rows_to_transfer; |
145 | 147 | extern const SettingsOverflowMode transfer_overflow_mode; |
146 | 148 | extern const SettingsBool enable_parallel_blocks_marshalling; |
| 149 | + extern const SettingsBool use_hive_partitioning; |
147 | 150 | } |
148 | 151 |
|
149 | 152 | namespace ServerSetting |
@@ -473,6 +476,19 @@ void addFilterStep( |
473 | 476 | query_plan.addStep(std::move(where_step)); |
474 | 477 | } |
475 | 478 |
|
| 479 | +void addObjectFilterStep(QueryPlan & query_plan, |
| 480 | + FilterAnalysisResult & filter_analysis_result, |
| 481 | + const std::string & step_description) |
| 482 | +{ |
| 483 | + auto actions = std::move(filter_analysis_result.filter_actions->dag); |
| 484 | + |
| 485 | + auto where_step = std::make_unique<ObjectFilterStep>(query_plan.getCurrentHeader(), |
| 486 | + std::move(actions), |
| 487 | + filter_analysis_result.filter_column_name); |
| 488 | + where_step->setStepDescription(step_description); |
| 489 | + query_plan.addStep(std::move(where_step)); |
| 490 | +} |
| 491 | + |
476 | 492 | Aggregator::Params getAggregatorParams(const PlannerContextPtr & planner_context, |
477 | 493 | const AggregationAnalysisResult & aggregation_analysis_result, |
478 | 494 | const QueryAnalysisResult & query_analysis_result, |
@@ -1787,6 +1803,16 @@ void Planner::buildPlanForQueryNode() |
1787 | 1803 |
|
1788 | 1804 | if (query_processing_info.isSecondStage() || query_processing_info.isFromAggregationState()) |
1789 | 1805 | { |
| 1806 | + if (settings[Setting::use_hive_partitioning] |
| 1807 | + && !query_processing_info.isFirstStage() |
| 1808 | + && expression_analysis_result.hasWhere()) |
| 1809 | + { |
| 1810 | + if (typeid_cast<ReadFromCluster *>(query_plan.getRootNode()->step.get())) |
| 1811 | + { |
| 1812 | + addObjectFilterStep(query_plan, expression_analysis_result.getWhere(), "WHERE"); |
| 1813 | + } |
| 1814 | + } |
| 1815 | + |
1790 | 1816 | if (query_processing_info.isFromAggregationState()) |
1791 | 1817 | { |
1792 | 1818 | /// Aggregation was performed on remote shards |
|
0 commit comments