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

Method fmt_verbose_syntax

src/expr/src/explain/text.rs:340–911  ·  view source on GitHub ↗
(
        &self,
        f: &mut fmt::Formatter<'_>,
        ctx: &mut PlanRenderingContext<'_, MirRelationExpr>,
    )

Source from the content-addressed store, hash-verified

338 }
339
340 fn fmt_verbose_syntax(
341 &self,
342 f: &mut fmt::Formatter<'_>,
343 ctx: &mut PlanRenderingContext<'_, MirRelationExpr>,
344 ) -> fmt::Result {
345 use MirRelationExpr::*;
346
347 let mode = HumanizedExplain::new(ctx.config.redacted);
348
349 match &self {
350 Constant { rows, typ: _ } => match rows {
351 Ok(rows) => {
352 if !rows.is_empty() {
353 write!(f, "{}Constant", ctx.indent)?;
354 self.fmt_analyses(f, ctx)?;
355 ctx.indented(|ctx| {
356 fmt_text_constant_rows(
357 f,
358 rows.iter().map(|(x, y)| (x, y)),
359 &mut ctx.indent,
360 mode.redacted(),
361 )
362 })?;
363 } else {
364 write!(f, "{}Constant <empty>", ctx.indent)?;
365 self.fmt_analyses(f, ctx)?;
366 }
367 }
368 Err(err) => {
369 if mode.redacted() {
370 writeln!(f, "{}Error █", ctx.indent)?;
371 } else {
372 writeln!(f, "{}Error {}", ctx.indent, err.to_string().escaped())?;
373 }
374 }
375 },
376 Let { id, value, body } => {
377 let mut bindings = vec![(id, value.as_ref())];
378 let mut head = body.as_ref();
379
380 // Render Let-blocks nested in the body an outer Let-block in one step
381 // with a flattened list of bindings
382 while let Let { id, value, body } = head {
383 bindings.push((id, value.as_ref()));
384 head = body.as_ref();
385 }
386
387 if ctx.config.linear_chains {
388 writeln!(f, "{}With", ctx.indent)?;
389 ctx.indented(|ctx| {
390 for (id, value) in bindings.iter() {
391 writeln!(f, "{}cte {} =", ctx.indent, *id)?;
392 ctx.indented(|ctx| value.fmt_text(f, ctx))?;
393 }
394 Ok(())
395 })?;
396 write!(f, "{}Return", ctx.indent)?;
397 self.fmt_analyses(f, ctx)?;

Callers 2

fmt_textMethod · 0.80
fmt_default_syntaxMethod · 0.80

Calls 15

fmt_text_constant_rowsFunction · 0.85
CompactScalarsClass · 0.85
IndicesClass · 0.85
fmt_analysesMethod · 0.80
indentedMethod · 0.80
is_noneMethod · 0.80
seqMethod · 0.80
enumerateMethod · 0.80
unwrapMethod · 0.80
is_someMethod · 0.80
separatedFunction · 0.50

Tested by

no test coverage detected