Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 6 additions & 38 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::sync::Arc;
use crate::expr_fn::binary_expr;
use crate::function::WindowFunctionSimplification;
use crate::logical_plan::Subquery;
use crate::Volatility;
use crate::{AggregateUDF, Volatility};
use crate::{ExprSchemable, Operator, Signature, WindowFrame, WindowUDF};

use arrow::datatypes::{DataType, Field, FieldRef};
Expand Down Expand Up @@ -982,7 +982,7 @@ impl<'a> TreeNodeContainer<'a, Expr> for Sort {
#[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)]
pub struct AggregateFunction {
/// Name of the function
pub func: Arc<crate::AggregateUDF>,
pub func: Arc<AggregateUDF>,
pub params: AggregateFunctionParams,
}

Expand All @@ -1001,7 +1001,7 @@ pub struct AggregateFunctionParams {
impl AggregateFunction {
/// Create a new AggregateFunction expression with a user-defined function (UDF)
pub fn new_udf(
func: Arc<crate::AggregateUDF>,
func: Arc<AggregateUDF>,
args: Vec<Expr>,
distinct: bool,
filter: Option<Box<Expr>>,
Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl AggregateFunction {
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
pub enum WindowFunctionDefinition {
/// A user defined aggregate function
AggregateUDF(Arc<crate::AggregateUDF>),
AggregateUDF(Arc<AggregateUDF>),
/// A user defined aggregate function
WindowUDF(Arc<WindowUDF>),
}
Expand Down Expand Up @@ -1088,8 +1088,8 @@ impl Display for WindowFunctionDefinition {
}
}

impl From<Arc<crate::AggregateUDF>> for WindowFunctionDefinition {
fn from(value: Arc<crate::AggregateUDF>) -> Self {
impl From<Arc<AggregateUDF>> for WindowFunctionDefinition {
fn from(value: Arc<AggregateUDF>) -> Self {
Self::AggregateUDF(value)
}
}
Expand Down Expand Up @@ -1173,38 +1173,6 @@ impl Exists {
}
}

/// User Defined Aggregate Function
///
/// See [`crate::udaf::AggregateUDF`] for more information.
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct AggregateUDF {
/// The function
pub fun: Arc<crate::AggregateUDF>,
/// List of expressions to feed to the functions as arguments
pub args: Vec<Expr>,
/// Optional filter
pub filter: Option<Box<Expr>>,
/// Optional ORDER BY applied prior to aggregating
pub order_by: Vec<Expr>,
}

impl AggregateUDF {
/// Create a new AggregateUDF expression
pub fn new(
fun: Arc<crate::AggregateUDF>,
args: Vec<Expr>,
filter: Option<Box<Expr>>,
order_by: Vec<Expr>,
) -> Self {
Self {
fun,
args,
filter,
order_by,
}
}
}

/// InList expression
#[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)]
pub struct InList {
Expand Down