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

"Table default.xxx doesn't exist.." Exception occurs when both distributed and local tables are involved #19278

Closed
dgzdot opened this issue Jan 19, 2021 · 3 comments

Comments

@dgzdot
Copy link

dgzdot commented Jan 19, 2021

clickhouse server version 20.8.3.18

reproduce step:

local table:
SHOW CREATE TABLE test_query_local;
CREATE TABLE dgz.test_query_local
(
id UInt64,
repo String
)
ENGINE = ReplicatedMergeTree('/clickhouse/dgz/tables/{shard}/test_query_local', '{replica}')
ORDER BY id
SETTINGS index_granularity = 8192;

distributed table:
SHOW CREATE TABLE test_query_all;
CREATE TABLE dgz.test_query_all
(
id UInt64,
repo String
)
ENGINE = Distributed('xxx', 'dgz', 'test_query_local', rand());

execute sql:
use dgz;
SELECT uniq(id) FROM test_query_all WHERE repo = '100' AND id IN (SELECT id FROM test_query_local WHERE repo = '200');

then exception occurs:
Received exception from server (version 20.8.3):
Code: 60. DB::Exception: Received from 127.0.0.1:9000. DB::Exception: Received from xxxx:9000. DB::Exception: Table default.test_query_local doesn't exist..

Why this sql try to search table in default database in remote clickhouse instance.

@dgzdot dgzdot added the bug Confirmed user-visible misbehaviour in official release label Jan 19, 2021
@den-crane den-crane added question Question? unexpected behaviour and removed bug Confirmed user-visible misbehaviour in official release labels Jan 19, 2021
@den-crane
Copy link
Contributor

CH uses default database in this case by design.

#12489
#15898
#10471

you need to specify database: dgz.test_query_local

SELECT uniq(id) FROM test_query_all WHERE repo = '100' AND id IN (SELECT id FROM dgz.test_query_local WHERE repo = '200');

@dgzdot
Copy link
Author

dgzdot commented Jan 19, 2021

CH uses default database in this case by design.

#12489
#15898
#10471

you need to specify database: dgz.test_query_local

SELECT uniq(id) FROM test_query_all WHERE repo = '100' AND id IN (SELECT id FROM dgz.test_query_local WHERE repo = '200');

What are the reasons for this design? In general, SQL is always executed in the current database, such a design violates common sense.

@den-crane
Copy link
Contributor

den-crane commented Jan 19, 2021

What are the reasons for this design?

Basically: it is what it is

#12489 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants