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

Method humanize

src/expr/src/explain/text.rs:1281–1377  ·  view source on GitHub ↗
(
        e: &HumanizedExpr<'a, MirScalarExpr, M>,
        f: &mut fmt::Formatter<'_>,
    )

Source from the content-addressed store, hash-verified

1279
1280impl HumanizeDisplay for MirScalarExpr {
1281 fn humanize<'a, M: HumanizerMode>(
1282 e: &HumanizedExpr<'a, MirScalarExpr, M>,
1283 f: &mut fmt::Formatter<'_>,
1284 ) -> fmt::Result {
1285 use MirScalarExpr::*;
1286
1287 match e.expr {
1288 Column(i, TreatAsEqual(None)) => {
1289 // Delegate to the `HumanizedExpr<'a, _>` implementation (plain column reference).
1290 e.child(i).fmt(f)
1291 }
1292 Column(i, TreatAsEqual(Some(name))) => {
1293 // Delegate to the `HumanizedExpr<'a, _>` implementation (with stored name information)
1294 e.child(&(i, name)).fmt(f)
1295 }
1296 Literal(row, _) => {
1297 // Delegate to the `HumanizedExpr<'a, _>` implementation.
1298 e.child(row).fmt(f)
1299 }
1300 CallUnmaterializable(func) => write!(f, "{}()", func),
1301 CallUnary { func, expr } => {
1302 if let crate::UnaryFunc::Not(_) = *func {
1303 if let CallUnary { func, expr } = expr.as_ref() {
1304 if let Some(is) = func.is() {
1305 let expr = e.child::<MirScalarExpr>(&*expr);
1306 return write!(f, "({}) IS NOT {}", expr, is);
1307 }
1308 }
1309 }
1310 if let Some(is) = func.is() {
1311 let expr = e.child::<MirScalarExpr>(&*expr);
1312 write!(f, "({}) IS {}", expr, is)
1313 } else {
1314 let expr = e.child::<MirScalarExpr>(&*expr);
1315 write!(f, "{}({})", func, expr)
1316 }
1317 }
1318 CallBinary { func, expr1, expr2 } => {
1319 let expr1 = e.child::<MirScalarExpr>(&*expr1);
1320 let expr2 = e.child::<MirScalarExpr>(&*expr2);
1321 if func.is_infix_op() {
1322 write!(f, "({} {} {})", expr1, func, expr2)
1323 } else {
1324 write!(f, "{}({}, {})", func, expr1, expr2)
1325 }
1326 }
1327 CallVariadic { func, exprs } => {
1328 use crate::VariadicFunc::*;
1329 match func {
1330 CaseLiteral(cl) => {
1331 let input = e.child::<MirScalarExpr>(&exprs[0]);
1332 write!(f, "case_lookup {}", input)?;
1333 for entry in &cl.lookup {
1334 let result = e.child::<MirScalarExpr>(&exprs[entry.expr_index]);
1335 write!(f, " when ")?;
1336 e.mode.humanize_datum(entry.literal.unpack_first(), f)?;
1337 write!(f, " then {}", result)?;
1338 }

Callers

nothing calls this directly

Calls 13

childMethod · 0.80
isMethod · 0.80
humanize_datumMethod · 0.80
unpack_firstMethod · 0.80
unwrapMethod · 0.80
lastMethod · 0.80
separatedFunction · 0.50
fmtMethod · 0.45
as_refMethod · 0.45
is_infix_opMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected