Merge pull request #63983 from ClickHouse/fix-limit-by-skip-usunsed-shards

Limit by and skip_unused_shards with analyzer
This commit is contained in:
Dmitry Novik 2024-05-17 08:09:59 +00:00 committed by GitHub
commit 91066aeace
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -584,7 +584,7 @@ PlannerExpressionsAnalysisResult buildExpressionAnalysisResult(const QueryTreeNo
* otherwise coordinator does not find it in block. * otherwise coordinator does not find it in block.
*/ */
NameSet required_output_nodes_names; NameSet required_output_nodes_names;
if (sort_analysis_result_optional.has_value() && !planner_query_processing_info.isSecondStage()) if (sort_analysis_result_optional.has_value() && planner_query_processing_info.isFirstStage() && planner_query_processing_info.getToStage() != QueryProcessingStage::Complete)
{ {
const auto & before_order_by_actions = sort_analysis_result_optional->before_order_by_actions; const auto & before_order_by_actions = sort_analysis_result_optional->before_order_by_actions;
for (const auto & output_node : before_order_by_actions->getOutputs()) for (const auto & output_node : before_order_by_actions->getOutputs())

View File

@ -34,3 +34,6 @@ select * from dist_01757 where dummy in (0, 1) settings optimize_skip_unused_sha
select * from dist_01757 where dummy in (0, 1) settings optimize_skip_unused_shards_limit=9223372036854775808; -- { serverError 69 } select * from dist_01757 where dummy in (0, 1) settings optimize_skip_unused_shards_limit=9223372036854775808; -- { serverError 69 }
drop table dist_01757; drop table dist_01757;
-- fuzzed
SELECT * FROM remote('127.0.0.{1,2}', numbers(40), number) ORDER BY 'a' LIMIT 1 BY number SETTINGS optimize_skip_unused_shards = 1, force_optimize_skip_unused_shards=0 format Null