Repository navigation
Commit e48d69e
committed
Fix logical error in correlated subqueries with group_by_use_nulls
A correlated scalar subquery referencing an outer `GROUP BY` key that
becomes `Nullable` via `group_by_use_nulls` (`GROUPING SETS` / `ROLLUP` /
`CUBE` / `WITH TOTALS`) aborted with:
Logical error: Unexpected return type from toString. Expected String. Got Nullable(String)
The `group_by_use_nulls` nullability walk in `resolveExpressionNode`
stops at the subquery's own query scope, so a correlated column kept its
non-`Nullable` type while decorrelation fed in the real `Nullable`
column, mismatching a baked function result type (`toString` -> `String`
vs `Nullable(String)`).
Continue the walk past a subquery's query boundary for correlated
columns and convert the column to `Nullable` in place, preserving the
node identity shared with the subquery's correlated-columns set (which
the planner matches by identity).
Discovered by the AST fuzzer in the `amd_msan` stress test:
https://github.com/ClickHouse/ClickHouse/actions/runs/28286443407/job/83839128485?pr=108685
Related: ClickHouse#1086851 parent b17aed5 commit e48d69e
3 files changed
Lines changed: 120 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3075 | 3075 | | |
3076 | 3076 | | |
3077 | 3077 | | |
| 3078 | + | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
3078 | 3096 | | |
3079 | 3097 | | |
3080 | 3098 | | |
| |||
3519 | 3537 | | |
3520 | 3538 | | |
3521 | 3539 | | |
| 3540 | + | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + | |
3522 | 3544 | | |
3523 | 3545 | | |
3524 | 3546 | | |
3525 | 3547 | | |
3526 | 3548 | | |
3527 | 3549 | | |
3528 | 3550 | | |
3529 | | - | |
3530 | | - | |
3531 | | - | |
3532 | | - | |
3533 | | - | |
3534 | | - | |
3535 | | - | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
3536 | 3571 | | |
3537 | 3572 | | |
3538 | 3573 | | |
3539 | 3574 | | |
3540 | | - | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
3541 | 3582 | | |
3542 | | - | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
3543 | 3588 | | |
3544 | 3589 | | |
3545 | 3590 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments