From 98e4a8598673332fa93d1f8c1411c79bc216ba14 Mon Sep 17 00:00:00 2001 From: zhuqi-lucas <821684824@qq.com> Date: Sat, 16 Aug 2025 21:58:46 +0800 Subject: [PATCH] minor: clean up distinct window code --- datafusion/physical-plan/src/windows/mod.rs | 30 +++++++++------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/datafusion/physical-plan/src/windows/mod.rs b/datafusion/physical-plan/src/windows/mod.rs index 519bed3a84609..721432ce2571e 100644 --- a/datafusion/physical-plan/src/windows/mod.rs +++ b/datafusion/physical-plan/src/windows/mod.rs @@ -102,34 +102,28 @@ pub fn create_window_expr( ) -> Result> { Ok(match fun { WindowFunctionDefinition::AggregateUDF(fun) => { - if distinct { - let aggregate = AggregateExprBuilder::new(Arc::clone(fun), args.to_vec()) + let aggregate = if distinct { + AggregateExprBuilder::new(Arc::clone(fun), args.to_vec()) .schema(Arc::new(input_schema.clone())) .alias(name) .with_ignore_nulls(ignore_nulls) .distinct() .build() - .map(Arc::new)?; - window_expr_from_aggregate_expr( - partition_by, - order_by, - window_frame, - aggregate, - ) + .map(Arc::new)? } else { - let aggregate = AggregateExprBuilder::new(Arc::clone(fun), args.to_vec()) + AggregateExprBuilder::new(Arc::clone(fun), args.to_vec()) .schema(Arc::new(input_schema.clone())) .alias(name) .with_ignore_nulls(ignore_nulls) .build() - .map(Arc::new)?; - window_expr_from_aggregate_expr( - partition_by, - order_by, - window_frame, - aggregate, - ) - } + .map(Arc::new)? + }; + window_expr_from_aggregate_expr( + partition_by, + order_by, + window_frame, + aggregate, + ) } WindowFunctionDefinition::WindowUDF(fun) => Arc::new(StandardWindowExpr::new( create_udwf_window_expr(fun, args, input_schema, name, ignore_nulls)?,