ClickHouse / ClickHouse/ClickHouse
`ALTER RENAME COLUMN` fails when a metadata expression references a subcolumn
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
### Company or project name
_No response_
### Describe what's wrong
The `ALTER RENAME` is rejected and the table stays unchanged, and the
error mentions a column that was never written in the query:
https://fiddle.clickhouse.com/71c4d00e-1980-4aaa-af70-e506b1c49e25
### Does it reproduce on the most recent release?
Yes
### How to reproduce
```sql
CREATE TABLE t (a Tuple(x UInt64, y UInt64), b UInt64) ENGINE = MergeTree ORDER BY a.x;
ALTER TABLE t RENAME COLUMN a TO z;
-- Code: 47. DB::Exception: Missing columns: 'a.x' while processing: 'a.x', required columns: 'a.x',
-- available columns: ... 'z' 'z.x' 'z.y' 'b'. (UNKNOWN_IDENTIFIER)
```
### Expected behavior
Renaming should behave the same for a subcolumn reference as it already does for a plain one:
```sql
CREATE TABLE t (a Tuple(x UInt64, y UInt64), b UInt64) ENGINE = MergeTree ORDER BY a;
ALTER TABLE t RENAME COLUMN a TO z;
-- Code: 524. DB::Exception: Trying to ALTER RENAME key a column which is a part of key expression. (ALTER_OF_COLUMN_IS_FORBIDDEN)
```
### Error message and/or stacktrace
_No response_
### Related issues and pull requests
_No response_
### Additional context
See: https://github.com/ClickHouse/ClickHouse/pull/114163
Contributor guide
Assessment
This issue has not been assessed yet.