-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support MIN and MAX for DataType::List
#16025
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
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 |
|---|---|---|
|
|
@@ -616,7 +616,8 @@ fn min_batch(values: &ArrayRef) -> Result<ScalarValue> { | |
| min_binary_view | ||
| ) | ||
| } | ||
| DataType::Struct(_) => min_max_batch_struct(values, Ordering::Greater)?, | ||
| DataType::Struct(_) => min_max_batch_generic(values, Ordering::Greater)?, | ||
| DataType::List(_) => min_max_batch_generic(values, Ordering::Greater)?, | ||
| DataType::Dictionary(_, _) => { | ||
| let values = values.as_any_dictionary().values(); | ||
| min_batch(values)? | ||
|
|
@@ -625,7 +626,7 @@ fn min_batch(values: &ArrayRef) -> Result<ScalarValue> { | |
| }) | ||
| } | ||
|
|
||
| fn min_max_batch_struct(array: &ArrayRef, ordering: Ordering) -> Result<ScalarValue> { | ||
| fn min_max_batch_generic(array: &ArrayRef, ordering: Ordering) -> Result<ScalarValue> { | ||
|
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 like this name change 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. This opens the door to implement Min/Max over any type whose ScalarValue has an |
||
| if array.len() == array.null_count() { | ||
| return ScalarValue::try_from(array.data_type()); | ||
| } | ||
|
|
@@ -649,7 +650,7 @@ fn min_max_batch_struct(array: &ArrayRef, ordering: Ordering) -> Result<ScalarVa | |
| Ok(extreme.force_clone()) | ||
| } | ||
|
|
||
| macro_rules! min_max_struct { | ||
| macro_rules! min_max_generic { | ||
| ($VALUE:expr, $DELTA:expr, $OP:ident) => {{ | ||
| if $VALUE.is_null() { | ||
| $DELTA.clone() | ||
|
|
@@ -703,7 +704,8 @@ pub fn max_batch(values: &ArrayRef) -> Result<ScalarValue> { | |
| max_binary | ||
| ) | ||
| } | ||
| DataType::Struct(_) => min_max_batch_struct(values, Ordering::Less)?, | ||
| DataType::Struct(_) => min_max_batch_generic(values, Ordering::Less)?, | ||
| DataType::List(_) => min_max_batch_generic(values, Ordering::Less)?, | ||
| DataType::Dictionary(_, _) => { | ||
| let values = values.as_any_dictionary().values(); | ||
| max_batch(values)? | ||
|
|
@@ -983,7 +985,14 @@ macro_rules! min_max { | |
| lhs @ ScalarValue::Struct(_), | ||
| rhs @ ScalarValue::Struct(_), | ||
| ) => { | ||
| min_max_struct!(lhs, rhs, $OP) | ||
| min_max_generic!(lhs, rhs, $OP) | ||
| } | ||
|
|
||
| ( | ||
| lhs @ ScalarValue::List(_), | ||
| rhs @ ScalarValue::List(_), | ||
| ) => { | ||
| min_max_generic!(lhs, rhs, $OP) | ||
| } | ||
| e => { | ||
| return internal_err!( | ||
|
|
||
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 could should likely also consider implementing the same for
LargeListandFixedSizeList-- could you file a ticke to track the work?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.
#16032