comphead commented on code in PR #9686:
URL: https://github.com/apache/arrow-datafusion/pull/9686#discussion_r1530657760
##########
datafusion/physical-plan/src/windows/mod.rs:
##########
@@ -174,20 +174,15 @@ fn create_built_in_window_expr(
name: String,
ignore_nulls: bool,
) -> Result<Arc<dyn BuiltInWindowFunctionExpr>> {
- // need to get the types into an owned vec for some reason
- let input_types: Vec<_> = args
- .iter()
- .map(|arg| arg.data_type(input_schema))
- .collect::<Result<_>>()?;
+ // derive the output datatype from incoming schema
+ let out_data_type: &DataType =
input_schema.field_with_name(&name)?.data_type();
- // figure out the output type
- let data_type = &fun.return_type(&input_types)?;
Ok(match fun {
- BuiltInWindowFunction::RowNumber => Arc::new(RowNumber::new(name,
data_type)),
- BuiltInWindowFunction::Rank => Arc::new(rank(name, data_type)),
- BuiltInWindowFunction::DenseRank => Arc::new(dense_rank(name,
data_type)),
- BuiltInWindowFunction::PercentRank => Arc::new(percent_rank(name,
data_type)),
- BuiltInWindowFunction::CumeDist => Arc::new(cume_dist(name,
data_type)),
+ BuiltInWindowFunction::RowNumber => Arc::new(RowNumber::new(name,
out_data_type)),
Review Comment:
Reg to trait unification this is also a great idea to improve extensibility.
I'm thinking if can we move on with this PR, and migrate all window funcs to
unified trait in follow up activity?
--
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]