mustafasrepo commented on code in PR #9498:
URL: https://github.com/apache/arrow-datafusion/pull/9498#discussion_r1517659887


##########
datafusion/physical-expr/src/window/lead_lag.rs:
##########
@@ -151,6 +148,59 @@ impl WindowShiftEvaluator {
     }
 }
 
+// implement ignore null for evaluate_all
+fn evaluate_all_with_ignore_null(
+    array: &ArrayRef,
+    offset: i64,
+    default_value: &ScalarValue,
+    is_lag: bool,
+) -> Result<ArrayRef, DataFusionError> {
+    let valid_indices: Vec<usize> = (0..array.len())
+        .filter(|&index| array.is_valid(index))
+        .collect();
+
+    let new_array_results: Result<Vec<_>, DataFusionError> = (0..array.len())

Review Comment:
   I think following calculations do not change each iteration. Hence, you can 
move them out to the iteration as below
   ```rust    
   let direction = is_lag ^ (offset > 0);
   let offset = if direction {
       offset as usize
   } else {
       offset.unsigned_abs() as usize
   };
   
   let new_array_results: Result<Vec<_>, DataFusionError> = (0..array.len())
   ...
   ...
   ```



-- 
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]

Reply via email to