-
Notifications
You must be signed in to change notification settings - Fork 480
Allow null values in multi-dimensional arrays #33786
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
base: main
Are you sure you want to change the base?
Conversation
This should likely come with changes to |
Allow constructing multi-dimensional arrays with null values instead of panicking. Similarly to PostgreSQL, treat null elements as zero-dimensional arrays. Fixes MaterializeInc/database-issues#9757 Signed-off-by: Moritz Hoffmann <[email protected]>
51d12bf
to
7d71bbc
Compare
Signed-off-by: Moritz Hoffmann <[email protected]>
I understand but I don't know what needs to be true for an array datum to be instances of |
let actual = a.length; | ||
let expected = e.length; | ||
// All input arrays must have the same dimensionality. | ||
return Err(InvalidArrayError::WrongCardinality { actual, expected }.into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might need another error variant to be precise, but I feel we're good with the current one being used in two different contexts (length vs. dims).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Postgres also checks for the lower bound being the same, even if the lengths are the same and it also produces a more generic error message than us:
postgres=# SELECT ARRAY['[0:0]={1}'::int[], '[1:1]={2}'::int[]];
ERROR: multidimensional arrays must have array expressions with matching dimensions
What do you think of changing our error variant to give the same generic error message and then here we just do a simple if actual_dims != expected_dims { ... }
?
See materialize/src/repr/src/scalar.rs Lines 1198 to 1211 in 362c175
It seems the dimensions don't matter (unless you're dealing with int2vec weirdness). |
Allow constructing multi-dimensional arrays with null values instead of panicking. Similarly to PostgreSQL, treat null elements as zero-dimensional arrays.
Fixes MaterializeInc/database-issues#9757