create table t1 (c1 text);
-- good
select case when (EXISTS (select 1))
then count(*) over (partition by 1) else 1 end from t1 as ref_0;
-- good
select case when (EXISTS (select 1 where ref_0.c1))
then 1 else 1 end from t1 as ref_0;
-- bad
select case when (EXISTS (select 1 where ref_0.c1))
then count(*) over (partition by 1) else 1 end from t1 as ref_0;
2. What did you expect to see? (Required)
empty set.
3. What did you see instead (Required)
ERROR 1054 (42S22): Unknown column 'ref_0.c1' in 'where clause'
4. What is your TiDB version? (Required)
Release Version: v8.5.0-alpha-184-g1c059a1216
Edition: Community
Git Commit Hash: 1c059a1216db711e2cb56ea9f3d1ad8c23db6327
Git Branch: HEAD
UTC Build Time: 2024-11-21 04:56:22
GoVersion: go1.23.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv
Bug Report
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
empty set.
3. What did you see instead (Required)
4. What is your TiDB version? (Required)