Skip to content

Commit 100e9b7

Browse files
committed
deprecate AggregateUDF::is_nullable
1 parent 6ea305e commit 100e9b7

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

datafusion/expr/src/expr_schema.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,9 @@ impl ExprSchemable for Expr {
353353
let (_, nullable) = self.data_type_and_nullable(input_schema)?;
354354
Ok(nullable)
355355
}
356-
Expr::AggregateFunction(AggregateFunction { func, .. }) => {
357-
Ok(func.is_nullable())
356+
Expr::AggregateFunction(_) => {
357+
let (_, nullable) = self.data_type_and_nullable(input_schema)?;
358+
Ok(nullable)
358359
}
359360
Expr::WindowFunction(window_function) => self
360361
.data_type_and_nullable_with_window_function(

datafusion/expr/src/udaf.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl AggregateUDF {
209209
}
210210

211211
pub fn is_nullable(&self) -> bool {
212+
#[allow(deprecated)]
212213
self.inner.is_nullable()
213214
}
214215

@@ -532,6 +533,10 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {
532533
/// For example, aggregate functions like `COUNT` always return a non null value
533534
/// but others like `MIN` will return `NULL` if there is nullable input.
534535
/// Note that if the function is declared as *not* nullable, make sure the [`AggregateUDFImpl::default_value`] is `non-null`
536+
#[deprecated(
537+
since = "51.0.0",
538+
note = "Use `return_field` instead with return_field.is_nullable()."
539+
)]
535540
fn is_nullable(&self) -> bool {
536541
true
537542
}
@@ -1100,7 +1105,10 @@ pub fn udaf_default_return_field<F: AggregateUDFImpl + ?Sized>(
11001105
Ok(Arc::new(Field::new(
11011106
func.name(),
11021107
data_type,
1103-
func.is_nullable(),
1108+
#[allow(deprecated)]
1109+
{
1110+
func.is_nullable()
1111+
},
11041112
)))
11051113
}
11061114

@@ -1247,6 +1255,7 @@ impl AggregateUDFImpl for AliasedAggregateUDFImpl {
12471255
}
12481256

12491257
fn is_nullable(&self) -> bool {
1258+
#[allow(deprecated)]
12501259
self.inner.is_nullable()
12511260
}
12521261

datafusion/physical-expr/src/aggregate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl AggregateExprBuilder {
222222
)?;
223223

224224
let return_field = fun.return_field(&input_exprs_fields)?;
225-
let is_nullable = fun.is_nullable();
225+
let is_nullable = return_field.is_nullable();
226226
let name = match alias {
227227
None => {
228228
return internal_err!(

0 commit comments

Comments
 (0)