viirya commented on code in PR #9470:
URL: https://github.com/apache/arrow-datafusion/pull/9470#discussion_r1516626687
##########
datafusion/physical-expr/src/window/nth_value.rs:
##########
@@ -210,9 +225,31 @@ impl PartitionEvaluator for NthValueEvaluator {
// We produce None if the window is empty.
return ScalarValue::try_from(arr.data_type());
}
+
+ let mut valid_indices = Vec::new();
+ if self.ignore_nulls {
+ valid_indices =
arr.nulls().unwrap().valid_indices().collect::<Vec<_>>();
+ if valid_indices.is_empty() {
+ return ScalarValue::try_from(arr.data_type());
+ }
+ }
match self.state.kind {
- NthValueKind::First => ScalarValue::try_from_array(arr,
range.start),
- NthValueKind::Last => ScalarValue::try_from_array(arr,
range.end - 1),
+ NthValueKind::First => {
+ let index: usize = if self.ignore_nulls {
+ valid_indices[0]
+ } else {
+ range.start
+ };
+ ScalarValue::try_from_array(arr, index)
+ }
+ NthValueKind::Last => {
+ let index = if self.ignore_nulls {
+ valid_indices[valid_indices.len() - 1]
Review Comment:
Same here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]