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

Method process_result_query

benchmarks/src/sql_benchmark.rs:1003–1063  ·  view source on GitHub ↗
(
        bench: &mut SqlBenchmark,
        reader: &mut BenchmarkFileReader,
        line: &mut String,
        splits: &[&str],
    )

Source from the content-addressed store, hash-verified

1001 }
1002
1003 fn process_result_query(
1004 bench: &mut SqlBenchmark,
1005 reader: &mut BenchmarkFileReader,
1006 line: &mut String,
1007 splits: &[&str],
1008 ) -> Result<()> {
1009 if splits.len() <= 1 || splits[1].is_empty() {
1010 return Err(exec_datafusion_err!(
1011 "{}",
1012 reader.format_exception(
1013 "result_query must be followed by a column count (e.g. result_query III)"
1014 )
1015 ));
1016 }
1017
1018 line.clear();
1019
1020 let mut sql = String::new();
1021 let mut found_break = false;
1022 let mut reader_result = reader.read_line(line);
1023
1024 loop {
1025 match reader_result {
1026 Some(Ok(_)) => {
1027 if line.trim() == "----" {
1028 found_break = true;
1029 break;
1030 }
1031 sql.push_str(line);
1032 sql.push('\n');
1033 }
1034 Some(Err(e)) => return Err(e),
1035 None => break,
1036 }
1037
1038 // Clear the line buffer for the next iteration.
1039 line.clear();
1040 reader_result = reader.read_line(line);
1041 }
1042
1043 if !found_break {
1044 return Err(exec_datafusion_err!(
1045 "{}",
1046 reader.format_exception(
1047 "result_query must be followed by a query and a result (separated by ----)"
1048 )
1049 ));
1050 }
1051
1052 let result_check = read_query_from_reader(reader, &sql, splits[1])?;
1053
1054 if !bench.result_queries.is_empty() {
1055 return Err(exec_datafusion_err!(
1056 "{}",
1057 reader.format_exception("multiple results found")
1058 ));
1059 }
1060 bench.result_queries.push(result_check);

Callers

nothing calls this directly

Calls 8

newFunction · 0.85
read_query_from_readerFunction · 0.85
read_lineMethod · 0.80
trimMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45
clearMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected