timsaucer commented on PR #6746:
URL: https://github.com/apache/datafusion/pull/6746#issuecomment-2092866964

   I'm looking at the arguments we end up passing. I think `cume_dist` takes no 
arguments. Lead and lag take anywhere between 1 and 3. `nth_value` takes two. I 
think it might be easier to use with something like
   
   ```
   pub fn lead(arg: Expr, offset: Option<i64>, default: Option<ScalarValue>) -> 
expr::WindowFunction {
       let offset = lit(ScalarValue::Int64(offset));
       let default_value = match default {
           Some(v) => lit(v),
           None => lit(ScalarValue::Null),
       };
       expr::WindowFunction::new(BuiltInWindowFunction::Lead, vec![arg, offset, 
default_value])
   }
   ```
   
   and for nth value it's easier
   
   ```
   pub fn nth_value(arg: Expr, n: i64) -> expr::WindowFunction {
       expr::WindowFunction::new(BuiltInWindowFunction::NthValue, vec![arg, 
lit(n)])
   }
   ```
   
   


-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to