(&self, f: &mut fmt::Formatter<'_>)
| 299 | |
| 300 | impl 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 => { |
nothing calls this directly
no test coverage detected