Skip to content

Wrong DB used when Distribute table join Local table #10471

Closed

Description

@ljr900723

There is a DB named "jrliu_test" I created before.
Then I connect to Clickhouse like this:
clickhouse-client -m --database=jrliu_test

Then I execute the followint SQLs:

  1. create table "test_table_local"
    CREATE TABLE IF NOT EXISTS jrliu_test.test_table_local ON CLUSTER '{cluster}' ( join_key String, value String ) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY tuple();

  2. create table "test_table_distribute"
    CREATE TABLE jrliu_test.test_table_distribute ON CLUSTER '{cluster}' AS jrliu_test.test_table_local ENGINE = Distributed('{cluster}', 'jrliu_test', test_table_local);

  3. create table "test_table_join"
    CREATE TABLE IF NOT EXISTS jrliu_test.test_table_join ON CLUSTER '{cluster}' ( join_key String, value String ) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY tuple();

  4. insert data to "test_table_local" and "test_table_join"
    INSERT INTO jrliu_test.test_table_local FORMAT Values ('key1', 'value1'), ('key2', 'value2');
    INSERT INTO jrliu_test.test_table_join FORMAT Values ('key1', 'value1'), ('key3', 'value3');

  5. execute query
    5.1 execute Local table join Local table
    SELECT * FROM test_table_local as t INNER JOIN test_table_join as j ON t.join_key = j.join_key;
    (This query return result without any errors)
    5.2 execute Distribute table join Local table
    SELECT * FROM test_table_distribute as t INNER JOIN test_table_join as j ON t.join_key = j.join_key;
    (This query return error: Code: 60, e.displayText() = DB::Exception: Received from clickhouse-stg-af-shard1-replica0:9000. DB::Exception: Table default.test_table_join doesn't exist.. (version 19.14.7.15 (official build)))

Table "test_table_join" should be found in "jrliu_test" database but not in "default".

Server version: 19.14.7.15

Activity

  1. added
    bug
    on Apr 24, 2020
  2. added
    comp-distributed
    on Apr 27, 2020
  3. self-assigned this
    on May 6, 2020
  4. 4ertus2 commented on May 6, 2020

    @4ertus2
    Contributor

    It's most probable duplicate for #4756
    Need reproduction on 20.4+

  5. azat commented on May 6, 2020

    @azat
    Member

    AFAICS the problem here is different, distributed engine do not account current database, IOW:

    use system;
    create table dist_parts as parts engine=Distributed(test_cluster_two_shards, currentDatabase(), parts);
    select * from system.dist_parts l join parts r using name format Null;

    Will trigger the following error:

    Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Received from 127.0.0.2:9000. DB::Exception: Table default.parts doesn't exist.. 
    

    But note, that the error is only on the remote shard, on the local shard it is ok

  6. 4ertus2 commented on Oct 2, 2020

    @4ertus2
    Contributor

    Could be related #15538

  7. removed their assignment
    on Oct 16, 2020
  8. dzeban commented on Nov 11, 2020

    @dzeban

    Still reproduced on the latest stable version 20.10.3.30, so fix in #15538 doesn't help here.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcomp-distributed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions