mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 18:42:26 +00:00
Fix crash with DISTINCT and window functions
This commit is contained in:
parent
c45ebafc70
commit
f8e6614b80
@ -172,10 +172,14 @@ namespace
|
||||
}
|
||||
|
||||
if (typeid_cast<const WindowStep *>(current_step))
|
||||
{
|
||||
/// it can be empty in case of 2 WindowSteps following one another
|
||||
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)
|
||||
dag_stack.push_back(expr->getExpression());
|
||||
|
@ -0,0 +1,25 @@
|
||||
DROP TABLE IF EXISTS atable;
|
||||
|
||||
CREATE TABLE atable
|
||||
(
|
||||
cdu_date Int16,
|
||||
loanx_id String,
|
||||
rating_sp String
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY tuple();
|
||||
|
||||
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