Reads all `.sql` files from a directory and converts them to test queries. Skips files that: - Are not regular files - Don't have a `.sql` extension - Contain multiple SQL statements (indicated by `;\n`) Multi-statement files are skipped because the unparser doesn't support DML statements like `CREATE VIEW` that appear in multi-statement Clickbench queries.
(dir: ReadDir)
| 61 | /// Multi-statement files are skipped because the unparser doesn't support |
| 62 | /// DML statements like `CREATE VIEW` that appear in multi-statement Clickbench queries. |
| 63 | fn iterate_queries(dir: ReadDir) -> Vec<TestQuery> { |
| 64 | let mut queries = vec![]; |
| 65 | for entry in dir.flatten() { |
| 66 | let Ok(file_type) = entry.file_type() else { |
| 67 | continue; |
| 68 | }; |
| 69 | if !file_type.is_file() { |
| 70 | continue; |
| 71 | } |
| 72 | let path = entry.path(); |
| 73 | let Some(ext) = path.extension() else { |
| 74 | continue; |
| 75 | }; |
| 76 | if ext != "sql" { |
| 77 | continue; |
| 78 | } |
| 79 | let name = path.file_stem().unwrap().to_string_lossy().to_string(); |
| 80 | if let Ok(mut contents) = std::fs::read_to_string(entry.path()) { |
| 81 | // If the query contains ;\n it has DML statements like CREATE VIEW which the unparser doesn't support; skip it |
| 82 | contents = contents.trim().to_string(); |
| 83 | if contents.contains(";\n") { |
| 84 | println!("Skipping query with multiple statements: {name}"); |
| 85 | continue; |
| 86 | } |
| 87 | queries.push(TestQuery { |
| 88 | sql: contents, |
| 89 | name, |
| 90 | }); |
| 91 | } |
| 92 | } |
| 93 | queries |
| 94 | } |
| 95 | |
| 96 | /// A SQL query loaded from a benchmark file for roundtrip testing. |
| 97 | /// |
no test coverage detected
searching dependent graphs…