ClickHouse/tests/queries/0_stateless/01407_lambda_arrayJoin.sql
Azat Khuzhin 308e094d04 Fix arrayJoin() capturing in lambda
Fixes the following LOGICAL_ERROR:

    $ clickhouse-client -q 'select arrayFilter((a) -> ((a, arrayJoin([[]])) IN (Null, [Null])), [])'
    2020.08.16 00:32:01.967102 [ 1744189 ] {b40a5ebd-d710-4f03-bb18-57db67de1181} <Error> : Logical error: 'Lambda captured argument arrayJoin(array(array())) not found in required columns.'.
    clickhouse-server: ../src/Common/Exception.cpp:45: DB::Exception::Exception(const string&, int): Assertion `false' failed.

Since there are multiple input columns for arrayJoin():

    (gdb) p captured_names_
    $6 = std::vector of length 3, capacity 4 = {"arrayJoin(array(array()))", "arrayJoin(array(array()))", "__set"}

While FunctionCaptureOverloadResolver cannot handle non-unique columns.
2020-08-25 21:06:21 +03:00

7 lines
521 B
SQL

SELECT arrayFilter((a) -> ((a, arrayJoin([])) IN (Null, [Null])), []);
SELECT arrayFilter((a) -> ((a, arrayJoin([[]])) IN (Null, [Null])), []);
-- simplified from the https://clickhouse-test-reports.s3.yandex.net/10373/6c4748a63e7acde2cc3283d96ffec590aae1e724/fuzzer/fuzzer.log#fail1
SELECT * FROM system.one ARRAY JOIN arrayFilter((a) -> ((a, arrayJoin([])) IN (NULL)), []) AS arr_x; -- { serverError 43; }
SELECT * FROM numbers(1) LEFT ARRAY JOIN arrayFilter((x_0, x_1) -> (arrayJoin([]) IN (NULL)), [], []) AS arr_x;