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

Functionality of array_repeat udf #13872

Open
jatin510 opened this issue Dec 21, 2024 · 2 comments
Open

Functionality of array_repeat udf #13872

jatin510 opened this issue Dec 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jatin510
Copy link
Contributor

jatin510 commented Dec 21, 2024

Describe the bug

How array_repeat works currently for null as input in array or key:

> SELECT array_repeat(null,0 ) AS repeated_array;
+----------------+
| repeated_array |
+----------------+
| []             |
+----------------+
1 row(s) fetched. 
Elapsed 0.006 seconds.

> SELECT array_repeat(null,1 ) AS repeated_array;
+----------------+
| repeated_array |
+----------------+
| []             |
+----------------+
1 row(s) fetched. 
Elapsed 0.002 seconds.

> SELECT array_repeat(null,2 ) AS repeated_array;
+----------------+
| repeated_array |
+----------------+
| [, ]           |
+----------------+
1 row(s) fetched. 
Elapsed 0.004 seconds.

> SELECT array_repeat(ARRAY[1, 2], null) AS repeated_array;
Internal error: could not cast value to arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::Int64Type>.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
  • if we check this out, the length is also not same,
    but above both look same ?
> SELECT ARRAY_LENGTH(array_repeat(null, 0));

+-------------------------------------------+
| array_length(array_repeat(NULL,Int64(0))) |
+-------------------------------------------+
| 0                                         |
+-------------------------------------------+
1 row(s) fetched. 
Elapsed 0.006 seconds.

> SELECT ARRAY_LENGTH(array_repeat(null, 1));
+-------------------------------------------+
| array_length(array_repeat(NULL,Int64(1))) |
+-------------------------------------------+
| 1                                         |
+-------------------------------------------+

To Reproduce

No response

Expected behavior

  • both are looking same visually. Is thsi desired behaviour ?

No response

Additional context

@jatin510 jatin510 added the bug Something isn't working label Dec 21, 2024
@jayzhan211
Copy link
Contributor

jayzhan211 commented Dec 22, 2024

empty array [] and array of null with len = 1 [] looks the same but they are different, since we don't output null

SELECT array_repeat(ARRAY[1, 2], null)

I think we can return null for this case

@jatin510
Copy link
Contributor Author

I think we can return null for this case

This will be a breaking change.
@jayzhan211
cc: @alamb

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

2 participants