Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
smallzhongfeng opened this issue Nov 23, 2023 · 1 comment · Fixed by #8313
Closed

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

smallzhongfeng opened this issue Nov 23, 2023 · 1 comment · Fixed by #8313
Labels
bug Something isn't working

Comments

@smallzhongfeng
Copy link
Contributor

smallzhongfeng commented Nov 23, 2023

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

@smallzhongfeng smallzhongfeng added the bug Something isn't working label Nov 23, 2023
@smallzhongfeng
Copy link
Contributor Author

cc @alamb @Veeupup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant