Skip to content

Shadow variables in higher order functions/improve error message for naming collisions #5046

@buyology

Description

@buyology

On ClickHouse 19.4.54416:

:) select sum(c1) v FROM (select 1 c1, ['v'] c2) WHERE arrayExists((v) -> v == 'v')
SELECT sum(c1) AS v
FROM
(
    SELECT
        1 AS c1,
        ['v'] AS c2
)
WHERE arrayExists(v -> (v = 'v'))

Received exception from server (version 19.4.54416):
Code: 184. DB::Exception: Received from localhost:9000. 
DB::Exception: Aggregate function sum(c1) is found in WHERE or PREWHERE in query.

0 rows in set. Elapsed: 0.101 sec.

I would expect the arguments specified in arrayExists to shadow any column aliases or at least have the error message hint that a collision might be the case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions