alamb commented on code in PR #7277:
URL: https://github.com/apache/arrow-datafusion/pull/7277#discussion_r1293308189


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -288,11 +288,17 @@ impl Optimizer {
             log_plan(&format!("Optimizer input (pass {i})"), &new_plan);
 
             for rule in &self.rules {
-                let result = self.optimize_recursively(rule, &new_plan, 
config);
-
+                let result =
+                    self.optimize_recursively(rule, &new_plan, config)
+                        .and_then(|plan| {
+                            plan.map(|p| {
+                                assert_schema_is_the_same(rule.name(), 
&new_plan, &p)
+                                    .map(|_| Some(p))
+                            })
+                            .unwrap_or(Ok(None))
+                        });

Review Comment:
   Here is another way of writing this logic which I think might be clearer:
   
   ```suggestion
                   let result =
                       self.optimize_recursively(rule, &new_plan, config)
                       .and_then(|plan| {
                           if let Some(plan) = &plan {
                               assert_schema_is_the_same(rule.name(), 
&new_plan, &plan)?;
                           }
                           Ok(plan)
                       });
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to