Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map inside if statement with default empty map value fails when accessed through distributed table #63637

Closed
tanner-bruce opened this issue May 10, 2024 · 1 comment · Fixed by #63753
Assignees
Labels
analyzer Issues and pull-requests related to new analyzer bug Confirmed user-visible misbehaviour in official release

Comments

@tanner-bruce
Copy link

clickhouse version: 24.4.1.2088

Using if(..., some_map, map()) appears to fail with allow_experimental_analyzer=1 when queried through a distributed table.

our setup:

create table:

    `resource_attributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)),
-- Query through distributed table, analyzer on

SELECT if(1, resource_attributes, map())
FROM tracing.otel_traces
LIMIT 1
FORMAT `Null`
SETTINGS allow_experimental_analyzer = 1

Received exception from server (version 24.4.1):
Code: 10. DB::Exception: Received from localhost:9000. DB::Exception: Not found column if(1_UInt8, __table1.resource_attributes, _CAST([]_Map(Nothing, Nothing), 'Map(Nothing, Nothing)'_String)) in block. There are only columns: __table1.resource_attributes: While executing Remote. (NOT_FOUND_COLUMN_IN_BLOCK)


-- Query through distributed table, analyzer off
SELECT if(1, resource_attributes, map())
FROM tracing.otel_traces
LIMIT 1
FORMAT `Null`
SETTINGS allow_experimental_analyzer = 0

Ok.

0 rows in set. Elapsed: 0.833 sec.


-- Query through local table, analyzer on
SELECT if(1, resource_attributes, map())
FROM tracing.otel_traces_local
LIMIT 1
SETTINGS allow_experimental_analyzer = 1

Query id: e209cf69-2621-476a-8b25-c1e5ed1f5e78

Ok.

0 rows in set. Elapsed: 0.001 sec.

This should reproduce it from what I am seeing:

CREATE TABLE default.bug_repro_local
(
    `id` String CODEC(ZSTD(1)),
    `attributes` Map(LowCardinality(String), String) CODEC(ZSTD(1))
)
ENGINE = MergeTree
ORDER BY (id);

CREATE TABLE default.bug_repro
(
    `id` String CODEC(ZSTD(1)),
    `attributes` Map(LowCardinality(String), String) CODEC(ZSTD(1))
)
ENGINE = Distributed('all-shards', 'default', 'bug_repro_local', rand());

SELECT if(1, attributes, map()) from default.bug_repro limit 1 SETTINGS allow_experimental_analyzer=1;
SELECT if(1, attributes, map()) from default.bug_repro limit 1 SETTINGS allow_experimental_analyzer=0;
SELECT if(1, attributes, map()) from default.bug_repro_local limit 1 SETTINGS allow_experimental_analyzer=1;
@tanner-bruce tanner-bruce added the potential bug To be reviewed by developers and confirmed/rejected. label May 10, 2024
@den-crane
Copy link
Contributor

den-crane commented May 10, 2024

SELECT map() 
from remote('127.0.0.{1,2}', system,one)
SETTINGS allow_experimental_analyzer=0
{}
{}


SELECT map() 
from remote('127.0.0.{1,2}', system,one)
SETTINGS allow_experimental_analyzer=1

DB::Exception: CAST AS Map from array requires nested tuple of 2 elements.

https://fiddle.clickhouse.com/535fe5c1-b10a-465d-bb27-0146058c6a5d

CREATE TABLE bug_repro_local
(
    `attributes` Map(LowCardinality(String), String)
)
ENGINE = Memory as select map('','');

SELECT if(1, attributes, map()) 
from remote('127.0.0.{1,2}', default,bug_repro_local)
limit 1 SETTINGS allow_experimental_analyzer=0
format Pretty;

   +------------+
   | attributes |
   +------------+
1. | {'':''}    |
   +------------+


SELECT if(1, attributes, map()) 
from remote('127.0.0.{1,2}', default,bug_repro_local)
limit 1 SETTINGS allow_experimental_analyzer=1
format Pretty;

DB::Exception: Not found column if(1_UInt8, __table1.attributes,

https://fiddle.clickhouse.com/160b5196-2915-4f60-95ba-a9a85e05044e

@alexey-milovidov alexey-milovidov changed the title [experimental analyzer] map inside if statement with default empty map value fails when accessed through distributed table map inside if statement with default empty map value fails when accessed through distributed table May 12, 2024
@alexey-milovidov alexey-milovidov added bug Confirmed user-visible misbehaviour in official release analyzer Issues and pull-requests related to new analyzer and removed potential bug To be reviewed by developers and confirmed/rejected. labels May 12, 2024
@KochetovNicolai KochetovNicolai self-assigned this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer Issues and pull-requests related to new analyzer bug Confirmed user-visible misbehaviour in official release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants