(
&mut self,
expr: Expr<Aug>,
filter: Option<Box<Expr<Aug>>>,
distinct: bool,
over: Option<WindowSpec<Aug>>,
)
| 343 | } |
| 344 | |
| 345 | fn plan_bool_or( |
| 346 | &mut self, |
| 347 | expr: Expr<Aug>, |
| 348 | filter: Option<Box<Expr<Aug>>>, |
| 349 | distinct: bool, |
| 350 | over: Option<WindowSpec<Aug>>, |
| 351 | ) -> Expr<Aug> { |
| 352 | // The code below converts `bool_or(x)`z into: |
| 353 | // |
| 354 | // sum((x OR false)::int4) > 0 |
| 355 | // |
| 356 | // It is tempting to use `count` instead, but count does not return NULL |
| 357 | // when all input values are NULL, as required. |
| 358 | // |
| 359 | // The `(x OR false)` expression implicitly casts `x` to `bool` without |
| 360 | // changing its logical value. It is tempting to use `x::bool` instead, |
| 361 | // but that performs an explicit cast, and to match PostgreSQL we must |
| 362 | // perform only an implicit cast. |
| 363 | let sum = self.plan_agg( |
| 364 | self.scx |
| 365 | .dangerous_resolve_name(vec![PG_CATALOG_SCHEMA, "sum"]), |
| 366 | expr.or(Expr::Value(Value::Boolean(false))) |
| 367 | .cast(self.int32_data_type()), |
| 368 | vec![], |
| 369 | filter, |
| 370 | distinct, |
| 371 | over, |
| 372 | ); |
| 373 | sum.gt(Expr::Value(Value::Number(0.to_string()))) |
| 374 | } |
| 375 | |
| 376 | fn rewrite_function(&mut self, func: &Function<Aug>) -> Option<(Ident, Expr<Aug>)> { |
| 377 | if let Function { |
no test coverage detected