Adez017 commented on code in PR #66:
URL: https://github.com/apache/datafusion-site/pull/66#discussion_r2029127026


##########
content/blog/2025-04-04-datafusion-userdefined-window-functions.md:
##########
@@ -0,0 +1,154 @@
+---
+layout: post
+title: User defined Window Functions in DataFusion 
+date: 2025-04-04
+author: Aditya Singh Rathore
+categories: [tutorial]
+---
+
+<!--
+{% comment %}
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to you under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+{% endcomment %}
+-->
+
+## Introduction
+Window functions are a powerful feature in SQL, allowing for complex 
analytical computations over a subset of data. However, efficiently 
implementing them, especially sliding windows, can be quite challenging. With 
DataFusion's recent support for user-defined window functions , developers now 
have more flexibility and performance improvements at their disposal.
+
+In this post, we'll explore:
+
+- What window functions are and why they matter
+
+- Understanding sliding windows
+
+- The challenges of computing window aggregates efficiently
+
+- How DataFusion optimizes these computations
+
+- Alternative approaches and their trade-offs
+
+## Understanding Window Functions in SQL 
+
+Imagine you're analyzing sales data and want insights without losing the finer 
details. This is where **window functions** come into play. Unlike **GROUP 
BY**, which condenses data, window functions let you retain each row while 
performing calculations over a defined **range** —like having a moving lens 
over your dataset.
+
+Picture a business tracking daily sales. They need a running total to 
understand cumulative revenue trends without collapsing individual 
transactions. SQL makes this easy:
+```sql
+SELECT id, value, SUM(value) OVER (ORDER BY id) AS running_total
+FROM sales;
+```
+This helps in analytical queries where we need cumulative sums, moving 
averages, or ranking without losing individual records.
+
+
+## User Defined Window Functions
+
+Writing a user defined window function is slightly more complex than an 
aggregate function due
+to the variety of ways that window functions are called. I recommend reviewing 
the
+[online 
documentation](https://datafusion.apache.org/library-user-guide/adding-udfs.html)
+for a description of which functions need to be implemented. The details of 
how to implement
+these generally follow the same patterns as described above for aggregate 
functions.

Review Comment:
   I got your Point , and added  the necessary changes required



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

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