Dandandan commented on a change in pull request #558:
URL: https://github.com/apache/arrow-datafusion/pull/558#discussion_r654776646
##########
File path: datafusion/src/physical_plan/expressions/nth_value.rs
##########
@@ -135,8 +135,12 @@ impl BuiltInWindowFunctionExpr for NthValue {
NthValueKind::Last => (num_rows as usize) - 1,
NthValueKind::Nth(n) => (n as usize) - 1,
};
- let value = ScalarValue::try_from_array(value, index)?;
- Ok(value.to_array_of_size(num_rows))
+ Ok(if index >= num_rows {
+ new_null_array(value.data_type(), num_rows)
+ } else {
+ let value = ScalarValue::try_from_array(value, index)?;
+ value.to_array_of_size(num_rows)
Review comment:
Yes - that should probably already be quite an improvement :+1:
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]