Commit b10af16
committed
fix: CAST(BOOLEAN AS numeric) rejected — true/false now cast to 1/0
BOOLEAN -> INTEGER/BIGINT/FLOAT/DOUBLE failed: the cast string-
roundtripped ('true'/'false') and the numeric parser rejected it.
CAST(true AS INT) -> "Cannot cast 'true' to INTEGER" (was)
-> 1 (now)
CAST(false AS DOUBLE) -> error -> 0
SUM(CAST(pred AS INT)) -> error -> count
Symmetric counterpart to the numeric->BOOLEAN cast (commit 189342b).
Postgres/DuckDB: true -> 1, false -> 0.
Fix: typed BOOLEAN -> numeric branch in ExecuteCast, before the
string fallback. Covers TINYINT/SMALLINT/INTEGER/BIGINT/FLOAT/DOUBLE.
Verified manually:
CAST(true AS INT) / CAST(false AS INT) -> 1 / 0
CAST(true AS BIGINT) / (false AS DOUBLE) -> 1 / 0
int->bool->int roundtrip -> 1
SUM(CAST(x>1 AS INT)) -> counts predicate
Regression int->bool / varchar->bool -> unchanged
Regression int->varchar -> unchanged
Zero physical_planner.cpp fast-path dispatch impact. ExecuteCast
branch only.
This is the architect-spawn pattern's hidden-bug-find for the round:
the SUM(CAST(predicate AS INT)) counting idiom — extremely common
for conditional counts — was completely blocked by the missing
BOOLEAN->numeric cast.1 parent 7514aba commit b10af16
1 file changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4604 | 4604 | | |
4605 | 4605 | | |
4606 | 4606 | | |
| 4607 | + | |
| 4608 | + | |
| 4609 | + | |
| 4610 | + | |
| 4611 | + | |
| 4612 | + | |
| 4613 | + | |
| 4614 | + | |
| 4615 | + | |
| 4616 | + | |
| 4617 | + | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
4607 | 4628 | | |
4608 | 4629 | | |
4609 | 4630 | | |
| |||
0 commit comments