-
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
Fix get_type for higher-order array functions #13756
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,10 +21,11 @@ use arrow::{ | |||||||||
compute::can_cast_types, | ||||||||||
datatypes::{DataType, TimeUnit}, | ||||||||||
}; | ||||||||||
use datafusion_common::utils::coerced_fixed_size_list_to_list; | ||||||||||
use datafusion_common::{ | ||||||||||
exec_err, internal_datafusion_err, internal_err, plan_err, | ||||||||||
types::{LogicalType, NativeType}, | ||||||||||
utils::{coerced_fixed_size_list_to_list, list_ndims}, | ||||||||||
utils::list_ndims, | ||||||||||
Result, | ||||||||||
}; | ||||||||||
use datafusion_expr_common::{ | ||||||||||
|
@@ -414,7 +415,16 @@ fn get_valid_types( | |||||||||
_ => Ok(vec![vec![]]), | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
fn array(array_type: &DataType) -> Option<DataType> { | ||||||||||
match array_type { | ||||||||||
DataType::List(_) | DataType::LargeList(_) => Some(array_type.clone()), | ||||||||||
DataType::FixedSizeList(field, _) => Some(DataType::List(Arc::clone(field))), | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
_ => None, | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
fn recursive_array(array_type: &DataType) -> Option<DataType> { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we extend the existing array function for nested array instead of creating another signature for nested array There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how to do this, please advise! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't understand -- if the goal is to remove recursive flattening, should we be adding new code to support it 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the pre-existing the recursive type normalization matters for flatten only, cause it (currently) operates recursively and otherwise would need to gain code to handle FixedLengthList inputs the recursive array-ification was useless for other array functions and was made non-recursive. |
||||||||||
match array_type { | ||||||||||
DataType::List(_) | ||||||||||
| DataType::LargeList(_) | ||||||||||
|
@@ -653,6 +663,13 @@ fn get_valid_types( | |||||||||
array(¤t_types[0]) | ||||||||||
.map_or_else(|| vec![vec![]], |array_type| vec![vec![array_type]]) | ||||||||||
} | ||||||||||
ArrayFunctionSignature::RecursiveArray => { | ||||||||||
if current_types.len() != 1 { | ||||||||||
return Ok(vec![vec![]]); | ||||||||||
} | ||||||||||
recursive_array(¤t_types[0]) | ||||||||||
.map_or_else(|| vec![vec![]], |array_type| vec![vec![array_type]]) | ||||||||||
} | ||||||||||
ArrayFunctionSignature::MapArray => { | ||||||||||
if current_types.len() != 1 { | ||||||||||
return Ok(vec![vec![]]); | ||||||||||
|
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.
so this says that if the type is a list, keep the type, but if the type is large list / fixed size list then take the field type?
Why doesn't it also take the field type for
List
🤔 ? (Aka it doesn't make sense to me that List is treated differently than LargeList and FixedSizeListThere 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.
for backwards compat i should keep LargeList so it stays LargeList, will push shortly
not my invention, it was like this before.
i think the intention is "converge List, LL and FSL into one type... or maybe two types... to keep UDF impl simpler".
i am not attached to this approach, but i think code may be reliant on that