MCPcopy Create free account
hub / github.com/apache/datafusion / read_query_from_reader

Function read_query_from_reader

benchmarks/src/sql_benchmark.rs:1416–1466  ·  view source on GitHub ↗
(
    reader: &mut BenchmarkFileReader,
    sql: &str,
    header: &str,
)

Source from the content-addressed store, hash-verified

1414}
1415
1416fn read_query_from_reader(
1417 reader: &mut BenchmarkFileReader,
1418 sql: &str,
1419 header: &str,
1420) -> Result<BenchmarkQuery> {
1421 let column_count = header.len();
1422 let mut expected_result = vec![];
1423 let mut line = String::new();
1424 let mut reader_result = reader.read_line(&mut line);
1425
1426 loop {
1427 match reader_result {
1428 Some(Ok(_)) => {
1429 if is_comment_line(&line) {
1430 // comment, ignore
1431 } else if is_blank_line(&line) {
1432 break;
1433 } else {
1434 let result_splits: Vec<&str> = line.split(['\t', '|']).collect();
1435
1436 if result_splits.len() != column_count {
1437 return Err(exec_datafusion_err!(
1438 "{} {line}",
1439 reader.format_exception(&format!(
1440 "expected {} values but got {}",
1441 column_count,
1442 result_splits.len(),
1443 ))
1444 ));
1445 }
1446
1447 expected_result
1448 .push(result_splits.into_iter().map(|s| s.to_string()).collect());
1449 }
1450 }
1451 Some(Err(e)) => return Err(e),
1452 None => break,
1453 }
1454
1455 // Clear the line buffer for the next iteration.
1456 line.clear();
1457 reader_result = reader.read_line(&mut line);
1458 }
1459
1460 Ok(BenchmarkQuery {
1461 path: None,
1462 query: sql.to_string(),
1463 column_count,
1464 expected_result,
1465 })
1466}
1467
1468async fn read_query_from_file(
1469 ctx: &SessionContext,

Callers 2

process_assertMethod · 0.85
process_result_queryMethod · 0.85

Calls 12

newFunction · 0.85
is_comment_lineFunction · 0.85
is_blank_lineFunction · 0.85
read_lineMethod · 0.80
collectMethod · 0.80
lenMethod · 0.45
splitMethod · 0.45
pushMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
to_stringMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…