Apache DataFusion SQL Query Engine
chore: make more clarity for internal errors (#16741)
Oleks V8d7b11b1cdf0
diff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rsindex 805c74137b..88029ea474 100644--- a/datafusion/common/src/error.rs+++ b/datafusion/common/src/error.rs@@ -542,8 +542,9 @@ impl DataFusionError {DataFusionError::Configuration(ref desc) => Cow::Owned(desc.to_string()),DataFusionError::NotImplemented(ref desc) => Cow::Owned(desc.to_string()),DataFusionError::Internal(ref desc) => Cow::Owned(format!(- "{desc}.\nThis was likely caused by a bug in DataFusion's \- code and we would welcome that you file an bug report in our issue tracker"+ "{desc}.\nThis issue was likely caused by a bug in DataFusion's code. \+ Please help us to resolve this by filing a bug report in our issue tracker: \+ https://github.com/apache/datafusion/issues")),DataFusionError::Plan(ref desc) => Cow::Owned(desc.to_string()),DataFusionError::SchemaError(ref desc, ref backtrace) => {diff --git a/datafusion/physical-expr/src/expressions/column.rs b/datafusion/physical-expr/src/expressions/column.rsindex 5a11783a87..c9f3fb00f0 100644--- a/datafusion/physical-expr/src/expressions/column.rs+++ b/datafusion/physical-expr/src/expressions/column.rs@@ -204,7 +204,6 @@ mod test {use arrow::array::StringArray;use arrow::datatypes::{DataType, Field, Schema};use arrow::record_batch::RecordBatch;- use datafusion_common::Result;use std::sync::Arc;@@ -214,8 +213,9 @@ mod test {let col = Column::new("id", 9);let error = col.data_type(&schema).expect_err("error").strip_backtrace();assert!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \- but input schema only has 1 columns: [\"foo\"].\nThis was likely caused by a bug in \- DataFusion's code and we would welcome that you file an bug report in our issue tracker".starts_with(&error))+ but input schema only has 1 columns: [\"foo\"].\nThis issue was likely caused by a bug \+ in DataFusion's code. Please help us to resolve this by filing a bug report \+ in our issue tracker: https://github.com/apache/datafusion/issues".starts_with(&error))}#[test]@@ -224,20 +224,21 @@ mod test {let col = Column::new("id", 9);let error = col.nullable(&schema).expect_err("error").strip_backtrace();assert!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \- but input schema only has 1 columns: [\"foo\"].\nThis was likely caused by a bug in \- DataFusion's code and we would welcome that you file an bug report in our issue tracker".starts_with(&error))+ but input schema only has 1 columns: [\"foo\"].\nThis issue was likely caused by a bug \+ in DataFusion's code. Please help us to resolve this by filing a bug report \+ in our issue tracker: https://github.com/apache/datafusion/issues".starts_with(&error));}#[test]- fn out_of_bounds_evaluate() -> Result<()> {+ fn out_of_bounds_evaluate() {let schema = Schema::new(vec![Field::new("foo", DataType::Utf8, true)]);let data: StringArray = vec!["data"].into();- let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(data)])?;+ let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(data)]).unwrap();let col = Column::new("id", 9);let error = col.evaluate(&batch).expect_err("error").strip_backtrace();assert!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \- but input schema only has 1 columns: [\"foo\"].\nThis was likely caused by a bug in \- DataFusion's code and we would welcome that you file an bug report in our issue tracker".starts_with(&error));- Ok(())+ but input schema only has 1 columns: [\"foo\"].\nThis issue was likely caused by a bug \+ in DataFusion's code. Please help us to resolve this by filing a bug report \+ in our issue tracker: https://github.com/apache/datafusion/issues".starts_with(&error));}}diff --git a/datafusion/sql/src/expr/identifier.rs b/datafusion/sql/src/expr/identifier.rsindex 7c276ce53e..434ac50bce 100644--- a/datafusion/sql/src/expr/identifier.rs+++ b/datafusion/sql/src/expr/identifier.rs@@ -459,8 +459,8 @@ mod test {fn test_form_identifier() -> Result<()> {let err = form_identifier(&[]).expect_err("empty identifiers didn't fail");let expected = "Internal error: Incorrect number of identifiers: 0.\n\- 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";+ This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this \+ by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues";assert!(expected.starts_with(&err.strip_backtrace()));let ids = vec!["a".to_string()];@@ -497,8 +497,8 @@ mod test {]).expect_err("too many identifiers didn't fail");let expected = "Internal error: Incorrect number of identifiers: 5.\n\- 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";+ This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this \+ by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues";assert!(expected.starts_with(&err.strip_backtrace()));Ok(())