databend
databend copied to clipboard
bug: Duplicated table name numbers in the same FROM clause
Summary root@localhost:8000/default> select * from (select number as a from numbers(10)), (select number as b from numbers(2)); error: APIError: QueryFailed: [1065]Duplicated table name numbers in the same FROM clause
I tried this SQL in Snowflake and Clickhouse, but both failed to execute.
Clickhouse prompted Code: 206. DB::Exception: JOIN , ... no alias for subquery or table function SELECT number AS a FROM numbers(10). In scope SELECT * FROM (SELECT number AS a FROM numbers(10)), (SELECT number AS b FROM numbers(2)) (set joined_subquery_requires_alias = 0 to disable restriction). (ALIAS_REQUIRED)
In fact, this SQL is indeed as ClickHouse suggests, and does not explicitly distinguish table names to differentiate numbers.Therefore, after modifying the SQL to
SELECT *
FROM
(SELECT number AS a FROM numbers(10)) AS t1,
(SELECT number AS b FROM numbers(2)) AS t2;
both ClickHouse and Databend can execute it.