ClickHouse / ClickHouse/ClickHouse

Send temporary tables of all engines when executing a distributed query

Open
#55,162 4 comments 0 reactions 0 assignees View on GitHub
comp-distributed external feature unexpected behaviour
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

**Describe what's wrong**

Temporary table with Log Engine is not sent to remote shards when joined to distributed table

**Does it reproduce on recent release?**
Reproduces on 23.8.2.7

**How to reproduce**

```sql
-- tables creation on individual shards + distributed creation and loading
drop table if exists default.repro_local ON CLUSTER 'clusterName';
create table default.repro_local ON CLUSTER 'clusterName' ( col1 Int64, col2 Date)
ENGINE = MergeTree PARTITION BY toStartOfMonth(col2) ORDER BY (col1, col2) ;

drop table if exists default.distr_repro_local ON CLUSTER 'clusterName';
create table default.distr_repro_local ON CLUSTER 'clusterName' ( col1 Int64, col2 Date)
ENGINE = Distributed('clusterName', 'default', 'repro_local', rand());

insert into default.distr_repro_local select number, toDate('2010-01-01') + number as d FROM numbers(365);
select count() from default.distr_repro_local drl ; --365
select count() from default.repro_local drl ; --365

drop temporary table if exists temp_logengine;
create temporary table temp_logengine ( col1 Int64) engine=Log ;
insert into temp_logengine select number as d FROM numbers(365);

select count() from default.repro_local where col1 in (select col1 from temp_logengine);
-- works

select count() from default.distr_repro_local where col1 in (select col1 from temp_logengine);
-- gets error " Table default.temp_logengine does not exist"

select count() from default.distr_repro_local where col1 GLOBAL in (select col1 from temp_logengine);
-- works

drop temporary table if exists temp_memengine;
create temporary table temp_memengine ( col1 Int64) ;
insert into temp_memengine select number as d FROM numbers(365);

select count() from default.repro_local where col1 in (select col1 from temp_memengine);
-- works

select count() from default.distr_repro_local where col1 in (select col1 from temp_memengine);
-- works

select count() from default.distr_repro_local where col1 GLOBAL in (select col1 from temp_memengine);
-- works
```

**Expected behavior**

Query is joining distributed table with any temporary table is expected to correctly send temporary table to the shards

**Error message and/or stacktrace**
```
SQL Error [1002]: ClickHouse exception, code: 1002, host: clickhouse1.host.net, port: 8123; Code: 60. DB::Exception: Received from clickhouse2.host.net:9000. DB::Exception: Table default.temp_logengine does not exist: While processing col1 IN ((SELECT col1 FROM temp_logengine) AS _subquery56). (UNKNOWN_TABLE) (version 23.8.2.7 (official build))
```

**Additional context**

Problem can be easily worked around by using GLOBAL IN, or by setting prefer_global_in_and_join=1.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.