File tree 9 files changed +25
-21
lines changed
9 files changed +25
-21
lines changed Original file line number Diff line number Diff line change @@ -276,13 +276,18 @@ impl From<GenericError> for DataFusionError {
276
276
}
277
277
}
278
278
279
+ fn get_back_trace ( ) -> String {
280
+ let back_trace = Backtrace :: capture ( ) ;
281
+ if back_trace. status ( ) == BacktraceStatus :: Captured {
282
+ return format ! ( "\n back trace: {}" , back_trace) ;
283
+ }
284
+
285
+ "" . to_string ( )
286
+ }
287
+
279
288
impl Display for DataFusionError {
280
289
fn fmt ( & self , f : & mut Formatter ) -> std:: fmt:: Result {
281
- let back_trace = Backtrace :: capture ( ) ;
282
- let mut back_trace_desc: String = "" . to_string ( ) ;
283
- if back_trace. status ( ) == BacktraceStatus :: Captured {
284
- back_trace_desc = format ! ( "\n back trace: {}" , back_trace) ;
285
- }
290
+ let back_trace_desc: String = get_back_trace ( ) ;
286
291
287
292
match * self {
288
293
DataFusionError :: ArrowError ( ref desc) => {
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ mod tests {
237
237
238
238
match catalog. register_schema ( "foo" , schema) {
239
239
Ok ( _) => panic ! ( "unexpected OK" ) ,
240
- Err ( e) => assert_eq ! ( e. to_string( ) , "This feature is not implemented: Registering new schemas is not supported" ) ,
240
+ Err ( e) => assert ! ( e. to_string( ) . starts_with ( "This feature is not implemented: Registering new schemas is not supported" ) ) ,
241
241
} ;
242
242
}
243
243
Original file line number Diff line number Diff line change @@ -1428,7 +1428,7 @@ mod tests {
1428
1428
// try to sort on some value not present in input to distinct
1429
1429
. sort ( vec ! [ col( "c2" ) . sort( true , true ) ] )
1430
1430
. unwrap_err ( ) ;
1431
- assert_eq ! ( err. to_string( ) , "Error during planning: For SELECT DISTINCT, ORDER BY expressions c2 must appear in select list" ) ;
1431
+ assert ! ( err. to_string( ) . starts_with ( "Error during planning: For SELECT DISTINCT, ORDER BY expressions c2 must appear in select list" ) ) ;
1432
1432
1433
1433
Ok ( ( ) )
1434
1434
}
@@ -1486,7 +1486,7 @@ mod tests {
1486
1486
. join_on ( right, JoinType :: Inner , [ col ( "c1" ) . eq ( col ( "c1" ) ) ] )
1487
1487
. expect_err ( "join didn't fail check" ) ;
1488
1488
let expected = "Schema error: Ambiguous reference to unqualified field c1" ;
1489
- assert_eq ! ( join. to_string( ) , expected) ;
1489
+ assert ! ( join. to_string( ) . starts_with ( expected) ) ;
1490
1490
1491
1491
Ok ( ( ) )
1492
1492
}
@@ -1843,7 +1843,7 @@ mod tests {
1843
1843
. with_column_renamed ( "c2" , "AAA" )
1844
1844
. unwrap_err ( ) ;
1845
1845
let expected_err = "Schema error: Ambiguous reference to unqualified field c2" ;
1846
- assert_eq ! ( actual_err. to_string( ) , expected_err) ;
1846
+ assert ! ( actual_err. to_string( ) . starts_with ( expected_err) ) ;
1847
1847
1848
1848
Ok ( ( ) )
1849
1849
}
Original file line number Diff line number Diff line change @@ -1862,7 +1862,8 @@ mod tests {
1862
1862
)
1863
1863
. await
1864
1864
. expect_err ( "Example should fail!" ) ;
1865
- assert_eq ! ( "Invalid or Unsupported Configuration: zstd compression requires specifying a level such as zstd(4)" , format!( "{e}" ) ) ;
1865
+ assert ! ( e. to_string( ) . starts_with( "Invalid or Unsupported Configuration: zstd compression requires specifying a level such as zstd(4)" ) ) ;
1866
+
1866
1867
Ok ( ( ) )
1867
1868
}
1868
1869
Original file line number Diff line number Diff line change @@ -835,9 +835,9 @@ mod tests {
835
835
// errors due to https://github.com/apache/arrow-datafusion/issues/4918
836
836
let mut it = csv. execute ( 0 , task_ctx) ?;
837
837
let err = it. next ( ) . await . unwrap ( ) . unwrap_err ( ) . to_string ( ) ;
838
- assert_eq ! (
839
- err,
840
- "Arrow error: Csv error: incorrect number of fields for line 1, expected 14 got 13"
838
+ assert ! (
839
+ err. to_string ( ) . starts_with (
840
+ "Arrow error: Csv error: incorrect number of fields for line 1, expected 14 got 13" )
841
841
) ;
842
842
Ok ( ( ) )
843
843
}
@@ -1074,7 +1074,7 @@ mod tests {
1074
1074
. write_csv ( out_dir_url)
1075
1075
. await
1076
1076
. expect_err ( "should fail because input file does not match inferred schema" ) ;
1077
- assert_eq ! ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" , format! ( "{e} ") ) ;
1077
+ assert ! ( e . to_string ( ) . starts_with ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" ) ) ;
1078
1078
Ok ( ( ) )
1079
1079
}
1080
1080
Original file line number Diff line number Diff line change @@ -792,7 +792,7 @@ mod tests {
792
792
. write_json ( out_dir_url)
793
793
. await
794
794
. expect_err ( "should fail because input file does not match inferred schema" ) ;
795
- assert_eq ! ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" , format! ( "{e} ") ) ;
795
+ assert ! ( e . to_string ( ) . starts_with ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" ) ) ;
796
796
Ok ( ( ) )
797
797
}
798
798
Original file line number Diff line number Diff line change @@ -935,7 +935,7 @@ mod tests {
935
935
. write_parquet ( out_dir_url, None )
936
936
. await
937
937
. expect_err ( "should fail because input file does not match inferred schema" ) ;
938
- assert_eq ! ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" , format! ( "{e} ") ) ;
938
+ assert ! ( e . to_string ( ) . starts_with ( "Arrow error: Parser error: Error while parsing value d for column 0 at line 4" ) ) ;
939
939
Ok ( ( ) )
940
940
}
941
941
Original file line number Diff line number Diff line change @@ -2356,11 +2356,9 @@ mod tests {
2356
2356
let ctx = SessionContext :: new ( ) ;
2357
2357
2358
2358
let err = plan_and_collect ( & ctx, "SElECT @= X3" ) . await . unwrap_err ( ) ;
2359
-
2360
- assert_eq ! (
2361
- err. to_string( ) ,
2359
+ assert ! ( err. to_string( ) . starts_with(
2362
2360
"Error during planning: variable [\" @=\" ] has no type information"
2363
- ) ;
2361
+ ) ) ;
2364
2362
Ok ( ( ) )
2365
2363
}
2366
2364
Original file line number Diff line number Diff line change @@ -450,7 +450,7 @@ mod test {
450
450
// get the first result, which should be an error
451
451
let first_batch = stream. next ( ) . await . unwrap ( ) ;
452
452
let first_err = first_batch. unwrap_err ( ) ;
453
- assert_eq ! ( first_err. to_string( ) , "Execution error: Test1" ) ;
453
+ assert ! ( first_err. to_string( ) . starts_with ( "Execution error: Test1" ) ) ;
454
454
455
455
// There should be no more batches produced (should not get the second error)
456
456
assert ! ( stream. next( ) . await . is_none( ) ) ;
You can’t perform that action at this time.
0 commit comments