From 43a57c4f568b0e040ded2ad0f96840f739b71ae1 Mon Sep 17 00:00:00 2001 From: lgbo-ustc Date: Thu, 14 Nov 2024 14:39:14 +0800 Subject: [PATCH] fixed --- src/Processors/Transforms/WindowTransform.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Processors/Transforms/WindowTransform.cpp b/src/Processors/Transforms/WindowTransform.cpp index 216b56e5adb..22a1eb28493 100644 --- a/src/Processors/Transforms/WindowTransform.cpp +++ b/src/Processors/Transforms/WindowTransform.cpp @@ -1546,7 +1546,10 @@ struct WindowFunctionRank final : public StatelessWindowFunction RowNumber firstRequiredRowInFrame(const WindowTransform * transform) const override { - return transform->peer_group_start; + if (transform->window_description.frame.begin_type == WindowFrame::BoundaryType::Unbounded + && transform->window_description.frame.end_type == WindowFrame::BoundaryType::Current) + return transform->peer_group_start; + return transform->frame_start; } }; @@ -1569,7 +1572,10 @@ struct WindowFunctionDenseRank final : public StatelessWindowFunction RowNumber firstRequiredRowInFrame(const WindowTransform * transform) const override { - return transform->peer_group_start; + if (transform->window_description.frame.begin_type == WindowFrame::BoundaryType::Unbounded + && transform->window_description.frame.end_type == WindowFrame::BoundaryType::Current) + return transform->peer_group_start; + return transform->frame_start; } }; @@ -2050,8 +2056,13 @@ struct WindowFunctionRowNumber final : public StatelessWindowFunction RowNumber firstRequiredRowInFrame(const WindowTransform * transform) const override { /// Current block is the only one required to be kept in memory. - auto [row, _] = transform->moveRowNumber(transform->current_row, -1); - return row; + if (transform->window_description.frame.begin_type == WindowFrame::BoundaryType::Unbounded + && transform->window_description.frame.end_type == WindowFrame::BoundaryType::Current) + { + auto [row, _] = transform->moveRowNumber(transform->current_row, -1); + return row; + } + return transform->frame_start; } };