(
ctx: &SessionContext,
bench: &mut SqlBenchmark,
reader: &mut BenchmarkFileReader,
line: &mut String,
splits: &[&str],
)
| 1063 | } |
| 1064 | |
| 1065 | async fn process_template( |
| 1066 | ctx: &SessionContext, |
| 1067 | bench: &mut SqlBenchmark, |
| 1068 | reader: &mut BenchmarkFileReader, |
| 1069 | line: &mut String, |
| 1070 | splits: &[&str], |
| 1071 | ) -> Result<()> { |
| 1072 | if splits.len() != 2 || splits[1].is_empty() { |
| 1073 | return Err(exec_datafusion_err!( |
| 1074 | "{}", |
| 1075 | reader.format_exception("template requires a single template path") |
| 1076 | )); |
| 1077 | } |
| 1078 | |
| 1079 | // template: update the path to read |
| 1080 | bench.benchmark_path = PathBuf::from(splits[1]); |
| 1081 | |
| 1082 | line.clear(); |
| 1083 | |
| 1084 | // now read parameters |
| 1085 | let mut reader_result = reader.read_line(line); |
| 1086 | |
| 1087 | loop { |
| 1088 | match reader_result { |
| 1089 | Some(Ok(_)) => { |
| 1090 | if is_comment_line(line) { |
| 1091 | // Clear the line buffer for the next iteration. |
| 1092 | line.clear(); |
| 1093 | reader_result = reader.read_line(line); |
| 1094 | continue; |
| 1095 | } |
| 1096 | if is_blank_line(line) { |
| 1097 | break; |
| 1098 | } |
| 1099 | |
| 1100 | let Some((key, value)) = line.trim_start().split_once('=') else { |
| 1101 | return Err(exec_datafusion_err!( |
| 1102 | "{}", |
| 1103 | reader.format_exception( |
| 1104 | "Expected a template parameter in the form of X=Y" |
| 1105 | ) |
| 1106 | )); |
| 1107 | }; |
| 1108 | insert_replacement( |
| 1109 | &mut bench.replacement_mapping, |
| 1110 | key.trim(), |
| 1111 | value.trim().to_string(), |
| 1112 | ); |
| 1113 | } |
| 1114 | Some(Err(e)) => return Err(e), |
| 1115 | None => break, |
| 1116 | } |
| 1117 | |
| 1118 | // Clear the line buffer for the next iteration. |
| 1119 | line.clear(); |
| 1120 | reader_result = reader.read_line(line); |
| 1121 | } |
| 1122 |
nothing calls this directly
no test coverage detected