Skip to content

Bug + Regression: median(null) fails in v54 #24077

Description

@niebayes

SELECT median(NULL) worked in DataFusion v53 (53.1.0) but fails in v54 (54.0.0 / 54.1.0) with:

MedianAccumulator not supported for median(NULL) with Null

This is a regression introduced by PR #21988.

sum, avg and other UDAFs may also have the similar error, not accepting null input.

Root cause

PR #21988 changed median's signature from Signature::numeric to Signature::one_of with three coercible arms. The integer arm uses:

// datafusion/functions-aggregate/src/median.rs
Coercion::new_implicit(
    TypeSignatureClass::Native(logical_float64()),
    vec![TypeSignatureClass::Integer],   // ← should be Numeric
    NativeType::Float64,
),

TypeSignatureClass::Integer does not include DataType::Null, so median(NULL) (whose input is Null) falls through to the accumulator's _ => Err(...) branch.

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions