mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #64999 from ClickHouse/backport/24.3/64767
Backport #64767 to 24.3: Fix crash with DISTINCT and window functions
This commit is contained in:
commit
137bbd221e
@ -173,8 +173,12 @@ namespace
|
|||||||
|
|
||||||
if (typeid_cast<const WindowStep *>(current_step))
|
if (typeid_cast<const WindowStep *>(current_step))
|
||||||
{
|
{
|
||||||
actions_chain.push_back(std::move(dag_stack));
|
/// it can be empty in case of 2 WindowSteps following one another
|
||||||
dag_stack.clear();
|
if (!dag_stack.empty())
|
||||||
|
{
|
||||||
|
actions_chain.push_back(std::move(dag_stack));
|
||||||
|
dag_stack.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const auto * const expr = typeid_cast<const ExpressionStep *>(current_step); expr)
|
if (const auto * const expr = typeid_cast<const ExpressionStep *>(current_step); expr)
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
DROP TABLE IF EXISTS atable;
|
||||||
|
|
||||||
|
CREATE TABLE atable
|
||||||
|
(
|
||||||
|
cdu_date Int16,
|
||||||
|
loanx_id String,
|
||||||
|
rating_sp String
|
||||||
|
)
|
||||||
|
ENGINE = MergeTree
|
||||||
|
ORDER BY tuple();
|
||||||
|
|
||||||
|
-- disable parallelization after window function otherwise
|
||||||
|
-- generated pipeline contains enormous number of transformers (should be fixed separately)
|
||||||
|
SET query_plan_enable_multithreading_after_window_functions=0;
|
||||||
|
-- max_threads is randomized, and can significantly increase number of parallel transformers after window func, so set to small value explicitly
|
||||||
|
SET max_threads=3;
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
loanx_id,
|
||||||
|
rating_sp,
|
||||||
|
cdu_date,
|
||||||
|
row_number() OVER (PARTITION BY cdu_date) AS row_number,
|
||||||
|
last_value(cdu_date) OVER (PARTITION BY loanx_id ORDER BY cdu_date ASC) AS last_cdu_date
|
||||||
|
FROM atable
|
||||||
|
GROUP BY
|
||||||
|
cdu_date,
|
||||||
|
loanx_id,
|
||||||
|
rating_sp
|
||||||
|
SETTINGS query_plan_remove_redundant_distinct = 1;
|
||||||
|
|
||||||
|
DROP TABLE atable;
|
Loading…
Reference in New Issue
Block a user