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

Method fmt

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

Source from the content-addressed store, hash-verified

299
300impl fmt::Display for HirScalarExpr {
301 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
302 use HirRelationExpr::Get;
303 use HirScalarExpr::*;
304 match self {
305 Column(i, TreatAsEqual(None)) => write!(
306 f,
307 "#{}{}",
308 (0..i.level).map(|_| '^').collect::<String>(),
309 i.column
310 ),
311 Column(i, TreatAsEqual(Some(name))) => write!(
312 f,
313 "#{}{}{{{name}}}",
314 (0..i.level).map(|_| '^').collect::<String>(),
315 i.column,
316 ),
317 Parameter(i, _name) => write!(f, "${}", i),
318 Literal(row, _, _name) => write!(f, "{}", row.unpack_first()),
319 CallUnmaterializable(func, _name) => write!(f, "{}()", func),
320 CallUnary { func, expr, .. } => {
321 if let mz_expr::UnaryFunc::Not(_) = *func {
322 if let CallUnary { func, expr, .. } = expr.as_ref() {
323 if let Some(is) = func.is() {
324 return write!(f, "({}) IS NOT {}", expr, is);
325 }
326 }
327 }
328 if let Some(is) = func.is() {
329 write!(f, "({}) IS {}", expr, is)
330 } else {
331 write!(f, "{}({})", func, expr)
332 }
333 }
334 CallBinary {
335 func, expr1, expr2, ..
336 } => {
337 if func.is_infix_op() {
338 write!(f, "({} {} {})", expr1, func, expr2)
339 } else {
340 write!(f, "{}({}, {})", func, expr1, expr2)
341 }
342 }
343 CallVariadic { func, exprs, .. } => {
344 use mz_expr::VariadicFunc::*;
345 match func {
346 ArrayCreate(..) => {
347 let exprs = separated(", ", exprs);
348 write!(f, "array[{}]", exprs)
349 }
350 ListCreate(..) => {
351 let exprs = separated(", ", exprs);
352 write!(f, "list[{}]", exprs)
353 }
354 RecordCreate(..) => {
355 let exprs = separated(", ", exprs);
356 write!(f, "row({})", exprs)
357 }
358 func if func.is_infix_op() && exprs.len() > 1 => {

Callers

nothing calls this directly

Calls 12

isMethod · 0.80
separatedFunction · 0.50
as_refMethod · 0.45
is_infix_opMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
is_emptyMethod · 0.45
is_count_asteriskMethod · 0.45
into_exprMethod · 0.45
exprMethod · 0.45

Tested by

no test coverage detected