vibesql_executor/evaluator/window/
mod.rs

1//! Window Function Evaluator
2//!
3//! This module implements the core window function evaluation engine that:
4//! - Partitions rows by PARTITION BY expressions
5//! - Sorts partitions by ORDER BY clauses
6//! - Calculates frame boundaries (ROWS mode)
7//! - Evaluates window functions over frames
8//!
9//! # Module Organization
10//!
11//! The window function evaluator is split into logical modules:
12//! - `partitioning` - Partition management and row grouping
13//! - `sorting` - Partition sorting and value comparison
14//! - `frames` - Frame boundary calculation (ROWS mode)
15//! - `ranking` - Ranking functions (ROW_NUMBER, RANK, DENSE_RANK, NTILE)
16//! - `aggregates` - Aggregate window functions (COUNT, SUM, AVG, MIN, MAX)
17//! - `value` - Value access functions (LAG, LEAD, FIRST_VALUE, LAST_VALUE)
18//! - `utils` - Shared utility functions
19
20mod aggregates;
21mod frames;
22mod partitioning;
23mod ranking;
24mod sorting;
25mod utils;
26mod value;
27
28// Re-export public API
29pub use aggregates::{
30    evaluate_avg_window, evaluate_count_window, evaluate_group_concat_window, evaluate_max_window,
31    evaluate_min_window, evaluate_sum_window,
32};
33pub use frames::{calculate_frame, calculate_frame_with_exclusion, validate_frame, FrameResult};
34pub use partitioning::{partition_rows, Partition};
35pub use ranking::{
36    evaluate_cume_dist, evaluate_dense_rank, evaluate_ntile, evaluate_percent_rank, evaluate_rank,
37    evaluate_row_number,
38};
39pub use sorting::{compare_values, sort_partition};
40pub use value::{
41    evaluate_first_value, evaluate_lag, evaluate_last_value, evaluate_lead, evaluate_nth_value,
42};
43
44#[cfg(test)]
45mod tests;