Skip to content

Analyzer: (Almost) constant expression can not be resolved from parent scope #71828

@seriych

Description

@seriych

ClickHouse v24.3+ (including latest lts v24.8 and latest in fiddle v24.10)

Exception:

with
    arrayMap(x -> x + 1, [0]) as a
select
    1
where
    1 in (select arrayJoin(a))
settings allow_experimental_analyzer = 1;

Received exception from server (version 24.10.1):
Code: 1. DB::Exception: Received from localhost:9000. DB::Exception: Resolve identifier 'a' from parent scope only supported for constants and CTE. Actual arrayMap(x -> (x + 1), [0]) AS a node type FUNCTION. In scope (SELECT arrayJoin(a)). (UNSUPPORTED_METHOD)

In my mind this can't be a scope issue because this query works fine:

with
    [1] as a
select
    1
where
    1 in (select arrayJoin(a))
settings allow_experimental_analyzer = 1;
1

And arrayMap(x -> x + 1, [0]) as a is constant (known at the time the SQL query is parsed) and works fine with old analyzer:

with
    arrayMap(x -> x + 1, [0]) as a
select
    1
where
    1 in (select arrayJoin(a))
settings allow_experimental_analyzer = 0;
1

Sample queries:
https://fiddle.clickhouse.com/6a9e9d11-4529-41e2-b7c1-b2c0cbce32dd

Metadata

Metadata

Assignees

Labels

analyzerIssues and pull-requests related to new analyzerbugConfirmed user-visible misbehaviour in official release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions