wangzaixiang opened a new issue, #15714:
URL: https://github.com/apache/datafusion/issues/15714

   ### Describe the bug
   
   It looks the current range frame defines as 
   
   <img width="807" alt="Image" 
src="https://github.com/user-attachments/assets/0fae7808-890c-48d3-b88b-ff19df19a50e";
 />
   
   but the range should defines as: from [MySQL 
spec](https://dev.mysql.com/doc/refman/8.0/en/window-functions-frames.html)
   
   ```
   frame_extent:
       {frame_start | frame_between}
   
   frame_between:
       BETWEEN frame_start AND frame_end
   
   frame_start, frame_end: {
       CURRENT ROW
     | UNBOUNDED PRECEDING
     | UNBOUNDED FOLLOWING
     | expr PRECEDING
     | expr FOLLOWING
   }
   ```
   
   for example, if we aggregate on a date window( the last month's measure), we 
can sql like
   
   ```sql
   select so.shop_id, date_trunc('month', so.order_date) as month, 
count(distinct si.sale_order_id) as cnt_orders, 
        sum(quantity) as quantities, sum(amount) as amounts,
        first_value( count(distinct si.sale_order_id) ) over w as l1
   from sale_items si 
   left join sale_orders so on so.sale_order_id = si.sale_order_id
   group by so.shop_id, date_trunc('month', so.order_date)
   window w as ( partition by so.shop_id order by date_trunc('month', 
so.order_date) 
        range between interval 31 days PRECEDING and interval 1 days preceding )
   order by so.shop_id, date_trunc('month', so.order_date);
   ```
   
   ### To Reproduce
   
   _No response_
   
   ### Expected behavior
   
   _No response_
   
   ### Additional context
   
   _No response_


-- 
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: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to