|
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | 17 |
|
| 18 | +//! Window functions provide the ability to perform calculations across |
| 19 | +//! sets of rows that are related to the current query row. |
| 20 | +//! |
| 21 | +//! see also https://www.postgresql.org/docs/current/functions-window.html |
| 22 | +
|
18 | 23 | use super::expressions::{avg_return_type, sum_return_type}; |
19 | 24 | use super::{functions::Signature, type_coercion::data_types}; |
20 | 25 | use crate::error::{DataFusionError, Result}; |
21 | 26 | use crate::physical_plan::aggregates::AggregateFunction; |
22 | | -use arrow::datatypes::{DataType, Schema, TimeUnit}; |
| 27 | +use arrow::datatypes::{DataType, TimeUnit}; |
23 | 28 | use std::{fmt, str::FromStr}; |
24 | 29 |
|
25 | | -/// Window functions provide the ability to perform calculations across sets of rows that are |
26 | | -/// related to the current query row |
27 | | -/// |
28 | | -/// see also https://www.postgresql.org/docs/current/functions-window.html |
| 30 | +/// WindowFunction |
29 | 31 | #[derive(Debug, Clone, PartialEq, Eq)] |
30 | 32 | pub enum WindowFunction { |
31 | 33 | /// window function that leverages an aggregate function |
@@ -60,14 +62,22 @@ impl fmt::Display for WindowFunction { |
60 | 62 | } |
61 | 63 | } |
62 | 64 |
|
| 65 | +/// An aggregate function that is part of a built-in window function |
63 | 66 | #[derive(Debug, Clone, PartialEq, Eq)] |
64 | 67 | pub enum BuiltInWindowFunction { |
| 68 | + /// row number |
65 | 69 | RowNumber, |
| 70 | + /// rank |
66 | 71 | Rank, |
| 72 | + /// dense rank |
67 | 73 | DenseRank, |
| 74 | + /// lag |
68 | 75 | Lag, |
| 76 | + /// lead |
69 | 77 | Lead, |
| 78 | + /// first value |
70 | 79 | FirstValue, |
| 80 | + /// last value |
71 | 81 | LastValue, |
72 | 82 | } |
73 | 83 |
|
|
0 commit comments