(
&mut self,
expr: Expr<Aug>,
filter: Option<Box<Expr<Aug>>>,
distinct: bool,
over: Option<WindowSpec<Aug>>,
)
| 313 | } |
| 314 | |
| 315 | fn plan_bool_and( |
| 316 | &mut self, |
| 317 | expr: Expr<Aug>, |
| 318 | filter: Option<Box<Expr<Aug>>>, |
| 319 | distinct: bool, |
| 320 | over: Option<WindowSpec<Aug>>, |
| 321 | ) -> Expr<Aug> { |
| 322 | // The code below converts `bool_and(x)` into: |
| 323 | // |
| 324 | // sum((NOT x)::int4) = 0 |
| 325 | // |
| 326 | // It is tempting to use `count` instead, but count does not return NULL |
| 327 | // when all input values are NULL, as required. |
| 328 | // |
| 329 | // The `NOT x` expression has the side effect of implicitly casting `x` |
| 330 | // to `bool`. We intentionally do not write `NOT x::bool`, because that |
| 331 | // would perform an explicit cast, and to match PostgreSQL we must |
| 332 | // perform only an implicit cast. |
| 333 | let sum = self.plan_agg( |
| 334 | self.scx |
| 335 | .dangerous_resolve_name(vec![PG_CATALOG_SCHEMA, "sum"]), |
| 336 | expr.negate().cast(self.int32_data_type()), |
| 337 | vec![], |
| 338 | filter, |
| 339 | distinct, |
| 340 | over, |
| 341 | ); |
| 342 | sum.equals(Expr::Value(Value::Number(0.to_string()))) |
| 343 | } |
| 344 | |
| 345 | fn plan_bool_or( |
| 346 | &mut self, |
no test coverage detected