You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/14 17:35:32 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2909: Optimizer should skip failing rules

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


##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -97,13 +106,85 @@ impl Optimizer {
         debug!("Input logical plan:\n{}\n", plan.display_indent());
         trace!("Full input logical plan:\n{:?}", plan);
         for rule in &self.rules {
-            new_plan = rule.optimize(&new_plan, optimizer_config)?;
-            observer(&new_plan, rule.as_ref());
-            debug!("After apply {} rule:\n", rule.name());
-            debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+            let result = rule.optimize(&new_plan, optimizer_config);
+            match result {
+                Ok(plan) => {
+                    new_plan = plan;
+                    observer(&new_plan, rule.as_ref());
+                    debug!("After apply {} rule:\n", rule.name());
+                    debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+                }
+                Err(ref e) => {
+                    if optimizer_config.skip_failing_rules {
+                        error!(

Review Comment:
   ```suggestion
                           warn!(
   ```
   
   A warning might be a more appropriate level (as the query will likely succeed but it is serious enough to warrant investigation)



##########
datafusion/core/src/config.rs:
##########
@@ -43,6 +43,10 @@ pub const OPT_COALESCE_BATCHES: &str = "datafusion.execution.coalesce_batches";
 pub const OPT_COALESCE_TARGET_BATCH_SIZE: &str =
     "datafusion.execution.coalesce_target_batch_size";
 
+/// Configuration option "datafusion.optimizer.skip_failed_rules"

Review Comment:
   💯  for it being a config setting



##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -97,13 +106,85 @@ impl Optimizer {
         debug!("Input logical plan:\n{}\n", plan.display_indent());
         trace!("Full input logical plan:\n{:?}", plan);
         for rule in &self.rules {
-            new_plan = rule.optimize(&new_plan, optimizer_config)?;
-            observer(&new_plan, rule.as_ref());
-            debug!("After apply {} rule:\n", rule.name());
-            debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+            let result = rule.optimize(&new_plan, optimizer_config);
+            match result {
+                Ok(plan) => {
+                    new_plan = plan;
+                    observer(&new_plan, rule.as_ref());
+                    debug!("After apply {} rule:\n", rule.name());
+                    debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+                }
+                Err(ref e) => {
+                    if optimizer_config.skip_failing_rules {

Review Comment:
   ```suggestion
                       if optimizer_config.skip_failing_rules {
                         // Note to future readers: if you see this warning it signals a
                         // bug in the DataFusion optimizer. Please consider filing a ticket
                         // https://github.com/apache/arrow-datafusion
   ```
   
   I think it might be good to tell anyone who sees this error that it is not expected and that it means there is a bug somewhere in datafusion



##########
datafusion/optimizer/src/optimizer.rs:
##########
@@ -97,13 +106,85 @@ impl Optimizer {
         debug!("Input logical plan:\n{}\n", plan.display_indent());
         trace!("Full input logical plan:\n{:?}", plan);
         for rule in &self.rules {
-            new_plan = rule.optimize(&new_plan, optimizer_config)?;
-            observer(&new_plan, rule.as_ref());
-            debug!("After apply {} rule:\n", rule.name());
-            debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+            let result = rule.optimize(&new_plan, optimizer_config);
+            match result {
+                Ok(plan) => {
+                    new_plan = plan;
+                    observer(&new_plan, rule.as_ref());
+                    debug!("After apply {} rule:\n", rule.name());
+                    debug!("Optimized logical plan:\n{}\n", new_plan.display_indent());
+                }
+                Err(ref e) => {
+                    if optimizer_config.skip_failing_rules {
+                        error!(
+                            "Skipping optimizer rule {} due to error: {}",

Review Comment:
   ```suggestion
                               "Skipping optimizer rule {} due to unexpected error: {}",
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org