File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
datafusion/physical-expr/src/simplifier Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -57,27 +57,23 @@ impl<'a> TreeNodeRewriter for PhysicalExprSimplifier<'a> {
5757 type Node = Arc < dyn PhysicalExpr > ;
5858
5959 fn f_up ( & mut self , node : Self :: Node ) -> Result < Transformed < Self :: Node > > {
60- // Apply NOT expression simplification first
61- let not_expr_simplified = simplify_not_expr ( & node, self . schema ) ?;
62- let node = not_expr_simplified. data ;
63- let transformed = not_expr_simplified. transformed ;
64-
65- // Apply unwrap cast optimization
6660 #[ cfg( test) ]
6761 let original_type = node. data_type ( self . schema ) . unwrap ( ) ;
68- let unwrapped = unwrap_cast:: unwrap_cast_in_comparison ( node, self . schema ) ?;
62+
63+ // Apply NOT expression simplification first, then unwrap cast optimization
64+ let rewritten =
65+ simplify_not_expr ( & node, self . schema ) ?. transform_data ( |node| {
66+ unwrap_cast:: unwrap_cast_in_comparison ( node, self . schema )
67+ } ) ?;
68+
6969 #[ cfg( test) ]
7070 assert_eq ! (
71- unwrapped . data. data_type( self . schema) . unwrap( ) ,
71+ rewritten . data. data_type( self . schema) . unwrap( ) ,
7272 original_type,
7373 "Simplified expression should have the same data type as the original"
7474 ) ;
75- // Combine transformation results
76- let final_transformed = transformed || unwrapped. transformed ;
77- Ok ( Transformed :: new_transformed (
78- unwrapped. data ,
79- final_transformed,
80- ) )
75+
76+ Ok ( rewritten)
8177 }
8278}
8379
You can’t perform that action at this time.
0 commit comments