pingcap / pingcap/tidb

Unexpected syntax error: Unknown column 'ref_0.c1' in 'where clause'

Open
#57,594 1 comment 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
affects-8.5 severity/major sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

### 1. Minimal reproduce step (Required)
```sql
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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.