diff --git a/datafusion/common/src/error.rs b/datafusion/common/src/error.rs index b2ee01fcf92a1..582073c978a2f 100644 --- a/datafusion/common/src/error.rs +++ b/datafusion/common/src/error.rs @@ -420,7 +420,7 @@ impl DataFusionError { .split("\n\nbacktrace: ") .collect::>() .first() - .unwrap_or_else(|| &"") + .unwrap_or(&"") .to_string() } @@ -514,16 +514,15 @@ mod test { use arrow::error::ArrowError; #[test] - fn arrow_error_to_datafusion() { + fn datafusion_error_to_arrow() { let res = return_arrow_error().unwrap_err(); - assert_eq!( - res.to_string(), - "External error: Error during planning: foo" - ); + assert!(res + .to_string() + .starts_with("External error: Error during planning: foo")); } #[test] - fn datafusion_error_to_arrow() { + fn arrow_error_to_datafusion() { let res = return_datafusion_error().unwrap_err(); assert_eq!(res.strip_backtrace(), "Arrow error: Schema error: bar"); } @@ -641,9 +640,7 @@ mod test { let e = e.find_root(); // DataFusionError does not implement Eq, so we use a string comparison + some cheap "same variant" test instead - dbg!(e.to_string()); - dbg!(exp.to_string()); - assert_eq!(e.strip_backtrace(), exp.to_string()); + assert_eq!(e.strip_backtrace(), exp.strip_backtrace()); assert_eq!(std::mem::discriminant(e), std::mem::discriminant(&exp),) } } diff --git a/datafusion/core/tests/dataframe/mod.rs b/datafusion/core/tests/dataframe/mod.rs index bda6e5d929197..3e0a2ec82605c 100644 --- a/datafusion/core/tests/dataframe/mod.rs +++ b/datafusion/core/tests/dataframe/mod.rs @@ -482,7 +482,7 @@ async fn sort_on_distinct_unprojected_columns() -> Result<()> { .distinct()? .sort(vec![Expr::Sort(Sort::new(Box::new(col("b")), false, true))]) .unwrap_err(); - assert_eq!(err.to_string(), "Error during planning: For SELECT DISTINCT, ORDER BY expressions b must appear in select list"); + assert_eq!(err.strip_backtrace(), "Error during planning: For SELECT DISTINCT, ORDER BY expressions b must appear in select list"); Ok(()) } @@ -501,7 +501,7 @@ async fn sort_on_ambiguous_column() -> Result<()> { .unwrap_err(); let expected = "Schema error: Ambiguous reference to unqualified field b"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); Ok(()) } @@ -520,7 +520,7 @@ async fn group_by_ambiguous_column() -> Result<()> { .unwrap_err(); let expected = "Schema error: Ambiguous reference to unqualified field b"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); Ok(()) } @@ -539,7 +539,7 @@ async fn filter_on_ambiguous_column() -> Result<()> { .unwrap_err(); let expected = "Schema error: Ambiguous reference to unqualified field b"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); Ok(()) } @@ -558,7 +558,7 @@ async fn select_ambiguous_column() -> Result<()> { .unwrap_err(); let expected = "Schema error: Ambiguous reference to unqualified field b"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); Ok(()) } diff --git a/datafusion/core/tests/sql/joins.rs b/datafusion/core/tests/sql/joins.rs index 6ba8474ee1546..1aaa01bf4f668 100644 --- a/datafusion/core/tests/sql/joins.rs +++ b/datafusion/core/tests/sql/joins.rs @@ -231,7 +231,7 @@ async fn join_change_in_planner_without_sort_not_allowed() -> Result<()> { match df.create_physical_plan().await { Ok(_) => panic!("Expecting error."), Err(e) => { - assert_eq!(e.to_string(), "PipelineChecker\ncaused by\nError during planning: Join operation cannot operate on a non-prunable stream without enabling the 'allow_symmetric_joins_without_pruning' configuration flag") + assert_eq!(e.strip_backtrace(), "PipelineChecker\ncaused by\nError during planning: Join operation cannot operate on a non-prunable stream without enabling the 'allow_symmetric_joins_without_pruning' configuration flag") } } Ok(()) diff --git a/datafusion/core/tests/sql/order.rs b/datafusion/core/tests/sql/order.rs index d676ac731fd3a..c5497b4cc0f9d 100644 --- a/datafusion/core/tests/sql/order.rs +++ b/datafusion/core/tests/sql/order.rs @@ -70,7 +70,7 @@ async fn create_external_table_with_ddl_ordered_non_cols() -> Result<()> { Ok(_) => panic!("Expecting error."), Err(e) => { assert_eq!( - e.to_string(), + e.strip_backtrace(), "Error during planning: Column a is not in schema" ) } @@ -85,7 +85,7 @@ async fn create_external_table_with_ddl_ordered_without_schema() -> Result<()> { match ctx.state().create_logical_plan(sql).await { Ok(_) => panic!("Expecting error."), Err(e) => { - assert_eq!(e.to_string(), "Error during planning: Provide a schema before specifying the order while creating a table.") + assert_eq!(e.strip_backtrace(), "Error during planning: Provide a schema before specifying the order while creating a table.") } } Ok(()) diff --git a/datafusion/core/tests/sql/sql_api.rs b/datafusion/core/tests/sql/sql_api.rs index 4f249a8656da6..d7adc9611b2ff 100644 --- a/datafusion/core/tests/sql/sql_api.rs +++ b/datafusion/core/tests/sql/sql_api.rs @@ -30,7 +30,7 @@ async fn unsupported_ddl_returns_error() { let sql = "create view test_view as select * from test"; let df = ctx.sql_with_options(sql, options).await; assert_eq!( - df.unwrap_err().to_string(), + df.unwrap_err().strip_backtrace(), "Error during planning: DDL not supported: CreateView" ); @@ -49,7 +49,7 @@ async fn unsupported_dml_returns_error() { let sql = "insert into test values (1)"; let df = ctx.sql_with_options(sql, options).await; assert_eq!( - df.unwrap_err().to_string(), + df.unwrap_err().strip_backtrace(), "Error during planning: DML not supported: Insert Into" ); @@ -70,7 +70,7 @@ async fn unsupported_copy_returns_error() { let sql = format!("copy (values(1)) to '{}'", tmpfile.to_string_lossy()); let df = ctx.sql_with_options(&sql, options).await; assert_eq!( - df.unwrap_err().to_string(), + df.unwrap_err().strip_backtrace(), "Error during planning: DML not supported: COPY" ); @@ -88,7 +88,7 @@ async fn unsupported_statement_returns_error() { let sql = "set datafusion.execution.batch_size = 5"; let df = ctx.sql_with_options(sql, options).await; assert_eq!( - df.unwrap_err().to_string(), + df.unwrap_err().strip_backtrace(), "Error during planning: Statement not supported: SetVariable" ); @@ -110,7 +110,7 @@ async fn ddl_can_not_be_planned_by_session_state() { let plan = state.create_logical_plan(sql).await.unwrap(); let physical_plan = state.create_physical_plan(&plan).await; assert_eq!( - physical_plan.unwrap_err().to_string(), + physical_plan.unwrap_err().strip_backtrace(), "This feature is not implemented: Unsupported logical plan: DropTable" ); } diff --git a/datafusion/core/tests/sql/timestamp.rs b/datafusion/core/tests/sql/timestamp.rs index 611e7c22282ee..09bbd1754276e 100644 --- a/datafusion/core/tests/sql/timestamp.rs +++ b/datafusion/core/tests/sql/timestamp.rs @@ -795,7 +795,7 @@ async fn test_cast_to_time_with_time_zone_should_not_work() -> Result<()> { let results = plan_and_collect(&ctx, sql).await.unwrap_err(); assert_eq!( - results.to_string(), + results.strip_backtrace(), "This feature is not implemented: Unsupported SQL type Time(None, WithTimeZone)" ); @@ -828,7 +828,7 @@ async fn test_cast_to_timetz_should_not_work() -> Result<()> { let results = plan_and_collect(&ctx, sql).await.unwrap_err(); assert_eq!( - results.to_string(), + results.strip_backtrace(), "This feature is not implemented: Unsupported SQL type Time(None, Tz)" ); Ok(()) diff --git a/datafusion/execution/src/disk_manager.rs b/datafusion/execution/src/disk_manager.rs index e8d2ed9cc0f51..ecae698523875 100644 --- a/datafusion/execution/src/disk_manager.rs +++ b/datafusion/execution/src/disk_manager.rs @@ -220,7 +220,7 @@ mod tests { let manager = DiskManager::try_new(config).unwrap(); assert!(!manager.tmp_files_enabled()); assert_eq!( - manager.create_tmp_file("Testing").unwrap_err().to_string(), + manager.create_tmp_file("Testing").unwrap_err().strip_backtrace(), "Resources exhausted: Memory Exhausted while Testing (DiskManager is disabled)", ) } diff --git a/datafusion/execution/src/memory_pool/pool.rs b/datafusion/execution/src/memory_pool/pool.rs index cc48c34b8ed6c..fc49c5fa94c7e 100644 --- a/datafusion/execution/src/memory_pool/pool.rs +++ b/datafusion/execution/src/memory_pool/pool.rs @@ -261,10 +261,10 @@ mod tests { assert_eq!(pool.reserved(), 4000); - let err = r2.try_grow(1).unwrap_err().to_string(); + let err = r2.try_grow(1).unwrap_err().strip_backtrace(); assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated - maximum available is 0"); - let err = r2.try_grow(1).unwrap_err().to_string(); + let err = r2.try_grow(1).unwrap_err().strip_backtrace(); assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated - maximum available is 0"); r1.shrink(1990); @@ -289,12 +289,12 @@ mod tests { .with_can_spill(true) .register(&pool); - let err = r3.try_grow(70).unwrap_err().to_string(); + let err = r3.try_grow(70).unwrap_err().strip_backtrace(); assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated - maximum available is 40"); //Shrinking r2 to zero doesn't allow a3 to allocate more than 45 r2.free(); - let err = r3.try_grow(70).unwrap_err().to_string(); + let err = r3.try_grow(70).unwrap_err().strip_backtrace(); assert_eq!(err, "Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated - maximum available is 40"); // But dropping r2 does @@ -307,7 +307,7 @@ mod tests { assert_eq!(pool.reserved(), 80); let mut r4 = MemoryConsumer::new("s4").register(&pool); - let err = r4.try_grow(30).unwrap_err().to_string(); + let err = r4.try_grow(30).unwrap_err().strip_backtrace(); assert_eq!(err, "Resources exhausted: Failed to allocate additional 30 bytes for s4 with 0 bytes already allocated - maximum available is 20"); } } diff --git a/datafusion/execution/src/object_store.rs b/datafusion/execution/src/object_store.rs index 7bedf0c8659cb..5a1cdb769098c 100644 --- a/datafusion/execution/src/object_store.rs +++ b/datafusion/execution/src/object_store.rs @@ -234,20 +234,20 @@ mod tests { assert_eq!(url.as_str(), "s3://username:password@host:123/"); let err = ObjectStoreUrl::parse("s3://bucket:invalid").unwrap_err(); - assert_eq!(err.to_string(), "External error: invalid port number"); + assert_eq!(err.strip_backtrace(), "External error: invalid port number"); let err = ObjectStoreUrl::parse("s3://bucket?").unwrap_err(); - assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?"); + assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?"); let err = ObjectStoreUrl::parse("s3://bucket?foo=bar").unwrap_err(); - assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar"); + assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar"); let err = ObjectStoreUrl::parse("s3://host:123/foo").unwrap_err(); - assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"); + assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"); let err = ObjectStoreUrl::parse("s3://username:password@host:123/foo").unwrap_err(); - assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"); + assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"); } #[test] diff --git a/datafusion/expr/src/expr_rewriter/mod.rs b/datafusion/expr/src/expr_rewriter/mod.rs index acb8d23c0d5ea..1f04c80833f09 100644 --- a/datafusion/expr/src/expr_rewriter/mod.rs +++ b/datafusion/expr/src/expr_rewriter/mod.rs @@ -374,7 +374,7 @@ mod test { let error = normalize_col_with_schemas_and_ambiguity_check(expr, &[&schemas], &[]) .unwrap_err() - .to_string(); + .strip_backtrace(); assert_eq!( error, r#"Schema error: No field named b. Valid fields are "tableA".a."# diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs index d3cc42afbe66b..911dc44a26407 100644 --- a/datafusion/expr/src/logical_plan/builder.rs +++ b/datafusion/expr/src/logical_plan/builder.rs @@ -1522,7 +1522,7 @@ mod tests { let err = LogicalPlanBuilder::scan("", table_source(&schema), projection).unwrap_err(); assert_eq!( - err.to_string(), + err.strip_backtrace(), "Error during planning: table_name cannot be empty" ); } @@ -1651,8 +1651,8 @@ mod tests { let err_msg1 = plan1.clone().union(plan2.clone().build()?).unwrap_err(); let err_msg2 = plan1.union_distinct(plan2.build()?).unwrap_err(); - assert_eq!(err_msg1.to_string(), expected); - assert_eq!(err_msg2.to_string(), expected); + assert_eq!(err_msg1.strip_backtrace(), expected); + assert_eq!(err_msg2.strip_backtrace(), expected); Ok(()) } @@ -1876,7 +1876,7 @@ mod tests { LogicalPlanBuilder::intersect(plan1.build()?, plan2.build()?, true) .unwrap_err(); - assert_eq!(err_msg1.to_string(), expected); + assert_eq!(err_msg1.strip_backtrace(), expected); Ok(()) } diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index b17db245e6b19..10c06adea1cf1 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -2272,7 +2272,7 @@ digraph { })), empty_schema, ); - assert_eq!("Error during planning: Projection has mismatch between number of expressions (1) and number of fields in schema (0)", format!("{}", p.err().unwrap())); + assert_eq!(p.err().unwrap().strip_backtrace(), "Error during planning: Projection has mismatch between number of expressions (1) and number of fields in schema (0)"); Ok(()) } diff --git a/datafusion/expr/src/type_coercion/aggregates.rs b/datafusion/expr/src/type_coercion/aggregates.rs index d087f2c030dd3..261c406d5d5e7 100644 --- a/datafusion/expr/src/type_coercion/aggregates.rs +++ b/datafusion/expr/src/type_coercion/aggregates.rs @@ -577,7 +577,7 @@ mod tests { let input_types = vec![DataType::Int64, DataType::Int32]; let signature = fun.signature(); let result = coerce_types(&fun, &input_types, &signature); - assert_eq!("Error during planning: The function Min expects 1 arguments, but 2 were provided", result.unwrap_err().to_string()); + assert_eq!("Error during planning: The function Min expects 1 arguments, but 2 were provided", result.unwrap_err().strip_backtrace()); // test input args is invalid data type for sum or avg let fun = AggregateFunction::Sum; @@ -586,14 +586,14 @@ mod tests { let result = coerce_types(&fun, &input_types, &signature); assert_eq!( "Error during planning: The function Sum does not support inputs of type Utf8.", - result.unwrap_err().to_string() + result.unwrap_err().strip_backtrace() ); let fun = AggregateFunction::Avg; let signature = fun.signature(); let result = coerce_types(&fun, &input_types, &signature); assert_eq!( "Error during planning: The function Avg does not support inputs of type Utf8.", - result.unwrap_err().to_string() + result.unwrap_err().strip_backtrace() ); // test count, array_agg, approx_distinct, min, max. diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rs index 5e94f839b36a5..5f161b85dd9ac 100644 --- a/datafusion/expr/src/window_frame.rs +++ b/datafusion/expr/src/window_frame.rs @@ -332,7 +332,7 @@ mod tests { }; let err = WindowFrame::try_from(window_frame).unwrap_err(); assert_eq!( - err.to_string(), + err.strip_backtrace(), "Error during planning: Invalid window frame: start bound cannot be UNBOUNDED FOLLOWING".to_owned() ); @@ -343,7 +343,7 @@ mod tests { }; let err = WindowFrame::try_from(window_frame).unwrap_err(); assert_eq!( - err.to_string(), + err.strip_backtrace(), "Error during planning: Invalid window frame: end bound cannot be UNBOUNDED PRECEDING".to_owned() ); diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs index ba4b5d7b175c4..9a97b415eb435 100644 --- a/datafusion/optimizer/src/analyzer/type_coercion.rs +++ b/datafusion/optimizer/src/analyzer/type_coercion.rs @@ -1457,7 +1457,7 @@ mod test { }; let err = coerce_case_expression(case, &schema).unwrap_err(); assert_eq!( - err.to_string(), + err.strip_backtrace(), "Error during planning: \ Failed to coerce case (Interval(MonthDayNano)) and \ when ([Float32, Binary, Utf8]) to common types in \ @@ -1475,7 +1475,7 @@ mod test { }; let err = coerce_case_expression(case, &schema).unwrap_err(); assert_eq!( - err.to_string(), + err.strip_backtrace(), "Error during planning: \ Failed to coerce then ([Date32, Float32, Binary]) and \ else (Some(Timestamp(Nanosecond, None))) to common types \ diff --git a/datafusion/optimizer/src/optimizer.rs b/datafusion/optimizer/src/optimizer.rs index 3ce4ecf1c83a5..08b8cd52e564f 100644 --- a/datafusion/optimizer/src/optimizer.rs +++ b/datafusion/optimizer/src/optimizer.rs @@ -483,7 +483,7 @@ mod tests { assert_eq!( "Optimizer rule 'bad rule' failed\ncaused by\n\ Error during planning: rule failed", - err.to_string() + err.strip_backtrace() ); } @@ -507,7 +507,7 @@ mod tests { metadata: {}, functional_dependencies: FunctionalDependencies { deps: [] } }. \ 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", - err.to_string() + err.strip_backtrace() ); } diff --git a/datafusion/physical-expr/src/aggregate/min_max.rs b/datafusion/physical-expr/src/aggregate/min_max.rs index a9028e6840cee..2ce941568e11e 100644 --- a/datafusion/physical-expr/src/aggregate/min_max.rs +++ b/datafusion/physical-expr/src/aggregate/min_max.rs @@ -1152,7 +1152,10 @@ mod tests { "MIN/MAX is not expected to receive scalars of incompatible types {:?}", (Decimal128(Some(123), 10, 2), Decimal128(Some(124), 10, 3)) )); - assert_eq!(expect.to_string(), result.unwrap_err().to_string()); + assert_eq!( + expect.strip_backtrace(), + result.unwrap_err().strip_backtrace() + ); // max batch let array: ArrayRef = Arc::new( diff --git a/datafusion/physical-expr/src/array_expressions.rs b/datafusion/physical-expr/src/array_expressions.rs index 06432b615c5db..081345f8a5d5b 100644 --- a/datafusion/physical-expr/src/array_expressions.rs +++ b/datafusion/physical-expr/src/array_expressions.rs @@ -3213,7 +3213,7 @@ mod tests { let array = array_append(&args); - assert_eq!(array.unwrap_err().to_string(), "Error during planning: array_append received incompatible types: '[Int64, Utf8]'."); + assert_eq!(array.unwrap_err().strip_backtrace(), "Error during planning: array_append received incompatible types: '[Int64, Utf8]'."); } fn return_array() -> ColumnarValue { diff --git a/datafusion/physical-expr/src/datetime_expressions.rs b/datafusion/physical-expr/src/datetime_expressions.rs index 002332ab8364b..2db0818082cfb 100644 --- a/datafusion/physical-expr/src/datetime_expressions.rs +++ b/datafusion/physical-expr/src/datetime_expressions.rs @@ -1061,7 +1061,7 @@ mod tests { let res = date_bin(&[ColumnarValue::Scalar(ScalarValue::IntervalDayTime(Some(1)))]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN expected two or three arguments" ); @@ -1072,7 +1072,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN expects stride argument to be an INTERVAL but got Interval(YearMonth)" ); @@ -1083,7 +1083,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN stride must be non-zero" ); @@ -1094,7 +1094,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN stride argument is too large" ); @@ -1105,7 +1105,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN stride argument is too large" ); @@ -1116,7 +1116,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "This feature is not implemented: DATE_BIN stride does not support combination of month, day and nanosecond intervals" ); @@ -1127,7 +1127,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampMicrosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "Execution error: DATE_BIN expects origin argument to be a TIMESTAMP with nanosececond precision but got Timestamp(Microsecond, None)" ); @@ -1146,7 +1146,7 @@ mod tests { ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(Some(1), None)), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "This feature is not implemented: DATE_BIN only supports literal values for the stride argument, not arrays" ); @@ -1158,7 +1158,7 @@ mod tests { ColumnarValue::Array(timestamps), ]); assert_eq!( - res.err().unwrap().to_string(), + res.err().unwrap().strip_backtrace(), "This feature is not implemented: DATE_BIN only supports literal values for the origin argument, not arrays" ); } diff --git a/datafusion/physical-expr/src/expressions/column.rs b/datafusion/physical-expr/src/expressions/column.rs index 5955faa64551f..d368b04c35cc4 100644 --- a/datafusion/physical-expr/src/expressions/column.rs +++ b/datafusion/physical-expr/src/expressions/column.rs @@ -226,22 +226,22 @@ mod test { fn out_of_bounds_data_type() { let schema = Schema::new(vec![Field::new("foo", DataType::Utf8, true)]); let col = Column::new("id", 9); - let error = col.data_type(&schema).expect_err("error"); + let error = col.data_type(&schema).expect_err("error").strip_backtrace(); assert_eq!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \ but input schema only has 1 columns: [\"foo\"]. 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", - &format!("{error}")) + error) } #[test] fn out_of_bounds_nullable() { let schema = Schema::new(vec![Field::new("foo", DataType::Utf8, true)]); let col = Column::new("id", 9); - let error = col.nullable(&schema).expect_err("error"); + let error = col.nullable(&schema).expect_err("error").strip_backtrace(); assert_eq!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \ but input schema only has 1 columns: [\"foo\"]. 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", - &format!("{error}")) + error) } #[test] @@ -250,11 +250,11 @@ mod test { let data: StringArray = vec!["data"].into(); let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(data)])?; let col = Column::new("id", 9); - let error = col.evaluate(&batch).expect_err("error"); + let error = col.evaluate(&batch).expect_err("error").strip_backtrace(); assert_eq!("Internal error: PhysicalExpr Column references column 'id' at index 9 (zero-based) \ but input schema only has 1 columns: [\"foo\"]. 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", - &format!("{error}")); + error); Ok(()) } } diff --git a/datafusion/physical-expr/src/regex_expressions.rs b/datafusion/physical-expr/src/regex_expressions.rs index 5aea70f75a2a8..41cd01949595a 100644 --- a/datafusion/physical-expr/src/regex_expressions.rs +++ b/datafusion/physical-expr/src/regex_expressions.rs @@ -392,7 +392,7 @@ mod tests { regexp_match::(&[Arc::new(values), Arc::new(patterns), Arc::new(flags)]) .expect_err("unsupported flag should have failed"); - assert_eq!(re_err.to_string(), "Error during planning: regexp_match() does not support the \"global\" option"); + assert_eq!(re_err.strip_backtrace(), "Error during planning: regexp_match() does not support the \"global\" option"); } #[test] @@ -500,7 +500,7 @@ mod tests { ]); let pattern_err = re.expect_err("broken pattern should have failed"); assert_eq!( - pattern_err.to_string(), + pattern_err.strip_backtrace(), "External error: regex parse error:\n [\n ^\nerror: unclosed character class" ); } diff --git a/datafusion/sql/src/expr/identifier.rs b/datafusion/sql/src/expr/identifier.rs index 5a081136cce05..f6dd66523da4f 100644 --- a/datafusion/sql/src/expr/identifier.rs +++ b/datafusion/sql/src/expr/identifier.rs @@ -432,7 +432,7 @@ mod test { let expected = "Internal error: Incorrect number of identifiers: 0. \ 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"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); let ids = vec!["a".to_string()]; let (qualifier, column) = form_identifier(&ids)?; @@ -470,7 +470,7 @@ mod test { let expected = "Internal error: Incorrect number of identifiers: 5. \ 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"; - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); Ok(()) } diff --git a/datafusion/sql/tests/sql_integration.rs b/datafusion/sql/tests/sql_integration.rs index 07112184bf59d..6374e15aa1ece 100644 --- a/datafusion/sql/tests/sql_integration.rs +++ b/datafusion/sql/tests/sql_integration.rs @@ -461,7 +461,7 @@ Dml: op=[Insert Into] table=[test_decimal] #[test] fn test_insert_schema_errors(#[case] sql: &str, #[case] error: &str) { let err = logical_plan(sql).unwrap_err(); - assert_eq!(err.to_string(), error) + assert_eq!(err.strip_backtrace(), error) } #[test] @@ -1344,7 +1344,7 @@ fn select_simple_aggregate_with_groupby_and_column_in_group_by_does_not_exist() let err = logical_plan(sql).expect_err("query should have failed"); assert_eq!("Schema error: No field named doesnotexist. Valid fields are \"SUM(person.age)\", \ person.id, person.first_name, person.last_name, person.age, person.state, \ - person.salary, person.birth_date, person.\"😀\".", format!("{err}")); + person.salary, person.birth_date, person.\"😀\".", err.strip_backtrace()); } #[test] @@ -2850,7 +2850,7 @@ fn cte_use_same_name_multiple_times() { let expected = "SQL error: ParserError(\"WITH query name \\\"a\\\" specified more than once\")"; let result = logical_plan(sql).err().unwrap(); - assert_eq!(result.to_string(), expected); + assert_eq!(result.strip_backtrace(), expected); } #[test] @@ -3113,7 +3113,7 @@ fn cte_unbalanced_number_of_columns() { let expected = "Error during planning: Source table contains 3 columns but only 1 names given as column alias"; let result = logical_plan(sql).err().unwrap(); - assert_eq!(result.to_string(), expected); + assert_eq!(result.strip_backtrace(), expected); } #[test] @@ -3244,7 +3244,7 @@ fn order_by_ambiguous_name() { let expected = "Schema error: Ambiguous reference to unqualified field age"; let err = logical_plan(sql).unwrap_err(); - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); } #[test] @@ -3253,7 +3253,7 @@ fn group_by_ambiguous_name() { let expected = "Schema error: Ambiguous reference to unqualified field age"; let err = logical_plan(sql).unwrap_err(); - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); } #[test] @@ -3516,7 +3516,7 @@ fn test_select_distinct_order_by() { let result = logical_plan(sql); assert!(result.is_err()); let err = result.err().unwrap(); - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); } #[rstest] @@ -3543,7 +3543,7 @@ fn test_select_distinct_order_by() { #[test] fn test_select_unsupported_syntax_errors(#[case] sql: &str, #[case] error: &str) { let err = logical_plan(sql).unwrap_err(); - assert_eq!(err.to_string(), error) + assert_eq!(err.strip_backtrace(), error) } #[test] @@ -3600,7 +3600,7 @@ fn test_ambiguous_column_references_in_on_join() { let result = logical_plan(sql); assert!(result.is_err()); let err = result.err().unwrap(); - assert_eq!(err.to_string(), expected); + assert_eq!(err.strip_backtrace(), expected); } #[test]