Skip to content

Commit

Permalink
Apply cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
timsaucer committed Jul 24, 2024
1 parent 1818efd commit 180e9d3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
7 changes: 4 additions & 3 deletions datafusion-examples/examples/advanced_udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,10 @@ async fn main() -> Result<()> {
df.show().await?;

// Now, run the function using the DataFrame API:
let window_expr = smooth_it.call(vec![col("speed")]) // smooth_it(speed)
.partition_by(vec![col("car")]) // PARTITION BY car
.order_by(vec![col("time").sort(true, true)]) // ORDER BY time ASC
let window_expr = smooth_it
.call(vec![col("speed")]) // smooth_it(speed)
.partition_by(vec![col("car")]) // PARTITION BY car
.order_by(vec![col("time").sort(true, true)]) // ORDER BY time ASC
.window_frame(WindowFrame::new(None))
.build()?;
let df = ctx.table("cars").await?.window(vec![window_expr])?;
Expand Down
7 changes: 4 additions & 3 deletions datafusion-examples/examples/simple_udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ async fn main() -> Result<()> {
df.show().await?;

// Now, run the function using the DataFrame API:
let window_expr = smooth_it.call(vec![col("speed")]) // smooth_it(speed)
.partition_by(vec![col("car")]) // PARTITION BY car
.order_by(vec![col("time").sort(true, true)]) // ORDER BY time ASC
let window_expr = smooth_it
.call(vec![col("speed")]) // smooth_it(speed)
.partition_by(vec![col("car")]) // PARTITION BY car
.order_by(vec![col("time").sort(true, true)]) // ORDER BY time ASC
.window_frame(WindowFrame::new(None))
.build()?;
let df = ctx.table("cars").await?.window(vec![window_expr])?;
Expand Down
3 changes: 1 addition & 2 deletions datafusion/expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.
// Make cheap clones clear: https://github.com/apache/datafusion/issues/11143
#![deny(clippy::clone_on_ref_ptr)]

// TODO When the deprecated trait AggregateExt is removed, remove this unstable feature.
#![feature(trait_alias)]

Expand Down Expand Up @@ -90,9 +89,9 @@ pub use signature::{
};
pub use sqlparser;
pub use table_source::{TableProviderFilterPushDown, TableSource, TableType};
pub use udaf::{AggregateUDF, AggregateUDFImpl, ReversedUDAF};
#[allow(deprecated)]
pub use udaf::AggregateExt;
pub use udaf::{AggregateUDF, AggregateUDFImpl, ReversedUDAF};
pub use udf::{ScalarUDF, ScalarUDFImpl};
pub use udwf::{WindowUDF, WindowUDFImpl};
pub use window_frame::{WindowFrame, WindowFrameBound, WindowFrameUnits};
Expand Down
4 changes: 2 additions & 2 deletions datafusion/expr/src/udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,6 @@ impl AggregateUDFImpl for AggregateUDFLegacyWrapper {
}
}

#[deprecated(since = "40.0.0", note="Use ExprFunctionExt instead.")]
#[deprecated(since = "40.0.0", note = "Use ExprFunctionExt instead.")]
// pub trait AggregateExt : ExprFunctionExt {}
pub trait AggregateExt = ExprFunctionExt;
pub trait AggregateExt = ExprFunctionExt;
4 changes: 1 addition & 3 deletions datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ impl WindowUDF {
///
/// This utility allows using the UDWF without requiring access to
/// the registry, such as with the DataFrame API.
pub fn call(
&self,
args: Vec<Expr>) -> Expr {
pub fn call(&self, args: Vec<Expr>) -> Expr {
let fun = crate::WindowFunctionDefinition::WindowUDF(Arc::new(self.clone()));

Expr::WindowFunction(WindowFunction::new(fun, args))
Expand Down
20 changes: 16 additions & 4 deletions datafusion/expr/src/window_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use crate::{expr::WindowFunction, BuiltInWindowFunction, Expr, Literal};

/// Create an expression to represent the `row_number` window function
pub fn row_number() -> Expr {
Expr::WindowFunction(WindowFunction::new(BuiltInWindowFunction::RowNumber, vec![]))
Expr::WindowFunction(WindowFunction::new(
BuiltInWindowFunction::RowNumber,
vec![],
))
}

/// Create an expression to represent the `rank` window function
Expand All @@ -31,12 +34,18 @@ pub fn rank() -> Expr {

/// Create an expression to represent the `dense_rank` window function
pub fn dense_rank() -> Expr {
Expr::WindowFunction(WindowFunction::new(BuiltInWindowFunction::DenseRank, vec![]))
Expr::WindowFunction(WindowFunction::new(
BuiltInWindowFunction::DenseRank,
vec![],
))
}

/// Create an expression to represent the `percent_rank` window function
pub fn percent_rank() -> Expr {
Expr::WindowFunction(WindowFunction::new(BuiltInWindowFunction::PercentRank, vec![]))
Expr::WindowFunction(WindowFunction::new(
BuiltInWindowFunction::PercentRank,
vec![],
))
}

/// Create an expression to represent the `cume_dist` window function
Expand Down Expand Up @@ -83,5 +92,8 @@ pub fn lead(

/// Create an expression to represent the `nth_value` window function
pub fn nth_value(arg: Expr, n: i64) -> Expr {
Expr::WindowFunction(WindowFunction::new(BuiltInWindowFunction::NthValue, vec![arg, n.lit()]))
Expr::WindowFunction(WindowFunction::new(
BuiltInWindowFunction::NthValue,
vec![arg, n.lit()],
))
}

0 comments on commit 180e9d3

Please sign in to comment.