Skip to content

Commit

Permalink
Backport #42198 to 22.8: Fix a bug with projections and the `aggregat…
Browse files Browse the repository at this point in the history
…e_functions_null_for_empty` setting
  • Loading branch information
robot-clickhouse committed Oct 14, 2022
1 parent aaa25f0 commit 8bdb9c1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Storages/MergeTree/MergeTreeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5504,7 +5504,8 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
{
const auto & metadata_snapshot = storage_snapshot->metadata;
const auto & settings = query_context->getSettingsRef();
if (!settings.allow_experimental_projection_optimization || query_info.ignore_projections || query_info.is_projection_query)
if (!settings.allow_experimental_projection_optimization || query_info.ignore_projections || query_info.is_projection_query
|| settings.aggregate_functions_null_for_empty /* projections don't work correctly with this setting */)
return std::nullopt;

// Currently projections don't support parallel replicas reading yet.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20220920
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Tags: no-fasttest
# Tag no-fasttest: depends on bzip2

CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh

${CLICKHOUSE_LOCAL} --aggregate_functions_null_for_empty=1 --multiquery --query "create table test_date (date Int32) ENGINE = MergeTree ORDER BY (date) as select 20220920; SELECT max(date) FROM test_date";

0 comments on commit 8bdb9c1

Please sign in to comment.