Skip to content

Analyzer: Skipping indexes don't work with VIEWs #69373

@nitzangr

Description

@nitzangr

Describe the unexpected behaviour
Newer versions of clickhouse don't use indices on views which are defined as union

How to reproduce

CREATE TABLE tab_v1
(
    content String,
    INDEX idx_content_bloom content TYPE bloom_filter(0.01)
)
ENGINE = MergeTree
ORDER BY content

CREATE TABLE tab_v2
(
    content String,
    INDEX idx_content_bloom content TYPE bloom_filter(0.01)
)
ENGINE = MergeTree
ORDER BY content


CREATE VIEW tab_v3
AS SELECT *
FROM tab_v1
UNION ALL
SELECT *
FROM tab_v2

INSERT INTO tab_v1 (content) VALUES ('aaa bbb'), ('ccc ddd')
INSERT INTO tab_v2 (content) VALUES ('eee fff'), ('ggg hhh')


SELECT *
FROM tab_v3
WHERE content = 'iii'
SETTINGS force_data_skipping_indices='idx_content_bloom'

Expected behavior
Running on version 24.8.4.13 results on this:

Code: 277. DB::Exception: Received from localhost:9000. DB::Exception: Index `idx_content_bloom` is not used and setting 'force_data_skipping_indices' contains it. (INDEX_NOT_USED)

However, works fine on 23.10.3

Additional context
Just found a workaround for this, disabling allow_experimental_analyzer:

SELECT *
FROM tab_v3
WHERE content = 'iii'
SETTINGS force_data_skipping_indices='idx_content_bloom',allow_experimental_analyzer=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzerIssues and pull-requests related to new analyzeranalyzer-importantunexpected behaviourResult is unexpected, but not entirely wrong at the same time.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions