Jimexist commented on a change in pull request #687:
URL: https://github.com/apache/arrow-datafusion/pull/687#discussion_r665066286
##########
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:
feel like you can have a helper function to extract argument as
`Result<Literal>`
--
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]