-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
'array_repeat' if the repeat count value is 0, return NULL instead of empty array #14046
'array_repeat' if the repeat count value is 0, return NULL instead of empty array #14046
Conversation
I think we should fix it on the display/formatting side. For example, we still cannot distinguish:
See #13872 (comment) |
makes sense,
This will make changes everywhere. |
Display |
Why haven’t we been displaying |
I guess it's to follow PostgreSQL CLI. PostgreSQL CLI does not display null values as well, but it always displays null elements of arrays as NULL. $ psql
psql (16.6 (Ubuntu 16.6-0ubuntu0.24.04.1))
Type "help" for help.
psql=> select null, array[null, 1, null];
?column? | array
----------+---------------
| {NULL,1,NULL}
(1 row)
psql=> \pset null mynull
Null display is "mynull".
psql=> select null, array[null, 1, null];
?column? | array
----------+---------------
mynull | {NULL,1,NULL}
(1 row) I think we can follow PostgreSQL more thoroughly, or always display null, regardless of whether it is a list element. The fix should not involve the DataFusion core; it should be related to DataFusion CLI and sqllogictests. DataFusion CLI v44.0.0
> select array[null, null, null,1,null];
+------------------------------------------+
| make_array(NULL,NULL,NULL,Int64(1),NULL) |
+------------------------------------------+
| [, , , 1, ] |
+------------------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds. |
Created a different PR as this is related to specific array udf. Thanks, @jonahgao @jayzhan211 for your valuable feedback. |
Which issue does this PR close?
Closes #13872.
Rationale for this change
We noticed that,
Array of null: []
Empty array: []
Appears same
To distinguish both,
Updated the
empty array
to returnnull
insteadArray of null: []
Empty array will return: null
Now,
What changes are included in this PR?
Are these changes tested?
Yes,
Updated the
array.slt
fileAre there any user-facing changes?
Yes
It has breaking change. Please add the label
api change