Window Functions: Session Ranking — This or that? ...
# announcements
c
Window Functions: Session Ranking — This or that? How do you perform a session ranking WITHOUT window functions? 1. A self-join to compare each session with all other sessions 2. Filtering to count sessions with more chocolates 3. Grouping and aggregating to calculate the rank 4. Joining back to the original data 5. Handling nulls for top-ranked sessions ❌ Complex, error-prone, and hard to understand at a glance. How about WITH window functions? 1. Define a window partitioned by contestant and ordered by chocolates (descending) 2. Apply the
dense_rank()
function over this window (https://www.getdaft.io/projects/docs/en/stable/api/window/#daft.functions.dense_rank) ✅ All the comparison logic is handled internally, code is more concise and more efficient. Check out our documentation and try out Daft's window functions yourself! https://www.getdaft.io/projects/docs/en/stable/core_concepts/#window-functions