Skip to content
Merged
Show file tree
Hide file tree
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
60 changes: 56 additions & 4 deletions datafusion/expr/src/udaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,6 @@ where
/// let expr = geometric_mean.call(vec![col("a")]);
/// ```
pub trait AggregateUDFImpl: Debug + Send + Sync {
// Note: When adding any methods (with default implementations), remember to add them also
// into the AliasedAggregateUDFImpl below!

/// Returns this object as an [`Any`] trait object
fn as_any(&self) -> &dyn Any;

Expand Down Expand Up @@ -1059,6 +1056,7 @@ impl AliasedAggregateUDFImpl {
}
}

#[warn(clippy::missing_trait_methods)] // Delegates, so it should implement every single trait method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️
TIL missing_trait_methods 👍

impl AggregateUDFImpl for AliasedAggregateUDFImpl {
fn as_any(&self) -> &dyn Any {
self
Expand All @@ -1084,6 +1082,32 @@ impl AggregateUDFImpl for AliasedAggregateUDFImpl {
&self.aliases
}

fn schema_name(&self, params: &AggregateFunctionParams) -> Result<String> {
self.inner.schema_name(params)
}

fn human_display(&self, params: &AggregateFunctionParams) -> Result<String> {
self.inner.human_display(params)
}

fn window_function_schema_name(
&self,
params: &WindowFunctionParams,
) -> Result<String> {
self.inner.window_function_schema_name(params)
}

fn display_name(&self, params: &AggregateFunctionParams) -> Result<String> {
self.inner.display_name(params)
}

fn window_function_display_name(
&self,
params: &WindowFunctionParams,
) -> Result<String> {
self.inner.window_function_display_name(params)
}

fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<FieldRef>> {
self.inner.state_fields(args)
}
Expand Down Expand Up @@ -1138,12 +1162,40 @@ impl AggregateUDFImpl for AliasedAggregateUDFImpl {
self.inner.coerce_types(arg_types)
}

udf_equals_hash!(AggregateUDFImpl);
fn return_field(&self, arg_fields: &[FieldRef]) -> Result<FieldRef> {
self.inner.return_field(arg_fields)
}

fn is_nullable(&self) -> bool {
self.inner.is_nullable()
}

fn is_descending(&self) -> Option<bool> {
self.inner.is_descending()
}

fn value_from_stats(&self, statistics_args: &StatisticsArgs) -> Option<ScalarValue> {
self.inner.value_from_stats(statistics_args)
}

fn default_value(&self, data_type: &DataType) -> Result<ScalarValue> {
self.inner.default_value(data_type)
}

fn supports_null_handling_clause(&self) -> bool {
self.inner.supports_null_handling_clause()
}

fn is_ordered_set_aggregate(&self) -> bool {
self.inner.is_ordered_set_aggregate()
}

fn set_monotonicity(&self, data_type: &DataType) -> SetMonotonicity {
self.inner.set_monotonicity(data_type)
}

udf_equals_hash!(AggregateUDFImpl);

fn documentation(&self) -> Option<&Documentation> {
self.inner.documentation()
}
Expand Down
9 changes: 6 additions & 3 deletions datafusion/expr/src/udf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,6 @@ pub struct ReturnFieldArgs<'a> {
/// let expr = add_one.call(vec![col("a")]);
/// ```
pub trait ScalarUDFImpl: Debug + Send + Sync {
// Note: When adding any methods (with default implementations), remember to add them also
// into the AliasedScalarUDFImpl below!

/// Returns this object as an [`Any`] trait object
fn as_any(&self) -> &dyn Any;

Expand Down Expand Up @@ -765,6 +762,7 @@ impl AliasedScalarUDFImpl {
}
}

#[warn(clippy::missing_trait_methods)] // Delegates, so it should implement every single trait method
impl ScalarUDFImpl for AliasedScalarUDFImpl {
fn as_any(&self) -> &dyn Any {
self
Expand Down Expand Up @@ -794,6 +792,11 @@ impl ScalarUDFImpl for AliasedScalarUDFImpl {
self.inner.return_field_from_args(args)
}

fn is_nullable(&self, args: &[Expr], schema: &dyn ExprSchema) -> bool {
#[allow(deprecated)]
self.inner.is_nullable(args, schema)
}

fn invoke_with_args(&self, args: ScalarFunctionArgs) -> Result<ColumnarValue> {
self.inner.invoke_with_args(args)
}
Expand Down
8 changes: 5 additions & 3 deletions datafusion/expr/src/udwf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,6 @@ where
/// .unwrap();
/// ```
pub trait WindowUDFImpl: Debug + Send + Sync {
// Note: When adding any methods (with default implementations), remember to add them also
// into the AliasedWindowUDFImpl below!

/// Returns this object as an [`Any`] trait object
fn as_any(&self) -> &dyn Any;

Expand Down Expand Up @@ -500,6 +497,7 @@ impl AliasedWindowUDFImpl {
}
}

#[warn(clippy::missing_trait_methods)] // Delegates, so it should implement every single trait method
impl WindowUDFImpl for AliasedWindowUDFImpl {
fn as_any(&self) -> &dyn Any {
self
Expand Down Expand Up @@ -549,6 +547,10 @@ impl WindowUDFImpl for AliasedWindowUDFImpl {
self.inner.coerce_types(arg_types)
}

fn reverse_expr(&self) -> ReversedUDWF {
self.inner.reverse_expr()
}

fn documentation(&self) -> Option<&Documentation> {
self.inner.documentation()
}
Expand Down