viirya commented on code in PR #9470:
URL: https://github.com/apache/arrow-datafusion/pull/9470#discussion_r1516626316
##########
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]
Review Comment:
As @mustafasrepo said, you will pick the first non-null value in the array,
not the first non-null value in the range of the array.
--
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]