luwei16 commented on code in PR #8877:
URL: https://github.com/apache/incubator-doris/pull/8877#discussion_r857558808


##########
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);
+            is_set_frame_start = true;
+        }
+        frame_end = std::min<int64_t>(frame_end, partition_end);
+
+        if (this->frame_start + offset > frame_end) {
+            this->set_is_null();

Review Comment:
   > Maybe this is the case: window is above partition_start or under 
partition_end, should be null also
   
   this->frame_start = std::max<int64_t>(frame_start, partition_start);
   frame_end = std::min<int64_t>(frame_end, partition_end); 
   
   Because of these two statements, the window must be inside the partition, so 
the above case should be no problem



-- 
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

Reply via email to