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

Method fmt_raw_syntax

src/sql/src/plan/explain/text.rs:75–297  ·  view source on GitHub ↗
(
        &self,
        f: &mut fmt::Formatter<'_>,
        ctx: &mut PlanRenderingContext<'_, HirRelationExpr>,
    )

Source from the content-addressed store, hash-verified

73 }
74
75 fn fmt_raw_syntax(
76 &self,
77 f: &mut fmt::Formatter<'_>,
78 ctx: &mut PlanRenderingContext<'_, HirRelationExpr>,
79 ) -> fmt::Result {
80 use HirRelationExpr::*;
81
82 let mode = HumanizedExplain::new(ctx.config.redacted);
83
84 match &self {
85 Constant { rows, .. } => {
86 if !rows.is_empty() {
87 writeln!(f, "{}Constant", ctx.indent)?;
88 ctx.indented(|ctx| {
89 fmt_text_constant_rows(
90 f,
91 rows.iter().map(|row| (row, &Diff::ONE)),
92 &mut ctx.indent,
93 ctx.config.redacted,
94 )
95 })?;
96 } else {
97 writeln!(f, "{}Constant <empty>", ctx.indent)?;
98 }
99 }
100 Let {
101 name,
102 id,
103 value,
104 body,
105 } => {
106 let mut bindings = vec![(id, name, value.as_ref())];
107 let mut head = body.as_ref();
108
109 // Render Let-blocks nested in the body an outer Let-block in one step
110 // with a flattened list of bindings
111 while let Let {
112 name,
113 id,
114 value,
115 body,
116 } = head
117 {
118 bindings.push((id, name, value.as_ref()));
119 head = body.as_ref();
120 }
121
122 writeln!(f, "{}With", ctx.indent)?;
123 ctx.indented(|ctx| {
124 for (id, name, value) in bindings.iter() {
125 // TODO: print the name and not the id
126 writeln!(f, "{}cte [{} as {}] =", ctx.indent, *id, *name)?;
127 ctx.indented(|ctx| value.fmt_text(f, ctx))?;
128 }
129 Ok(())
130 })?;
131 writeln!(f, "{}Return", ctx.indent)?;
132 ctx.indented(|ctx| head.fmt_text(f, ctx))?;

Callers 2

fmt_textMethod · 0.80
fmt_virtual_syntaxMethod · 0.80

Calls 15

fmt_text_constant_rowsFunction · 0.85
IndicesClass · 0.85
CompactScalarSeqClass · 0.85
indentedMethod · 0.80
seqMethod · 0.80
contains_parametersMethod · 0.80
to_string_with_causesMethod · 0.80
separatedFunction · 0.50
is_emptyMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected