mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
properly handle case when there is nondeterministic functions
This commit is contained in:
parent
581f31ad3d
commit
3e3d1d15a8
@ -1055,6 +1055,14 @@ void ActionsDAG::assertDeterministic() const
|
||||
"Expression must be deterministic but it contains non-deterministic part `{}`", node.result_name);
|
||||
}
|
||||
|
||||
bool ActionsDAG::hasNonDeterministic() const
|
||||
{
|
||||
for (const auto & node : nodes)
|
||||
if (!node.is_deterministic)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ActionsDAG::addMaterializingOutputActions()
|
||||
{
|
||||
for (auto & output_node : outputs)
|
||||
|
@ -225,6 +225,7 @@ public:
|
||||
bool hasStatefulFunctions() const;
|
||||
bool trivial() const; /// If actions has no functions or array join.
|
||||
void assertDeterministic() const; /// Throw if not isDeterministic.
|
||||
bool hasNonDeterministic() const;
|
||||
|
||||
#if USE_EMBEDDED_COMPILER
|
||||
void compileExpressions(size_t min_count_to_compile_expression, const std::unordered_set<const Node *> & lazy_executed_nodes = {});
|
||||
|
@ -158,7 +158,7 @@ bool isPartitionKeySuitsGroupByKey(const ReadFromMergeTree & reading, ActionsDAG
|
||||
|
||||
/// We are interested only in calculations required to obtain group by keys.
|
||||
group_by_actions->removeUnusedActions(aggregating.getParams().keys);
|
||||
if (group_by_actions->hasArrayJoin() || group_by_actions->hasStatefulFunctions() /* || group_by_actions->assertDeterministic() */)
|
||||
if (group_by_actions->hasArrayJoin() || group_by_actions->hasStatefulFunctions() || group_by_actions->hasNonDeterministic())
|
||||
return false;
|
||||
const auto & gb_key_required_columns = group_by_actions->getRequiredColumnsNames();
|
||||
|
||||
|
@ -208,3 +208,4 @@ Skip merging: 0
|
||||
Skip merging: 0
|
||||
Skip merging: 1
|
||||
Skip merging: 0
|
||||
Skip merging: 0
|
||||
|
@ -228,3 +228,13 @@ select replaceRegexpOne(explain, '^[ ]*(.*)', '\\1') from (
|
||||
) where explain like '%Skip merging: %';
|
||||
|
||||
drop table t19;
|
||||
|
||||
create table t20(a UInt32, b UInt32) engine=MergeTree order by a partition by a;
|
||||
|
||||
insert into t20 select number, number from numbers_mt(50);
|
||||
|
||||
select replaceRegexpOne(explain, '^[ ]*(.*)', '\\1') from (
|
||||
explain actions=1 select a1 from t20 group by rand(a) as a1
|
||||
) where explain like '%Skip merging: %';
|
||||
|
||||
drop table t20;
|
||||
|
Loading…
Reference in New Issue
Block a user