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

select array_concat([]) panicked #10200

Closed
jonahgao opened this issue Apr 23, 2024 · 9 comments
Closed

select array_concat([]) panicked #10200

jonahgao opened this issue Apr 23, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@jonahgao
Copy link
Member

Describe the bug

thread 'main' panicked at datafusion/datafusion/functions-array/src/concat.rs:275:32:
index out of bounds: the len is 0 but the index is 0

To Reproduce

Run any of the following queries in CLI.

DataFusion CLI v37.1.0
> select array_concat([]);
DataFusion CLI v37.1.0
>  select array_concat(make_array());

Expected behavior

No response

Additional context

No response

@jonahgao jonahgao added the bug Something isn't working label Apr 23, 2024
@Lordworms
Copy link
Contributor

I can fix this one if no one is working on this

@jayzhan211
Copy link
Contributor

jayzhan211 commented Apr 23, 2024

@Lordworms Not sure what is your idea to solve this problem. I expect this to be solved with the correct signature.
I had worked on #8594 before but the solution is quite a specialized case. If you come out with another better idea, it would be great!

@Lordworms
Copy link
Contributor

Lordworms commented Apr 24, 2024

select array_concat(make_array());

Hi @jayzhan211 I was going to implement the same behavior like DuckDB
image
I could directly check the returnType here do match the behavior of DuckDB
image

and make datafusion support query like
image
Don't know if it could meet the issue's need

@jayzhan211
Copy link
Contributor

@Lordworms
I think arguments validity check are more like signature instead of one that need to be computed by the user in return_type.

@Lordworms
Copy link
Contributor

Lordworms commented Apr 24, 2024

@Lordworms I think arguments validity check are more like signature instead of one that need to be computed by the

Yes, I understand, but if we need to validate argument in signature a suitable way to do it is more likely what you did in #8594

user in return_type.

I'll try to see if I can come up with a better way, thanks for your advice!

@jayzhan211
Copy link
Contributor

After #10439, I believe array_concat should use user-defined signature given it's speciality, therefore we can check the empty array in coerce_types for array_concat and return exec_error instead of panicking

cc @Lordworms

@jayzhan211
Copy link
Contributor

I have a PR that updates the array_concat signature, maybe I can resolve the panic issue together.

@jayzhan211
Copy link
Contributor

Actually, I'm thinking about whether we should change the behavior of array_concat similar to postgres and duckdb.
It is one of the earliest array functions that we don't follow what postgres and duckdb's behavior 🤔

@jonahgao
Copy link
Member Author

jonahgao commented Jun 6, 2024

Fixed by #10790

@jonahgao jonahgao closed this as completed Jun 6, 2024
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

No branches or pull requests

3 participants