Skip to content

Commit a6d18ef

Browse files
author
Jiayu Liu
committed
adding more docs
1 parent e6698ee commit a6d18ef

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

datafusion/src/logical_plan/expr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ pub enum Expr {
191191
/// Whether this is a DISTINCT aggregation or not
192192
distinct: bool,
193193
},
194+
/// Represents the call of a window function with arguments.
194195
WindowFunction {
195196
/// Name of the function
196197
fun: windows::WindowFunction,

datafusion/src/optimizer/hash_build_probe_order.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ fn get_num_rows(logical_plan: &LogicalPlan) -> Option<usize> {
5454
let num_rows_input = get_num_rows(input);
5555
num_rows_input.map(|rows| std::cmp::min(*limit, rows))
5656
}
57-
LogicalPlan::Window { .. } | LogicalPlan::Aggregate { .. } => {
57+
LogicalPlan::Window { input, .. } => get_num_rows(input),
58+
LogicalPlan::Aggregate { .. } => {
5859
// we cannot yet predict how many rows will be produced by an aggregate or a window because
5960
// we do not know the cardinality of the grouping keys
6061
None

datafusion/src/physical_plan/windows.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

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+
1823
use super::expressions::{avg_return_type, sum_return_type};
1924
use super::{functions::Signature, type_coercion::data_types};
2025
use crate::error::{DataFusionError, Result};
2126
use crate::physical_plan::aggregates::AggregateFunction;
22-
use arrow::datatypes::{DataType, Schema, TimeUnit};
27+
use arrow::datatypes::{DataType, TimeUnit};
2328
use std::{fmt, str::FromStr};
2429

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
2931
#[derive(Debug, Clone, PartialEq, Eq)]
3032
pub enum WindowFunction {
3133
/// window function that leverages an aggregate function
@@ -60,14 +62,22 @@ impl fmt::Display for WindowFunction {
6062
}
6163
}
6264

65+
/// An aggregate function that is part of a built-in window function
6366
#[derive(Debug, Clone, PartialEq, Eq)]
6467
pub enum BuiltInWindowFunction {
68+
/// row number
6569
RowNumber,
70+
/// rank
6671
Rank,
72+
/// dense rank
6773
DenseRank,
74+
/// lag
6875
Lag,
76+
/// lead
6977
Lead,
78+
/// first value
7079
FirstValue,
80+
/// last value
7181
LastValue,
7282
}
7383

0 commit comments

Comments
 (0)