Skip to content

Commit 80bd033

Browse files
committed
tests
1 parent 8f67249 commit 80bd033

File tree

9 files changed

+25
-21
lines changed

9 files changed

+25
-21
lines changed

datafusion/common/src/error.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,18 @@ impl From<GenericError> for DataFusionError {
276276
}
277277
}
278278

279+
fn get_back_trace() -> String {
280+
let back_trace = Backtrace::capture();
281+
if back_trace.status() == BacktraceStatus::Captured {
282+
return format!("\nback trace: {}", back_trace);
283+
}
284+
285+
"".to_string()
286+
}
287+
279288
impl Display for DataFusionError {
280289
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!("\nback trace: {}", back_trace);
285-
}
290+
let back_trace_desc: String = get_back_trace();
286291

287292
match *self {
288293
DataFusionError::ArrowError(ref desc) => {

datafusion/core/src/catalog/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ mod tests {
237237

238238
match catalog.register_schema("foo", schema) {
239239
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")),
241241
};
242242
}
243243

datafusion/core/src/dataframe.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,7 @@ mod tests {
14281428
// try to sort on some value not present in input to distinct
14291429
.sort(vec![col("c2").sort(true, true)])
14301430
.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"));
14321432

14331433
Ok(())
14341434
}
@@ -1486,7 +1486,7 @@ mod tests {
14861486
.join_on(right, JoinType::Inner, [col("c1").eq(col("c1"))])
14871487
.expect_err("join didn't fail check");
14881488
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));
14901490

14911491
Ok(())
14921492
}
@@ -1843,7 +1843,7 @@ mod tests {
18431843
.with_column_renamed("c2", "AAA")
18441844
.unwrap_err();
18451845
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));
18471847

18481848
Ok(())
18491849
}

datafusion/core/src/datasource/listing/table.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,8 @@ mod tests {
18621862
)
18631863
.await
18641864
.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+
18661867
Ok(())
18671868
}
18681869

datafusion/core/src/datasource/physical_plan/csv.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,9 @@ mod tests {
835835
// errors due to https://github.com/apache/arrow-datafusion/issues/4918
836836
let mut it = csv.execute(0, task_ctx)?;
837837
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")
841841
);
842842
Ok(())
843843
}
@@ -1074,7 +1074,7 @@ mod tests {
10741074
.write_csv(out_dir_url)
10751075
.await
10761076
.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"));
10781078
Ok(())
10791079
}
10801080

datafusion/core/src/datasource/physical_plan/json.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ mod tests {
792792
.write_json(out_dir_url)
793793
.await
794794
.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"));
796796
Ok(())
797797
}
798798

datafusion/core/src/datasource/physical_plan/parquet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ mod tests {
935935
.write_parquet(out_dir_url, None)
936936
.await
937937
.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"));
939939
Ok(())
940940
}
941941

datafusion/core/src/execution/context.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2356,11 +2356,9 @@ mod tests {
23562356
let ctx = SessionContext::new();
23572357

23582358
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(
23622360
"Error during planning: variable [\"@=\"] has no type information"
2363-
);
2361+
));
23642362
Ok(())
23652363
}
23662364

datafusion/core/src/physical_plan/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ mod test {
450450
// get the first result, which should be an error
451451
let first_batch = stream.next().await.unwrap();
452452
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"));
454454

455455
// There should be no more batches produced (should not get the second error)
456456
assert!(stream.next().await.is_none());

0 commit comments

Comments
 (0)