Repository navigation
Commit e4ae236
authored
fix: Coerce aggregate FILTER predicates to boolean (apache#22774)
## Which issue does this PR close?
- Closes apache#22773 .
## Rationale for this change
Aggregate and window aggregate `FILTER` clauses currently fail with an
internal error when the filter condition is `NULL`, even though the
equivalent boolean-typed expression (e.g. `CAST(NULL AS BOOLEAN)`) works
correctly.
This occurs because `FILTER` predicates are not being coerced to
`BOOLEAN` during type coercion.
## What changes are included in this PR?
* Coerce aggregate `FILTER` predicates to `BOOLEAN` during type
coercion.
* Apply the same coercion to window aggregate `FILTER` predicates.
* Add SQL logic tests covering `FILTER (WHERE NULL)` for both aggregate
and window aggregate functions.
## Are these changes tested?
Yes.
Added SQL logic tests covering:
* `COUNT(*) FILTER (WHERE NULL)`
* `COUNT(1) FILTER (WHERE NULL)`
* `SUM(1) FILTER (WHERE NULL)`
* `AVG(1) FILTER (WHERE NULL)`
* Window aggregate variants using `FILTER (WHERE NULL)`
## Are there any user-facing changes?
Yes.
Queries using `FILTER (WHERE NULL)` no longer fail with an internal
error and now return the expected results. Also, no changes were made to
any public APIs1 parent c83a981 commit e4ae236
2 files changed
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
715 | 715 | | |
716 | 716 | | |
717 | 717 | | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
718 | 724 | | |
719 | 725 | | |
720 | 726 | | |
| |||
752 | 758 | | |
753 | 759 | | |
754 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
755 | 766 | | |
756 | 767 | | |
757 | 768 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6339 | 6339 | | |
6340 | 6340 | | |
6341 | 6341 | | |
| 6342 | + | |
| 6343 | + | |
| 6344 | + | |
| 6345 | + | |
| 6346 | + | |
| 6347 | + | |
| 6348 | + | |
| 6349 | + | |
| 6350 | + | |
| 6351 | + | |
| 6352 | + | |
| 6353 | + | |
| 6354 | + | |
| 6355 | + | |
| 6356 | + | |
| 6357 | + | |
| 6358 | + | |
| 6359 | + | |
| 6360 | + | |
| 6361 | + | |
| 6362 | + | |
| 6363 | + | |
| 6364 | + | |
| 6365 | + | |
| 6366 | + | |
| 6367 | + | |
| 6368 | + | |
| 6369 | + | |
| 6370 | + | |
| 6371 | + | |
| 6372 | + | |
| 6373 | + | |
| 6374 | + | |
| 6375 | + | |
6342 | 6376 | | |
6343 | 6377 | | |
6344 | 6378 | | |
| |||
0 commit comments