Merge pull request #44850 from ClickHouse/respect-context-in-projection-optimization

Save context created from projection analysis.
This commit is contained in:
Nikolai Kochetov 2023-01-03 13:30:51 +01:00 committed by GitHub
commit 6b1a697b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 0 deletions

View File

@ -6137,6 +6137,7 @@ std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAgg
{
ProjectionCandidate candidate{};
candidate.desc = &projection;
candidate.context = select.getContext();
auto sample_block = projection.sample_block;
auto sample_block_for_keys = projection.sample_block_for_keys;

View File

@ -466,6 +466,7 @@ QueryPlanPtr MergeTreeDataSelectExecutor::read(
fmt::format("MergeTree(with {} projection {})", query_info.projection->desc->type, query_info.projection->desc->name),
query_info.storage_limits);
plan->addStep(std::move(step));
plan->addInterpreterContext(query_info.projection->context);
return plan;
}

View File

@ -163,6 +163,9 @@ struct ProjectionCandidate
SortDescription group_by_elements_order_descr;
MergeTreeDataSelectAnalysisResultPtr merge_tree_projection_select_result_ptr;
MergeTreeDataSelectAnalysisResultPtr merge_tree_normal_select_result_ptr;
/// Because projection analysis uses a separate interpreter.
ContextPtr context;
};
/** Query along with some additional data,

View File

@ -0,0 +1,6 @@
DROP TABLE IF EXISTS test1__fuzz_37;
CREATE TABLE test1__fuzz_37 (`i` Date) ENGINE = MergeTree ORDER BY i;
insert into test1__fuzz_37 values ('2020-10-10');
SELECT count() FROM test1__fuzz_37 GROUP BY dictHas(NULL, (dictHas(NULL, (('', materialize(NULL)), materialize(NULL))), 'KeyKey')), dictHas('test_dictionary', tuple(materialize('Ke\0'))), tuple(dictHas(NULL, (tuple('Ke\0Ke\0Ke\0Ke\0Ke\0Ke\0\0\0\0Ke\0'), materialize(NULL)))), 'test_dicti\0nary', (('', materialize(NULL)), dictHas(NULL, (dictHas(NULL, tuple(materialize(NULL))), 'KeyKeyKeyKeyKeyKeyKeyKey')), materialize(NULL)); -- { serverError BAD_ARGUMENTS }
SELECT count() FROM test1__fuzz_37 GROUP BY dictHas('non_existing_dictionary', materialize('a')); -- { serverError BAD_ARGUMENTS }
DROP TABLE test1__fuzz_37;