(
e: &HumanizedExpr<'a, MirScalarExpr, M>,
f: &mut fmt::Formatter<'_>,
)
| 1279 | |
| 1280 | impl 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 | } |
nothing calls this directly
no test coverage detected