mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #37724 from CurtizJ/fix-ast-optimizations-remote
Fix `optimize_monotonous_functions_in_order_by` in distributed queries
This commit is contained in:
commit
a0020cb55c
@ -135,7 +135,7 @@ struct SelectQueryOptions
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelectQueryOptions & ignoreASTOptimizationsAlias(bool value = true)
|
||||
SelectQueryOptions & ignoreASTOptimizations(bool value = true)
|
||||
{
|
||||
ignore_ast_optimizations = value;
|
||||
return *this;
|
||||
|
@ -46,8 +46,15 @@ std::unique_ptr<QueryPlan> createLocalPlan(
|
||||
checkStackSize();
|
||||
|
||||
auto query_plan = std::make_unique<QueryPlan>();
|
||||
/// Do not apply AST optimizations, because query
|
||||
/// is already optimized and some optimizations
|
||||
/// can be applied only for non-distributed tables
|
||||
/// and we can produce query, inconsistent with remote plans.
|
||||
auto interpreter = InterpreterSelectQuery(
|
||||
query_ast, context, SelectQueryOptions(processed_stage).setShardInfo(shard_num, shard_count));
|
||||
query_ast, context,
|
||||
SelectQueryOptions(processed_stage)
|
||||
.setShardInfo(shard_num, shard_count)
|
||||
.ignoreASTOptimizations());
|
||||
|
||||
interpreter.setProperClientInfo();
|
||||
if (coordinator)
|
||||
|
@ -109,7 +109,7 @@ ProjectionDescription::getProjectionFromAST(const ASTPtr & definition_ast, const
|
||||
InterpreterSelectQuery select(
|
||||
result.query_ast, query_context, storage, {},
|
||||
/// Here we ignore ast optimizations because otherwise aggregation keys may be removed from result header as constants.
|
||||
SelectQueryOptions{QueryProcessingStage::WithMergeableState}.modify().ignoreAlias().ignoreASTOptimizationsAlias());
|
||||
SelectQueryOptions{QueryProcessingStage::WithMergeableState}.modify().ignoreAlias().ignoreASTOptimizations());
|
||||
|
||||
result.required_columns = select.getRequiredColumns();
|
||||
result.sample_block = select.getSampleBlock();
|
||||
@ -221,7 +221,7 @@ ProjectionDescription ProjectionDescription::getMinMaxCountProjection(
|
||||
InterpreterSelectQuery select(
|
||||
result.query_ast, query_context, storage, {},
|
||||
/// Here we ignore ast optimizations because otherwise aggregation keys may be removed from result header as constants.
|
||||
SelectQueryOptions{QueryProcessingStage::WithMergeableState}.modify().ignoreAlias().ignoreASTOptimizationsAlias());
|
||||
SelectQueryOptions{QueryProcessingStage::WithMergeableState}.modify().ignoreAlias().ignoreASTOptimizations());
|
||||
result.required_columns = select.getRequiredColumns();
|
||||
result.sample_block = select.getSampleBlock();
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
0
|
||||
0
|
@ -0,0 +1,6 @@
|
||||
SET prefer_localhost_replica = 1;
|
||||
SET optimize_monotonous_functions_in_order_by = 1;
|
||||
|
||||
SELECT *
|
||||
FROM cluster(test_cluster_two_shards_localhost, system, one)
|
||||
ORDER BY toDateTime(dummy);
|
Loading…
Reference in New Issue
Block a user