Skip to content

Apache DataFusion SQL Query Engine

Fill missing methods in aliased UDF impls (#17080)

Piotr Findeisen9264bb88ab73
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rs
index bd72801372..c8e4e332b0 100644
--- a/datafusion/expr/src/udaf.rs
+++ b/datafusion/expr/src/udaf.rs
@@ -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;
@@ -1059,6 +1056,7 @@ impl AliasedAggregateUDFImpl {
}
}
+#[warn(clippy::missing_trait_methods)] // Delegates, so it should implement every single trait method
impl AggregateUDFImpl for AliasedAggregateUDFImpl {
fn as_any(&self) -> &dyn Any {
self
@@ -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)
}
@@ -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()
}
diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rs
index 1d3f0d2456..f65b6d96cc 100644
--- a/datafusion/expr/src/udf.rs
+++ b/datafusion/expr/src/udf.rs
@@ -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;
@@ -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
@@ -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)
}
diff --git a/datafusion/expr/src/udwf.rs b/datafusion/expr/src/udwf.rs
index 032daa5c25..507e88aad0 100644
--- a/datafusion/expr/src/udwf.rs
+++ b/datafusion/expr/src/udwf.rs
@@ -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;
@@ -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
@@ -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()
}