Get the SQL statements from the specified query file using the provided scale factor for TPC-H substitutions such as Q11 FRACTION.
(
query: usize,
scale_factor: f64,
)
| 146 | /// Get the SQL statements from the specified query file using the provided scale factor for |
| 147 | /// TPC-H substitutions such as Q11 FRACTION. |
| 148 | pub fn get_query_sql_for_scale_factor( |
| 149 | query: usize, |
| 150 | scale_factor: f64, |
| 151 | ) -> Result<Vec<String>> { |
| 152 | if !(scale_factor.is_finite() && scale_factor > 0.0) { |
| 153 | return plan_err!( |
| 154 | "invalid scale factor. Expected a positive finite value, got {scale_factor}" |
| 155 | ); |
| 156 | } |
| 157 | |
| 158 | if query > 0 && query < 23 { |
| 159 | let possibilities = vec![ |
| 160 | format!("queries/q{query}.sql"), |
| 161 | format!("benchmarks/queries/q{query}.sql"), |
| 162 | ]; |
| 163 | let mut errors = vec![]; |
| 164 | for filename in possibilities { |
| 165 | match fs::read_to_string(&filename) { |
| 166 | Ok(contents) => { |
| 167 | let contents = customize_query_sql(query, contents, scale_factor)?; |
| 168 | return Ok(contents |
| 169 | .split(';') |
| 170 | .map(|s| s.trim()) |
| 171 | .filter(|s| !s.is_empty()) |
| 172 | .map(|s| s.to_string()) |
| 173 | .collect()); |
| 174 | } |
| 175 | Err(e) => errors.push(format!("{filename}: {e}")), |
| 176 | }; |
| 177 | } |
| 178 | plan_err!("invalid query. Could not find query: {:?}", errors) |
| 179 | } else { |
| 180 | plan_err!("invalid query. Expected value between 1 and 22") |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | fn customize_query_sql( |
| 185 | query: usize, |
no test coverage detected
searching dependent graphs…