MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_explain_sql

Function parse_explain_sql

src/testdrive/src/parser.rs:384–416  ·  view source on GitHub ↗
(line_reader: &mut LineReader)

Source from the content-addressed store, hash-verified

382}
383
384fn parse_explain_sql(line_reader: &mut LineReader) -> Result<SqlCommand, PosError> {
385 let (_, line1) = line_reader.next().unwrap();
386 let expected_start = line_reader.consumed_raw_pos;
387 // This is a bit of a hack to extract the next chunk of the file with
388 // blank lines intact. Ideally the `LineReader` would expose the API we
389 // need directly, but that would require a large refactor.
390 let mut expected_output: String = line_reader
391 .inner
392 .lines()
393 .filter(|l| !matches!(l.chars().next(), Some('#')))
394 .take_while(|l| !is_sigil(l.chars().next()))
395 .fold(String::new(), |mut output, l| {
396 let _ = write!(output, "{}\n", l);
397 output
398 });
399 while expected_output.ends_with("\n\n") {
400 expected_output.pop();
401 }
402 // We parsed the multiline expected_output directly using line_reader.inner
403 // above.
404 slurp_all(line_reader);
405 let expected_end = line_reader.consumed_raw_pos;
406
407 Ok(SqlCommand {
408 query: line1[1..].trim().to_owned(),
409 expected_output: SqlOutput::Full {
410 column_names: None,
411 expected_rows: vec![vec![expected_output]],
412 },
413 expected_start,
414 expected_end,
415 })
416}
417
418fn parse_fail_sql(line_reader: &mut LineReader) -> Result<FailSqlCommand, PosError> {
419 let (pos, line1) = line_reader.next().unwrap();

Callers 1

parseFunction · 0.85

Calls 10

is_sigilFunction · 0.85
slurp_allFunction · 0.85
unwrapMethod · 0.80
foldMethod · 0.80
take_whileMethod · 0.80
nextMethod · 0.45
filterMethod · 0.45
popMethod · 0.45
to_ownedMethod · 0.45
trimMethod · 0.45

Tested by

no test coverage detected