Set correct column alias state if a derived table includes a column name list
Details
| Detail name | Value |
|---|---|
| Changelog Number | 18069 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | Exasol 8.9.0 |
| Fix Versions | Exasol 8.23.0 |
| Resolution Date | 2023-11-06 |
The WITH clause (and also statements such as CREATE TABLE AS and CREATE VIEW AS) requires that its columns have well-formed names. Expressions that are not simple column references must be named explicitly with an alias.
One way to name columns is to give the optional list of column names for a derived table. Unfortunately, such columns are not marked as aliases because of a bug. This will lead to an error for expressions that are not simple column references and which are not given an alias elsewhere in the query.
Example
-- Setup
create schema S;
create table A (A1 int);
-- Expected: Success
-- Observed: Error "must name expression in query W with a column alias"
with W as (select A1_PLUS_1
from (select A1 + 1
from A) as DT(A1_PLUS_1))
select *
from W;
Workaround
Give the column a name elsewhere in the query. For example:
with W as (select A1_PLUS_1
from (select A1 + 1 as A1_PLUS_1 -- alias added here
from A) as DT(A1_PLUS_1))
select *
from W;
Fix
This change fixes the bug described above.