Skip to content

Joining MySQL table and MergeTree table causes 'Missing columns' #14614

@asabirov

Description

@asabirov

Describe the bug
If you make a query to MySQL Engine Table with joined MergeTree Engine Table, you use any columns of the latter.

How to reproduce

  • ClickHouse server 20.8.2
  • ClickHouse client version 20.8.2.3 (official build).
CREATE TABLE mysql_table
(
    `id` UInt64,
    `name` Nullable(String),
)
ENGINE = MySQL('test:3306', 'test', 'test', 'test', 'test');
CREATE TABLE ch_table
(
    `id` UInt64,
    `mysql_item_id` UInt64,
    `d` DateTime
)
ENGINE = MergeTree()
PARTITION BY toYYYYMM(d)
ORDER BY d;

Query

    SELECT *
    FROM mysql_table AS t_mysql_table
    LEFT JOIN ch_table AS t_ch_table 
         ON t_ch_table.mysql_item_id = t_mysql_table.id
    WHERE t_ch_table.id > 100

Expected behavior
Returns empty result without errors.

Error message and/or stacktrace

Code: 47. DB::Exception: Received from test:9000. DB::Exception: Missing columns: 't_ch_table.id' while processing query: 't_ch_table.id > 100', required columns: 't_ch_table.id', source columns: 'id', 'name'. 

Metadata

Metadata

Assignees

Labels

bugConfirmed user-visible misbehaviour in official releasecomp-joinsJOINs end-to-end (planning hooks + runtime join operators/algorithms). Single bucket to avoid pla...

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions