You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Alias columns incorrect behaviour in join queries #47432
create or replacetablet1
engine = MergeTree()
order by tuple()
asselect1as user_id, 2as level
;
create or replacetablet2
engine = MergeTree()
order by tuple()
asselect1as user_id, 'website'as event_source, '2023-01-01 00:00:00'::DateTime astimestamp
;
altertable t2
add column dateDate alias toDate(timestamp)
;
SELECT
any(t2.date) as any_val
FROM t1 AS t1
LEFT JOIN t2 as t2
ON (t1.user_id=t2.user_id)
Clickhouse 23.2.1.2537 throws the following exception:
SQL Error [47] [07000]: Code: 47. DB::Exception: Unknown column: date, there are only columns user_id. (UNKNOWN_IDENTIFIER) (version 23.2.1.2537 (official build))¶, server ClickHouseNode [uri=http://<url>:<port>/<db>, options={use_server_time_zone=false,profile=dbt_web,use_time_zone=false}]@-106769119
And the expected behaviour would be to return 1 row with 2023-01-01.
Replacing an alias column with a stored one works OK:
SELECT
any(t2.event_source) as any_val
FROM t1 AS t1
LEFT JOIN t2 as t2
ON (t1.user_id=t2.user_id)
returns website as expected.
Also, wrapping the table in a subquery (with an explicit setting for * including alias columns) fixes the issue:
SELECT
any(t2.date) as any_val
FROMuser_data_db.t1AS t1
LEFT JOIN (select*fromuser_data_db.t2) as t2
ON (t1.user_id=t2.user_id)
SETTINGS asterisk_include_alias_columns=1
Activity
kitaisreal commentedon Mar 10, 2023
Related to #42648. Works in new analyzer.
Close: #47432