Skip to content

panic: array_position underflows start_from at i64::MIN #22220

@Dandandan

Description

@Dandandan

Describe the bug

array_position panics when the optional start_from argument is i64::MIN. The planner/constant folder subtracts one from the value without checking for underflow.

To Reproduce

EXPLAIN SELECT array_position([1], 1, -9223372036854775808);

Actual behavior

thread 'main' panicked at datafusion/functions-nested/src/position.rs:210:21:
attempt to subtract with overflow

Expected behavior

Return a normal error for an invalid start_from value, not a panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions