|
68 | 68 | #include <Processors/QueryPlan/TotalsHavingStep.h>
|
69 | 69 | #include <Processors/QueryPlan/WindowStep.h>
|
70 | 70 | #include <Processors/QueryPlan/Optimizations/QueryPlanOptimizationSettings.h>
|
| 71 | +#include <Processors/QueryPlan/ObjectFilterStep.h> |
71 | 72 | #include <Processors/Sources/NullSource.h>
|
72 | 73 | #include <Processors/Sources/SourceFromSingleChunk.h>
|
73 | 74 | #include <Processors/Transforms/AggregatingTransform.h>
|
@@ -189,6 +190,7 @@ namespace Setting
|
189 | 190 | extern const SettingsUInt64 min_count_to_compile_aggregate_expression;
|
190 | 191 | extern const SettingsBool enable_software_prefetch_in_aggregation;
|
191 | 192 | extern const SettingsBool optimize_group_by_constant_keys;
|
| 193 | + extern const SettingsBool use_hive_partitioning; |
192 | 194 | }
|
193 | 195 |
|
194 | 196 | namespace ServerSetting
|
@@ -1965,6 +1967,22 @@ void InterpreterSelectQuery::executeImpl(QueryPlan & query_plan, std::optional<P
|
1965 | 1967 |
|
1966 | 1968 | if (expressions.second_stage || from_aggregation_stage)
|
1967 | 1969 | {
|
| 1970 | + if (settings[Setting::use_hive_partitioning] |
| 1971 | + && !expressions.first_stage |
| 1972 | + && expressions.hasWhere()) |
| 1973 | + { |
| 1974 | + if (typeid_cast<ReadFromCluster *>(query_plan.getRootNode()->step.get())) |
| 1975 | + { |
| 1976 | + auto object_filter_step = std::make_unique<ObjectFilterStep>( |
| 1977 | + query_plan.getCurrentHeader(), |
| 1978 | + expressions.before_where->dag.clone(), |
| 1979 | + getSelectQuery().where()->getColumnName()); |
| 1980 | + |
| 1981 | + object_filter_step->setStepDescription("WHERE"); |
| 1982 | + query_plan.addStep(std::move(object_filter_step)); |
| 1983 | + } |
| 1984 | + } |
| 1985 | + |
1968 | 1986 | if (from_aggregation_stage)
|
1969 | 1987 | {
|
1970 | 1988 | /// No need to aggregate anything, since this was done on remote shards.
|
|
0 commit comments