jgoday commented on a change in pull request #687:
URL: https://github.com/apache/arrow-datafusion/pull/687#discussion_r666130346



##########
File path: datafusion/src/physical_plan/windows.rs
##########
@@ -110,13 +110,49 @@ fn create_built_in_window_expr(
             let coerced_args = coerce(args, input_schema, 
&signature_for_built_in(fun))?;
             let arg = coerced_args[0].clone();
             let data_type = args[0].data_type(input_schema)?;
-            Arc::new(lag(name, data_type, arg))
+            let shift_offset = coerced_args
+                .get(1)
+                .map(|v| {
+                    v.as_any()
+                        .downcast_ref::<Literal>()
+                        .unwrap()
+                        .value()
+                        .clone()
+                        .try_into()
+                })
+                .and_then(|v| v.ok());
+            let default_value = coerced_args.get(2).map(|v| {
+                v.as_any()
+                    .downcast_ref::<Literal>()
+                    .unwrap()
+                    .value()
+                    .clone()
+            });
+            Arc::new(lag(name, data_type, arg, shift_offset, default_value))
         }
         BuiltInWindowFunction::Lead => {
             let coerced_args = coerce(args, input_schema, 
&signature_for_built_in(fun))?;
             let arg = coerced_args[0].clone();
             let data_type = args[0].data_type(input_schema)?;
-            Arc::new(lead(name, data_type, arg))
+            let shift_offset = coerced_args
+                .get(1)
+                .map(|v| {
+                    v.as_any()

Review comment:
       Ok, created get_scalar_value_from_args helper function.

##########
File path: datafusion/src/physical_plan/expressions/lead_lag.rs
##########
@@ -98,20 +105,58 @@ impl BuiltInWindowFunctionExpr for WindowShift {
         Ok(Box::new(WindowShiftEvaluator {
             shift_offset: self.shift_offset,
             values,
+            default_value: self.default_value.clone(),
         }))
     }
 }
 
 pub(crate) struct WindowShiftEvaluator {
     shift_offset: i64,
     values: Vec<ArrayRef>,
+    default_value: Option<ScalarValue>,
+}
+
+fn shift_with_default_value(

Review comment:
       Added a TODO comment




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