ClickHouse icon indicating copy to clipboard operation
ClickHouse copied to clipboard

Resolve identifier supported for constants and CTE. Actual node type COLUMN with `allow_experimental_analyzer=1, join_use_nulls=1`

Open UnamedRus opened this issue 1 year ago • 0 comments

You have to provide the following information whenever possible.

Describe what's wrong 24.1 https://fiddle.clickhouse.com/5ada3a58-e2ea-4547-8abf-cd8888cf8cc8 23.3 https://fiddle.clickhouse.com/2672375c-0bda-49b3-865e-6004c004e281 working correctly

WITH ws_wh AS
    (
        SELECT
            ws1.ws_order_number
        FROM
        (
            SELECT
                1 AS ws_order_number,
                1 AS ws_warehouse_sk
        ) AS ws1,
        (
            SELECT
                1 AS ws_order_number,
                2 AS ws_warehouse_sk
        ) AS ws2
        WHERE (ws1.ws_order_number = ws2.ws_order_number) AND (ws1.ws_warehouse_sk != ws2.ws_warehouse_sk)
    )
SELECT COUNT()
FROM
(
    SELECT 1 AS ws_order_number
) AS ws1
WHERE (ws1.ws_order_number IN (
    SELECT ws_order_number
    FROM ws_wh
))
SETTINGS allow_experimental_analyzer = 1,join_use_nulls=1

Received exception from server (version 24.1.1):
Code: 1. DB::Exception: Received from localhost:9000. DB::Exception: Resolve identifier 'ws_order_number' from parent scope only supported for constants and CTE. Actual ws1.ws_order_number node type COLUMN. In scope (SELECT ws_order_number FROM ws_wh). (UNSUPPORTED_METHOD)

Works for SETTINGS allow_experimental_analyzer = 0,join_use_nulls=1 or SETTINGS allow_experimental_analyzer = 1,join_use_nulls=0

Does it reproduce on recent release?

Yes

Received exception from server (version 24.1.1):
Code: 1. DB::Exception: Received from localhost:9000. DB::Exception: Resolve identifier 'ws_order_number' from parent scope only supported for constants and CTE. Actual ws1.ws_order_number node type COLUMN. In scope (SELECT ws_order_number FROM ws_wh). (UNSUPPORTED_METHOD)
(query: with ws_wh as
(select ws1.ws_order_number,ws1.ws_warehouse_sk wh1,ws2.ws_warehouse_sk wh2
 from web_sales ws1,web_sales ws2
 where ws1.ws_order_number = ws2.ws_order_number
   and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
 select  
   count(distinct ws_order_number) as "order count"
  ,sum(ws_ext_ship_cost) as "total shipping cost"
  ,sum(ws_net_profit) as "total net profit"
from
   web_sales ws1
  ,date_dim
  ,customer_address
  ,web_site
where
    d_date between '1999-5-01' and 
           (cast('1999-5-01' as date) + INTERVAL 60 day)
and ws1.ws_ship_date_sk = d_date_sk
and ws1.ws_ship_addr_sk = ca_address_sk
and ca_state = 'TX'
and ws1.ws_web_site_sk = web_site_sk
and web_company_name = 'pri'
and ws1.ws_order_number in (select ws_order_number
                            from ws_wh)
and ws1.ws_order_number in (select wr_order_number
                            from web_returns,ws_wh
                            where wr_order_number = ws_wh.ws_order_number)
order by count(distinct ws_order_number)
LIMIT 100;)

UnamedRus avatar Jan 19 '24 13:01 UnamedRus