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

Function get_query_sql_for_scale_factor

benchmarks/src/tpch/mod.rs:148–182  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

146/// Get the SQL statements from the specified query file using the provided scale factor for
147/// TPC-H substitutions such as Q11 FRACTION.
148pub 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
184fn customize_query_sql(
185 query: usize,

Callers 3

get_query_sqlFunction · 0.85
benchmark_queryMethod · 0.85

Calls 9

customize_query_sqlFunction · 0.85
collectMethod · 0.80
trimMethod · 0.80
mapMethod · 0.45
filterMethod · 0.45
splitMethod · 0.45
is_emptyMethod · 0.45
to_stringMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…