(
&self,
f: &mut fmt::Formatter<'_>,
ctx: &mut PlanRenderingContext<'_, HirRelationExpr>,
)
| 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))?; |
no test coverage detected