Skip to content

Commit 9bc6a47

Browse files
committed
Remove comment
1 parent b840fd1 commit 9bc6a47

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

datafusion/optimizer/src/common_subexpr_eliminate.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,6 @@ impl CommonSubexprEliminate {
220220
.into_iter()
221221
.zip(window_schemas)
222222
.try_rfold(new_input, |plan, (new_window_expr, schema)| {
223-
// Rebuilding with the preserved schema to keep column names stable.
224-
// If that fails (e.g., due to expr/schema mismatch
225-
// from earlier rewrites), fall back to rebuilding the schema
226-
// from the expressions directly.
227223
match Window::try_new_with_schema(
228224
new_window_expr.clone(),
229225
Arc::new(plan.clone()),
@@ -731,7 +727,6 @@ impl CSEController for ExprCSEController<'_> {
731727
}
732728
}
733729

734-
735730
impl Default for CommonSubexprEliminate {
736731
fn default() -> Self {
737732
Self::new()
@@ -804,11 +799,13 @@ mod test {
804799

805800
use arrow::datatypes::{DataType, Field, Schema, SchemaRef};
806801
use datafusion_expr::logical_plan::{table_scan, JoinType};
802+
use datafusion_expr::window_frame::WindowFrame;
807803
use datafusion_expr::{
808-
grouping_set, is_null, not, AccumulatorFactoryFunction, AggregateUDF, ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Signature, SimpleAggregateUDF, TableSource, Volatility
804+
grouping_set, is_null, not, AccumulatorFactoryFunction, AggregateUDF,
805+
ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Signature,
806+
SimpleAggregateUDF, TableSource, Volatility,
809807
};
810808
use datafusion_expr::{lit, logical_plan::builder::LogicalPlanBuilder};
811-
use datafusion_expr::window_frame::WindowFrame;
812809
use datafusion_functions_window::row_number::row_number_udwf;
813810

814811
use super::*;
@@ -1710,9 +1707,9 @@ mod test {
17101707
.filter(Expr::BinaryExpr(BinaryExpr {
17111708
left: Box::new(wnd),
17121709
op: Operator::Eq,
1713-
right: Box::new(Expr::Literal(
1714-
datafusion_common::ScalarValue::UInt64(Some(1)),
1715-
)),
1710+
right: Box::new(Expr::Literal(datafusion_common::ScalarValue::UInt64(
1711+
Some(1),
1712+
))),
17161713
}))
17171714
.unwrap()
17181715
.project(vec![col("a"), col("b")])

datafusion/sql/src/select.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
219219
mut select_exprs_post_aggr,
220220
having_expr_post_aggr,
221221
mut qualify_expr_post_aggr,
222-
) = if !group_by_exprs
223-
.is_empty()
224-
|| !aggr_exprs.is_empty()
225-
{
222+
) = if !group_by_exprs.is_empty() || !aggr_exprs.is_empty() {
226223
self.aggregate(
227224
&base_plan,
228225
&select_exprs,
@@ -252,13 +249,14 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
252249
};
253250

254251
// Process window function
255-
let window_search_exprs: Vec<Expr> = if let Some(ref qualify_expr) = qualify_expr_post_aggr {
256-
let mut v = select_exprs_post_aggr.clone();
257-
v.push(qualify_expr.clone());
258-
v
259-
} else {
260-
select_exprs_post_aggr.clone()
261-
};
252+
let window_search_exprs: Vec<Expr> =
253+
if let Some(ref qualify_expr) = qualify_expr_post_aggr {
254+
let mut v = select_exprs_post_aggr.clone();
255+
v.push(qualify_expr.clone());
256+
v
257+
} else {
258+
select_exprs_post_aggr.clone()
259+
};
262260
let window_func_exprs = find_window_exprs(&window_search_exprs);
263261

264262
if has_qualify && window_func_exprs.is_empty() {
@@ -280,15 +278,18 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
280278

281279
// Re-write QUALIFY predicate to reference computed window columns
282280
if let Some(q) = qualify_expr_post_aggr.take() {
283-
qualify_expr_post_aggr = Some(rebase_expr(&q, &window_func_exprs, &plan)?);
281+
qualify_expr_post_aggr =
282+
Some(rebase_expr(&q, &window_func_exprs, &plan)?);
284283
}
285284

286285
plan
287286
};
288287

289288
// Apply QUALIFY filter
290289
let plan = if let Some(qualify_expr) = qualify_expr_post_aggr {
291-
LogicalPlanBuilder::from(plan).filter(qualify_expr)?.build()?
290+
LogicalPlanBuilder::from(plan)
291+
.filter(qualify_expr)?
292+
.build()?
292293
} else {
293294
plan
294295
};

0 commit comments

Comments
 (0)