Skip to content

feat: deprecate AggregateUDFImpl::is_nullable in favour of return_field - #26746

Open
CuteChuanChuan wants to merge 1 commit into
apache:mainfrom
CuteChuanChuan:issue-18882/deprecate-isnullable-aggregateudf
Open

CuteChuanChuan wants to merge 1 commit into
apache:mainfrom
CuteChuanChuan:issue-18882/deprecate-isnullable-aggregateudf

Conversation

@CuteChuanChuan

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

An aggregate's nullability is described twice: by AggregateUDFImpl::is_nullable and by the field returned from AggregateUDFImpl::return_field. AggregateFunctionExpr stored both, so is_nullable() and field().is_nullable() could disagree. This makes return_field the single source of truth, following #17074 for scalar UDFs.

What changes are included in this PR?

  • Deprecate AggregateUDFImpl::is_nullable and AggregateUDF::is_nullable (since 56.0.0).
  • AggregateExprBuilder::build now derives is_nullable from the return field.
  • Migrate the built-in overrides (count, approx_distinct, regr_*) and the Count test stub to return_field.
  • FFI: keep the FFI_AggregateUDF::is_nullable field for ABI stability and silence the deprecation warning; it can be removed together with the method.

This addresses the review feedback on #18934.

What is the testing strategy for this PR?

Covered by existing tests.

Are there any user-facing changes?

Yes. Implementations overriding is_nullable should set nullability in return_field instead.

@github-actions github-actions Bot added documentation Improvements or additions to documentation logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates functions Changes to functions implementation ffi Changes to the ffi crate labels Oct 25, 2026
@github-actions

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning 36f393559620235c250f68727e3243cc7f429db8
    Building datafusion-expr v55.1.0 (current)
       Built [  35.529s] (current)
     Parsing datafusion-expr v55.1.0 (current)
      Parsed [   0.108s] (current)
    Building datafusion-expr v55.1.0 (baseline)
       Built [   7.839s] (baseline)
     Parsing datafusion-expr v55.1.0 (baseline)
      Parsed [   0.111s] (baseline)
    Checking datafusion-expr v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   1.608s] 229 checks: 227 pass, 2 fail, 0 warn, 31 skip

--- failure trait_method_marked_deprecated: trait method #[deprecated] added ---

Description:
A trait method is now #[deprecated]. Downstream crates will get a compiler warning when using this method.
        ref: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/trait_method_marked_deprecated.ron

Failed in:
  method is_nullable in trait datafusion_expr::AggregateUDFImpl in /home/runner/work/datafusion/datafusion/datafusion/expr/src/udaf.rs:461

--- failure type_method_marked_deprecated: type method #[deprecated] added ---

Description:
A type method is now #[deprecated]. Downstream crates will get a compiler warning when using this method.
        ref: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/type_method_marked_deprecated.ron

Failed in:
  method datafusion_expr::AggregateUDF::is_nullable in /home/runner/work/datafusion/datafusion/datafusion/expr/src/udaf.rs:212

     Summary semver requires new minor version: 0 major and 2 minor checks failed
    Finished [  46.585s] datafusion-expr
    Building datafusion-ffi v55.1.0 (current)
       Built [  50.865s] (current)
     Parsing datafusion-ffi v55.1.0 (current)
      Parsed [   0.073s] (current)
    Building datafusion-ffi v55.1.0 (baseline)
       Built [  22.027s] (baseline)
     Parsing datafusion-ffi v55.1.0 (baseline)
      Parsed [   0.072s] (baseline)
    Checking datafusion-ffi v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.276s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  74.870s] datafusion-ffi
    Building datafusion-functions-aggregate v55.1.0 (current)
       Built [  11.675s] (current)
     Parsing datafusion-functions-aggregate v55.1.0 (current)
      Parsed [   0.057s] (current)
    Building datafusion-functions-aggregate v55.1.0 (baseline)
       Built [   8.118s] (baseline)
     Parsing datafusion-functions-aggregate v55.1.0 (baseline)
      Parsed [   0.059s] (baseline)
    Checking datafusion-functions-aggregate v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.189s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [  21.168s] datafusion-functions-aggregate
    Building datafusion-physical-expr v55.1.0 (current)
       Built [   3.791s] (current)
     Parsing datafusion-physical-expr v55.1.0 (current)
      Parsed [   0.058s] (current)
    Building datafusion-physical-expr v55.1.0 (baseline)
       Built [   3.906s] (baseline)
     Parsing datafusion-physical-expr v55.1.0 (baseline)
      Parsed [   0.060s] (baseline)
    Checking datafusion-physical-expr v55.1.0 -> v55.1.0 (no change; assume patch)
     Checked [   0.343s] 229 checks: 229 pass, 31 skip
     Summary no semver update required
    Finished [   9.516s] datafusion-physical-expr

@github-actions github-actions Bot added the auto detected api change Auto detected API change label Oct 25, 2026
@CuteChuanChuan

Copy link
Copy Markdown
Contributor Author

Hi @Jefffrey,

could you PTAL when you have a chance? Thanks 🙏!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change documentation Improvements or additions to documentation ffi Changes to the ffi crate functions Changes to functions implementation logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate AggregateUDFImpl::is_nullable in favour of return_field

1 participant