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

Function get_query_sql

benchmarks/src/tpcds/run.rs:75–95  ·  view source on GitHub ↗

Get the SQL statements from the specified query file

(base_query_path: &str, query: usize)

Source from the content-addressed store, hash-verified

73
74/// Get the SQL statements from the specified query file
75pub fn get_query_sql(base_query_path: &str, query: usize) -> Result<Vec<String>> {
76 if query > 0 && query < 100 {
77 let filename = format!("{base_query_path}/{query}.sql");
78 let mut errors = vec![];
79 match fs::read_to_string(&filename) {
80 Ok(contents) => {
81 return Ok(contents
82 .split(';')
83 .map(|s| s.trim())
84 .filter(|s| !s.is_empty())
85 .map(|s| s.to_string())
86 .collect());
87 }
88 Err(e) => errors.push(format!("{filename}: {e}")),
89 };
90
91 plan_err!("invalid query. Could not find query: {:?}", errors)
92 } else {
93 plan_err!("invalid query. Expected value between 1 and 99")
94 }
95}
96
97/// Run the tpcds benchmark.
98#[derive(Debug, Args, Clone)]

Callers 1

benchmark_queryMethod · 0.70

Calls 8

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…