dqkqd commented on code in PR #17926:
URL: https://github.com/apache/datafusion/pull/17926#discussion_r2404415429
##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -2543,16 +2543,22 @@ impl Window {
)
}
+ /// Create a new window function using the provided schema to avoid the
overhead of
+ /// building the schema again when the schema is already known.
+ ///
+ /// This method should only be called when you are absolutely sure that
the schema being
+ /// provided is correct for the window function. If in doubt, call
[try_new](Self::try_new) instead.
pub fn try_new_with_schema(
window_expr: Vec<Expr>,
input: Arc<LogicalPlan>,
schema: DFSchemaRef,
) -> Result<Self> {
- if window_expr.len() != schema.fields().len() -
input.schema().fields().len() {
+ let input_fields_count = input.schema().fields().len();
+ if schema.fields().len() != input_fields_count + window_expr.len() {
return plan_err!(
- "Window has mismatch between number of expressions ({}) and
number of fields in schema ({})",
- window_expr.len(),
- schema.fields().len() - input.schema().fields().len()
+ "Window schema has wrong number of fields. Expected {} got {}",
+ input_fields_count + window_expr.len(),
+ schema.fields().len()
Review Comment:
I follow the error message from `Aggregate::try_new_with_schema`.
https://github.com/apache/datafusion/blob/9e8ec548fb6ef6bcfaa33abda67a17af6a8999e4/datafusion/expr/src/logical_plan/plan.rs#L3470-L3477
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]