ClickHouse / ClickHouse

ClickHouse® is a free analytics DBMS for big data
https://clickhouse.com
Apache License 2.0
34.66k stars 6.52k forks source link

Distributed tables. Depended aliases. Exception: Multiple expressions. MULTIPLE_EXPRESSIONS_FOR_ALIAS. #62184

Open alexeyrusnak opened 1 month ago

alexeyrusnak commented 1 month ago

Hi

Table has 2 aliases, one depends on other.

It worked good for versions before 24.3 for all tables: distributed and not distributed.

For versions >= 24.3 it is broken for distributed (only) tables. For simple tables it works.

Works for 24.2.2.71 and earlier https://fiddle.clickhouse.com/89f370e7-4598-4a9c-8b01-3de68e2188cc

Broken for Latest https://fiddle.clickhouse.com/ca7a3d45-6472-483d-ba0d-681b8d2e4074

Works for latest if simple table (not distributed) https://fiddle.clickhouse.com/f513fd16-ed40-456d-b2cb-346535fdd8f1

` CREATE TABLE test ( host String, host_other String alias empty(host) ? 'Unknown' : replaceOne(host, '*', 'www'), host_category UInt64 alias toUInt64(host_other = 'www' ? 1 : 0) ) ENGINE = Memory;

create table if not exists test_dist AS test engine = Distributed('default', 'default', 'test', rand());

INSERT INTO test VALUES ('host'); INSERT INTO test VALUES ('www'); INSERT INTO test VALUES ('domain');

SELECT t.host_other, anyLast(t.host_category) host_category_agg_anyLast, uniq(t.host_category) host_category_agg_uniq FROM test_dist t GROUP BY t.host_other; `

SaltTan commented 1 month ago

A workaround is settings allow_experimental_analyzer=0 https://fiddle.clickhouse.com/1bc566c9-9c3f-444d-b8ed-795c35f01ae7