pub trait ExprFunctionExt {
// Required methods
fn order_by(self, order_by: Vec<Sort>) -> ExprFuncBuilder;
fn filter(self, filter: Expr) -> ExprFuncBuilder;
fn distinct(self) -> ExprFuncBuilder;
fn null_treatment(
self,
null_treatment: impl Into<Option<NullTreatment>>,
) -> ExprFuncBuilder;
fn partition_by(self, partition_by: Vec<Expr>) -> ExprFuncBuilder;
fn window_frame(self, window_frame: WindowFrame) -> ExprFuncBuilder;
}
Expand description
Extensions for configuring Expr::AggregateFunction
or Expr::WindowFunction
Adds methods to Expr
that make it easy to set optional options
such as ORDER BY
, FILTER
and DISTINCT
§Example
unimplemented!() }
// Create an aggregate count, filtering on column y > 5
let agg = count(col("x")).filter(col("y").gt(lit(5))).build()?;
// Find the first value in an aggregate sorted by column y
// equivalent to:
// `FIRST_VALUE(x ORDER BY y ASC IGNORE NULLS)`
let sort_expr = col("y").sort(true, true);
let agg = first_value(col("x"))
.order_by(vec![sort_expr])
.null_treatment(NullTreatment::IgnoreNulls)
.build()?;
// Create a window expression for percent rank partitioned on column a
// equivalent to:
// `PERCENT_RANK() OVER (PARTITION BY a ORDER BY b ASC NULLS LAST IGNORE NULLS)`
// percent_rank is an udwf function in another crate
unimplemented!() }
let window = percent_rank()
.partition_by(vec![col("a")])
.order_by(vec![col("b").sort(true, true)])
.null_treatment(NullTreatment::IgnoreNulls)
.build()?;
Required Methods§
Sourcefn order_by(self, order_by: Vec<Sort>) -> ExprFuncBuilder
fn order_by(self, order_by: Vec<Sort>) -> ExprFuncBuilder
Add ORDER BY <order_by>
Sourcefn filter(self, filter: Expr) -> ExprFuncBuilder
fn filter(self, filter: Expr) -> ExprFuncBuilder
Add FILTER <filter>
Sourcefn distinct(self) -> ExprFuncBuilder
fn distinct(self) -> ExprFuncBuilder
Add DISTINCT
Sourcefn null_treatment(
self,
null_treatment: impl Into<Option<NullTreatment>>,
) -> ExprFuncBuilder
fn null_treatment( self, null_treatment: impl Into<Option<NullTreatment>>, ) -> ExprFuncBuilder
Add RESPECT NULLS
or IGNORE NULLS
Sourcefn partition_by(self, partition_by: Vec<Expr>) -> ExprFuncBuilder
fn partition_by(self, partition_by: Vec<Expr>) -> ExprFuncBuilder
Add PARTITION BY
Sourcefn window_frame(self, window_frame: WindowFrame) -> ExprFuncBuilder
fn window_frame(self, window_frame: WindowFrame) -> ExprFuncBuilder
Add appropriate window frame conditions
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.