luwei16 commented on code in PR #8877: URL: https://github.com/apache/incubator-doris/pull/8877#discussion_r857581933
########## be/src/vec/aggregate_functions/aggregate_function_window.h: ########## @@ -363,6 +363,47 @@ struct WindowFunctionLastData : Data { static const char* name() { return "last_value"; } }; +template <typename Data> +struct WindowFunctionNthData : Data { + void add_range_single_place(int64_t partition_start, int64_t partition_end, int64_t frame_start, + int64_t frame_end, const IColumn** columns) { + int64_t offset = columns[1]->get64(partition_start); + if (this->has_set_value()) { + return; + } + + if (!is_set_frame_start) { + this->frame_start = std::max<int64_t>(frame_start, partition_start); Review Comment: The frame_start parameter is not the real window start, only when reset is called, frame_start is equal to the real window start, so I use this->frame_start to save the real window start value Below is an example the simple table is: |class | id | score| 1 1 80 1 2 90 1 3 70 1 4 95 the sql is: select class_id, student_id, score, nth_value(id, 3) over (partition by class order by score desc) as 'nth' from table The parameters for add_range_single_place to run four times are: partition_start partition_end frame_start frame_end 0 4 0 1 0 4 1 2 0 4 2 3 0 4 3 4 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org