mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Fix crash with DISTINCT and window functions
This commit is contained in:
parent
c45ebafc70
commit
f8e6614b80
@ -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,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