Skip to content

Argument at index 1 for function ilike must be constant: while executing. (ILLEGAL_COLUMN) #36279

Closed

Description

@orloffv

How to reproduce

CREATE TABLE test_local on cluster '{cluster}' (text String, text2 String) ENGINE = MergeTree() ORDER BY text;
CREATE TABLE test_distruted (text String, text2 String) ENGINE = Distributed('{cluster}', currentDatabase(), test_local);
INSERT INTO test_distruted SELECT randomString(100) as text, randomString(100) as tex2 from system.numbers limit 1;
SELECT COUNT() AS count
FROM test_distruted
INNER JOIN
(
    SELECT text
    FROM test_distruted
    WHERE (text ILIKE '%text-for-search%') AND (text2 ILIKE '%text-for-search%')
) USING (text)
WHERE (text ILIKE '%text-for-search%') AND (text2 ILIKE '%text-for-search%')
Received exception from server (version 22.3.2):
Code: 44. DB::Exception: Received from xxx. DB::Exception: Argument at index 1 for function ilike must be constant: while executing 'FUNCTION ilike(text2 : 3, '%text-for-search%' : 0) -> ilike(text2, '%text-for-search%') UInt8 : 4'. (ILLEGAL_COLUMN)

Simple query - it works

SELECT text
FROM test_distruted
WHERE (text ILIKE '%text-for-search%') AND (text2 ILIKE '%text-for-search%')

Query id: 4960850f-6e27-4a10-a7a0-c9182fdf27ac

Ok.

0 rows in set. Elapsed: 0.010 sec.

Versions with bug:
22.3.2, 21.11.11

Activity

  1. added
    potential bug
    on Apr 14, 2022
  2. self-assigned this
    on Apr 14, 2022
  3. orloffv commented on Apr 14, 2022

    @orloffv
    ContributorAuthor

    if i change one of like expressions
    like this - it works correctly

    SELECT COUNT() AS count
    FROM test_distruted
    INNER JOIN
    (
        SELECT text
        FROM test_distruted
        WHERE (text ILIKE '%text-for-search%') AND (text2 ILIKE '%another-text%')
    ) USING (text)
    WHERE (text ILIKE '%text-for-search%') AND (text2 ILIKE '%another-text%')
    
    Query id: c37e4514-9d53-4cc6-9626-fee0ed0ae800
    
    ┌─count─┐
    │     0 │
    └───────┘
    
    1 rows in set. Elapsed: 0.013 sec.
    
  4. orloffv commented on Apr 20, 2022

    @orloffv
    ContributorAuthor

    @vdimir do u know workaround or fix?

  5. vdimir commented on Apr 21, 2022

    @vdimir
    Member

    Sorry for delay, just started to work on it, investigating right now.

    do u know workaround or fix?

    Workaround is SET optimize_move_to_prewhere = 0;

  6. added
    bug
    and removed
    potential bug
    on May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions