-
Notifications
You must be signed in to change notification settings - Fork 495
[10057] [Planner] Treat empty int2vector as 1 dimensional #34981
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
Conversation
Pre-merge checklist
|
src/repr/src/adt/array.rs
Outdated
| /// Returns true if this array's dimensions are valid for the Int2Vector type. | ||
| /// Int2Vector is 1-D; empty arrays use 0 dimensions (PostgreSQL convention). | ||
| pub fn has_int2vector_dims(array: &Array<'_>) -> bool { | ||
| array.dims().len() == 1 || (array.dims().len() == 0 && array.elements().iter().next().is_none()) | ||
| } | ||
|
|
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.
Can we make this a function on Array? It's hard to keep track of free standing functions, and this seems to be highly specific to arrays.
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.
Sure, there didn't seem to be a ton of function on the Array struct. But I'm happy to move it.
6416405 to
01aa3e6
Compare
09c7f48 to
a0a92bc
Compare
antiguru
left a comment
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.
Looks good, left a minor comment inline. Thank you!
src/repr/src/adt/array.rs
Outdated
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use std::iter; |
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.
Nit: import std::iter::empty as this is the only thing you're using from the module, or write std::iter::empty in all call sites.
Problem: Panic arise in the execution/optimization with empty int2vector's ``` ERROR: internal error: internal error in optimizer: internal transform error int2vector dimensions differ: got datum with dimension 0, expected dimension 1 ``` Solution: Introduce has_int2vector_dims which validates either the array is 1-dimensional, or 0 dimensional, and empty. Use this in 3 places where checked Testing: New tests in int2vector.slt that test empty int2vector's, or rows with empty vector's
a0a92bc to
355857c
Compare
Problem:
Panics arise in the execution/optimization with empty int2vector's
Solution:
Introduce has_int2vector_dims which validates either the array is 1-dimensional, or 0 dimensional, and empty. Use this in 3 places where checked
Testing:
New tests in int2vector.slt that test empty int2vector's, or rows with empty vector's
Motivation
https://github.com/MaterializeInc/database-issues/issues/10057