Skip to content

Commit a5c242c

Browse files
authored
minor: clean up distinct window code (#17215)
1 parent 420a862 commit a5c242c

File tree

1 file changed

+12
-18
lines changed
  • datafusion/physical-plan/src/windows

1 file changed

+12
-18
lines changed

datafusion/physical-plan/src/windows/mod.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,28 @@ pub fn create_window_expr(
102102
) -> Result<Arc<dyn WindowExpr>> {
103103
Ok(match fun {
104104
WindowFunctionDefinition::AggregateUDF(fun) => {
105-
if distinct {
106-
let aggregate = AggregateExprBuilder::new(Arc::clone(fun), args.to_vec())
105+
let aggregate = if distinct {
106+
AggregateExprBuilder::new(Arc::clone(fun), args.to_vec())
107107
.schema(Arc::new(input_schema.clone()))
108108
.alias(name)
109109
.with_ignore_nulls(ignore_nulls)
110110
.distinct()
111111
.build()
112-
.map(Arc::new)?;
113-
window_expr_from_aggregate_expr(
114-
partition_by,
115-
order_by,
116-
window_frame,
117-
aggregate,
118-
)
112+
.map(Arc::new)?
119113
} else {
120-
let aggregate = AggregateExprBuilder::new(Arc::clone(fun), args.to_vec())
114+
AggregateExprBuilder::new(Arc::clone(fun), args.to_vec())
121115
.schema(Arc::new(input_schema.clone()))
122116
.alias(name)
123117
.with_ignore_nulls(ignore_nulls)
124118
.build()
125-
.map(Arc::new)?;
126-
window_expr_from_aggregate_expr(
127-
partition_by,
128-
order_by,
129-
window_frame,
130-
aggregate,
131-
)
132-
}
119+
.map(Arc::new)?
120+
};
121+
window_expr_from_aggregate_expr(
122+
partition_by,
123+
order_by,
124+
window_frame,
125+
aggregate,
126+
)
133127
}
134128
WindowFunctionDefinition::WindowUDF(fun) => Arc::new(StandardWindowExpr::new(
135129
create_udwf_window_expr(fun, args, input_schema, name, ignore_nulls)?,

0 commit comments

Comments
 (0)