mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
fix
This commit is contained in:
parent
d1a14d76f1
commit
c47ec31617
@ -4539,12 +4539,12 @@ Block MergeTreeData::getMinMaxCountProjectionBlock(
|
||||
}
|
||||
|
||||
|
||||
bool MergeTreeData::getQueryProcessingStageWithAggregateProjection(
|
||||
std::optional<ProjectionCandidate> MergeTreeData::getQueryProcessingStageWithAggregateProjection(
|
||||
ContextPtr query_context, const StorageMetadataPtr & metadata_snapshot, SelectQueryInfo & query_info) const
|
||||
{
|
||||
const auto & settings = query_context->getSettingsRef();
|
||||
if (!settings.allow_experimental_projection_optimization || query_info.ignore_projections || query_info.is_projection_query)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
|
||||
const auto & query_ptr = query_info.original_query;
|
||||
|
||||
@ -4552,16 +4552,16 @@ bool MergeTreeData::getQueryProcessingStageWithAggregateProjection(
|
||||
{
|
||||
// Currently projections don't support final yet.
|
||||
if (select->final())
|
||||
return false;
|
||||
return std::nullopt;
|
||||
|
||||
// Currently projections don't support ARRAY JOIN yet.
|
||||
if (select->arrayJoinExpressionList().first)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Currently projections don't support sampling yet.
|
||||
if (settings.parallel_replicas_count > 1)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
|
||||
InterpreterSelectQuery select(
|
||||
query_ptr,
|
||||
@ -4918,14 +4918,14 @@ bool MergeTreeData::getQueryProcessingStageWithAggregateProjection(
|
||||
}
|
||||
|
||||
if (!selected_candidate)
|
||||
return false;
|
||||
return std::nullopt;
|
||||
else if (min_sum_marks == 0)
|
||||
{
|
||||
/// If selected_projection indicated an empty result set. Remember it in query_info but
|
||||
/// don't use projection to run the query, because projection pipeline with empty result
|
||||
/// set will not work correctly with empty_result_for_aggregation_by_empty_set.
|
||||
query_info.merge_tree_empty_result = true;
|
||||
return false;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (selected_candidate->desc->type == ProjectionDescription::Type::Aggregate)
|
||||
@ -4936,8 +4936,7 @@ bool MergeTreeData::getQueryProcessingStageWithAggregateProjection(
|
||||
= std::make_shared<SubqueriesForSets>(std::move(select.getQueryAnalyzer()->getSubqueriesForSets()));
|
||||
}
|
||||
|
||||
query_info.projection = std::move(*selected_candidate);
|
||||
return true;
|
||||
return *selected_candidate;
|
||||
}
|
||||
|
||||
|
||||
@ -4949,11 +4948,14 @@ QueryProcessingStage::Enum MergeTreeData::getQueryProcessingStage(
|
||||
{
|
||||
if (to_stage >= QueryProcessingStage::Enum::WithMergeableState)
|
||||
{
|
||||
if (getQueryProcessingStageWithAggregateProjection(query_context, metadata_snapshot, query_info))
|
||||
if (auto projection = getQueryProcessingStageWithAggregateProjection(query_context, metadata_snapshot, query_info))
|
||||
{
|
||||
query_info.projection = std::move(projection);
|
||||
if (query_info.projection->desc->type == ProjectionDescription::Type::Aggregate)
|
||||
return QueryProcessingStage::Enum::WithMergeableState;
|
||||
}
|
||||
else
|
||||
query_info.projection = std::nullopt;
|
||||
}
|
||||
|
||||
return QueryProcessingStage::Enum::FetchColumns;
|
||||
|
@ -383,7 +383,7 @@ public:
|
||||
DataPartsVector & normal_parts,
|
||||
ContextPtr query_context) const;
|
||||
|
||||
bool getQueryProcessingStageWithAggregateProjection(
|
||||
std::optional<ProjectionCandidate> getQueryProcessingStageWithAggregateProjection(
|
||||
ContextPtr query_context, const StorageMetadataPtr & metadata_snapshot, SelectQueryInfo & query_info) const;
|
||||
|
||||
QueryProcessingStage::Enum getQueryProcessingStage(
|
||||
|
@ -16,3 +16,4 @@
|
||||
\N 2021-10-27 10:00:00 4
|
||||
2021-10-24 10:00:00
|
||||
2021-10-24 10:00:00
|
||||
0
|
||||
|
@ -55,5 +55,6 @@ select count() from d group by toDate(dt);
|
||||
SELECT pointInEllipses(min(j), NULL), max(dt), count('0.0000000007') FROM d WHERE toDate(dt) >= '2021-10-25';
|
||||
SELECT min(dt) FROM d PREWHERE ceil(j) <= 0;
|
||||
SELECT min(dt) FROM d PREWHERE ((0.9998999834060669 AND 1023) AND 255) <= ceil(j);
|
||||
SELECT count('') AND NULL FROM d PREWHERE ceil(j) <= NULL;
|
||||
|
||||
drop table d;
|
||||
|
Loading…
Reference in New Issue
Block a user