Skip to content

Commit 1ad97d2

Browse files
committed
Improve sqllogictest error reporting
1 parent af99b54 commit 1ad97d2

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

datafusion/sqllogictest/bin/sqllogictests.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,38 @@ async fn run_test_file(
235235
runner.with_normalizer(value_normalizer);
236236
runner.with_validator(validator);
237237

238-
let res = runner
239-
.run_file_async(path)
240-
.await
241-
.map_err(|e| DataFusionError::External(Box::new(e)));
238+
let path = path.canonicalize()?;
239+
let records =
240+
parse_file(&path).map_err(|e| DataFusionError::External(Box::new(e)))?;
241+
let mut errs = vec![];
242+
for record in records.into_iter() {
243+
if let Record::Halt { .. } = record {
244+
break;
245+
}
246+
if let Err(err) = runner.run_async(record).await {
247+
errs.push(format!("{err}"));
248+
}
249+
}
242250

243251
pb.finish_and_clear();
244252

245-
res
253+
if errs.is_empty() {
254+
return Ok(());
255+
}
256+
const ERR_LIMIT: usize = 10;
257+
let mut msg = format!("{} errors in file {}\n\n", errs.len(), path.display());
258+
for (i, err) in errs.iter().enumerate() {
259+
if i >= ERR_LIMIT {
260+
msg.push_str(&format!(
261+
"... other {} errors in {} not shown ...\n\n",
262+
errs.len() - ERR_LIMIT,
263+
path.display()
264+
));
265+
break;
266+
}
267+
msg.push_str(&format!("{}. {err}\n\n", i + 1));
268+
}
269+
Err(DataFusionError::External(msg.into()))
246270
}
247271

248272
fn get_record_count(path: &PathBuf, label: String) -> u64 {

0 commit comments

Comments
 (0)