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

Difference in behaviour of Array with psql: multidimensional arrays must have array expressions with matching dimensions #8217

Closed
jon-chuang opened this issue Feb 28, 2023 · 4 comments
Labels
type/bug Something isn't working
Milestone

Comments

@jon-chuang
Copy link
Contributor

jon-chuang commented Feb 28, 2023

Describe the bug

psql

> select ARRAY[ARRAY[1], ARRAY[2, 3]];
ERROR:  multidimensional arrays must have array expressions with matching dimensions

risingwave

> select ARRAY[ARRAY[1], ARRAY[2, 3]];
    array    
-------------
 {{1},{2,3}}
(1 row)

To Reproduce

as above

Expected behavior

Should we be same as psql? Some users may have some nested list data without matching dim assumption. However, in this case, could they use jsonb as opposed to array?

We need the behaviour to be consistent at least for the purpose of implementing array_upper.

Additional context

Related: #8201
No response

@jon-chuang jon-chuang added the type/bug Something isn't working label Feb 28, 2023
@github-actions github-actions bot added this to the release-0.1.18 milestone Feb 28, 2023
@jon-chuang jon-chuang changed the title Difference in behaviour of Array with psql Difference in behaviour of Array with psql: multidimensional arrays must have array expressions with matching dimensions Feb 28, 2023
@jon-chuang
Copy link
Contributor Author

jon-chuang commented Feb 28, 2023

@xiangjinwu has suggested that we do not follow a C-type fixed dim semantic as psql does, but always allow a dynamic length.

We should figure out what our multi-dim array functions should do if we implement them. (e.g. array_ndims, array_dims, array_upper, array_lower)

Note that array_upper, array_lower have little meaning in our case, as array_lower == 1 and array_upper == array_length, since we currently do not support shifting the indexes (e.g. '[3:7]={1,1,1,1,1}'::integer[]).

@jon-chuang
Copy link
Contributor Author

Note that jsonb can handle non-matching dims (as well as arrays with any type e.g. Any::[] )

select '[[1], [2, 3]]'::jsonb;
     jsonb     
---------------
 [[1], [2, 3]]
(1 row)

@xxchan
Copy link
Member

xxchan commented Feb 28, 2023

#3811

@xxchan
Copy link
Member

xxchan commented Mar 21, 2023

close as duplicate

@xxchan xxchan closed this as not planned Won't fix, can't repro, duplicate, stale Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants