Skip to content

LEAD/LAG IGNORE NULLS panics without a null bitmap #23705

Description

@xudong963

Describe the bug

The whole-partition evaluation path for LEAD and LAG with IGNORE NULLS calls array.nulls().unwrap(). Arrow arrays containing no null values commonly omit the null bitmap, so evaluating either function on such an array panics.

To Reproduce

Evaluate LEAD or LAG with IGNORE NULLS through PartitionEvaluator::evaluate_all using an array constructed without nulls, for example:

let array = Int32Array::from(vec![1, 2, 3]);
assert!(array.nulls().is_none());

The evaluation panics with:

called `Option::unwrap()` on a `None` value

Expected behavior

IGNORE NULLS should behave like the regular shift when the input contains no null values, returning the expected LEAD or LAG result without requiring a null bitmap.

Additional context

The panic is in evaluate_all_with_ignore_null in datafusion/functions-window/src/lead_lag.rs.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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