Skip to content

Apache DataFusion SQL Query Engine

refactor: optimizer shouldn't assume failed rules are internal error (#6184)

Christopher M. Wolffbeee1d91303d
diff --git a/datafusion/core/tests/sqllogictests/test_files/timestamps.slt b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt
index dee6de6b20..84405b0cf1 100644
--- a/datafusion/core/tests/sqllogictests/test_files/timestamps.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt
@@ -317,11 +317,11 @@ select
----
08:09:10.123456789 13:14:15.123456 13:14:15.123 13:14:15
-query error Cannot cast string 'not a time' to value of Time64\(Nanosecond\) type\. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
+query error Cannot cast string 'not a time' to value of Time64\(Nanosecond\) type
SELECT TIME 'not a time' as time;
# invalid time
-query error Cannot cast string '24:01:02' to value of Time64\(Nanosecond\) type\. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
+query error Cannot cast string '24:01:02' to value of Time64\(Nanosecond\) type
SELECT TIME '24:01:02' as time;
statement ok
diff --git a/datafusion/optimizer/src/optimizer.rs b/datafusion/optimizer/src/optimizer.rs
index 487da9db6b..e72833fae6 100644
--- a/datafusion/optimizer/src/optimizer.rs
+++ b/datafusion/optimizer/src/optimizer.rs
@@ -293,7 +293,7 @@ impl Optimizer {
i
);
}
- Err(ref e) => {
+ Err(e) => {
if options.optimizer.skip_failed_rules {
// Note to future readers: if you see this warning it signals a
// bug in the DataFusion optimizer. Please consider filing a ticket
@@ -304,13 +304,8 @@ impl Optimizer {
e
);
} else {
- let e = DataFusionError::Internal(format!(
- "Optimizer rule '{}' failed due to unexpected error: {}",
- rule.name(),
- e
- ));
return Err(DataFusionError::Context(
- rule.name().to_string(),
+ format!("Optimizer rule '{}' failed", rule.name(),),
Box::new(e),
));
}
@@ -468,10 +463,8 @@ mod tests {
});
let err = opt.optimize(&plan, &config, &observe).unwrap_err();
assert_eq!(
- "bad rule\ncaused by\n\
- Internal error: Optimizer rule 'bad rule' failed due to unexpected error: \
- Error during planning: rule failed. This was likely caused by a bug in \
- DataFusion's code and we would welcome that you file an bug report in our issue tracker",
+ "Optimizer rule 'bad rule' failed\ncaused by\n\
+ Error during planning: rule failed",
err.to_string()
);
}