@@ -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-
735730impl 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" ) ] )
0 commit comments