Skip to content

Commit

Permalink
Minior: Add example comment on window expr
Browse files Browse the repository at this point in the history
  • Loading branch information
caicancai committed Feb 16, 2024
1 parent e07a79c commit 1e98213
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions datafusion/core/src/dataframe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,20 @@ impl DataFrame {

/// Return a new DataFrame that adds the result of evaluating one or more
/// window functions ([`Expr::WindowFunction`]) to the existing columns
/// # Example
/// ```
/// # use datafusion::prelude::*;
/// # use datafusion::error::Result;
/// # #[tokio::main]
/// # async fn main() -> Result<()> {
/// let ctx = SessionContext::new();
/// let df = ctx.read_csv("tests/data/example.csv", CsvReadOptions::new()).await?;
///
/// let window_expr = vec![min(col("b"))];
/// let _ = df.window(window_expr)?;
/// # Ok(())
/// # }
/// ```
pub fn window(self, window_exprs: Vec<Expr>) -> Result<DataFrame> {
let plan = LogicalPlanBuilder::from(self.plan)
.window(window_exprs)?
Expand Down

0 comments on commit 1e98213

Please sign in to comment.