Skip to content

The range function results in an error when step is a negative number #8311

@smallzhongfeng

Description

@smallzhongfeng

Describe the bug

In the range function, if step is a negative number, since the parameter is specified as usize, step=-1 is converted to 18446744073709551614, which leads to incorrect results.
https://github.com/apache/arrow-datafusion/blob/9619f02db79c794212437415b1e6a53b44eef4c9/datafusion/physical-expr/src/array_expressions.rs#L749C50-L749C51
Therefore, we need to specially handle the case where step is a negative number.

To Reproduce

run :

select range(1, 10, -2) result is [1]

As a comparison:
duckdb
image{width=40px height=30px}

clickhouse
image

Expected behavior

result is []

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions