Skip to content

Fix wrong database for JOIN w/o explicit database in distributed queries - #33611

Merged
vdimir merged 4 commits into
ClickHouse:masterfrom
azat:dist-current-database
Jan 14, 2022
Merged

vdimir merged 4 commits into
ClickHouse:masterfrom
azat:dist-current-database

Conversation

@azat

@azat azat commented Jan 13, 2022 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix wrong database for JOIN w/o explicit database in distributed queries (Fixes: #10471)

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Jan 13, 2022
@azat
azat force-pushed the dist-current-database branch 2 times, most recently from ee09ad6 to d0ea3c7 Compare January 13, 2022 18:49
@azat
azat marked this pull request as draft January 13, 2022 19:27
azat added 4 commits January 14, 2022 11:18
This will fix rewriting of distributed queries with GLOBAL IN

v2: get external tables only for non-global context

Signed-off-by: Azat Khuzhin <[email protected]>
…ueries

This should fix JOIN w/o explicit database.

v2: rewrite only JOIN section, since there is old behavior that relies
on default_database for IN section, see [1]:
- 01487_distributed_in_not_default_db
- 01152_cross_replication

  [1]: https://s3.amazonaws.com/clickhouse-test-reports/33611/d0ea3c76fa51131171b1825939680867eb1c04da/fast_test__actions_.html

Signed-off-by: Azat Khuzhin <[email protected]>
@azat
azat force-pushed the dist-current-database branch from d0ea3c7 to c341b3b Compare January 14, 2022 08:24
@azat
azat marked this pull request as ready for review January 14, 2022 08:24
@vdimir vdimir self-assigned this Jan 14, 2022
if (identifier.compound())
return;
/// There is temporary table with such name, should not be rewritten.
if (external_tables.count(identifier.shortName()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (external_tables.count(identifier.shortName()))
if (external_tables.contains(identifier.shortName()))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, looks better, the reason I prefer to use count over contains is that before I have to remember about arcadia built that has pretty limited c++20 support, and contains wasn't supported, but anyway this is not relevant anymore.

@vdimir
vdimir merged commit 1254225 into ClickHouse:master Jan 14, 2022
@azat
azat deleted the dist-current-database branch January 14, 2022 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong DB used when Distribute table join Local table

3 participants