comphead commented on code in PR #9686:
URL: https://github.com/apache/arrow-datafusion/pull/9686#discussion_r1530643670


##########
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:
   You are right @alamb, It is always the same for DataFusion, but when 
building the hybrid system, like something on top of the DF, it happens 
expected external output type its not the same as hardcoded in DF.
   
   Imho, derivation from schema improves DF extensibility as it reduces 
coupling between physical and logical layers and the schema is the contract. 
Thus external systems on top of DF may safely use physical layer just providing 
the expected schema



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