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

Correct sample_block in HashJoin for dict join with join_algorithm #23312

Merged
merged 2 commits into from
Apr 24, 2021

Conversation

vdimir
Copy link
Member

@vdimir vdimir commented Apr 19, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Apr 19, 2021
@vdimir vdimir marked this pull request as ready for review April 20, 2021 09:54
@kitaisreal kitaisreal self-assigned this Apr 20, 2021
@vdimir
Copy link
Member Author

vdimir commented Apr 21, 2021

We got error because with join_algorithm = auto we save key column into sample_block

/// We could remove key columns for LEFT | INNER HashJoin but we should keep them for JoinSwitcher (if any).
bool save_key_columns = !table_join->forceHashJoin() || isRightOrFull(kind);
if (save_key_columns)

But dictionary_reader always uses HashJoin and return block without it.

So, it leads to wrong indices

right_indexes.push_back(saved_block_sample.getPositionByName(tn.second));

and out of bound error
columns[j]->insertFrom(*block.getByPosition(right_indexes[j]).column, row_num);

Copy link
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

The fix looks alright.

@alexey-milovidov
Copy link
Member

@kitaisreal said that you are planning to implement a different fix.
But this is already good enough to merge. Let's merge it and then change to a different solution.

@alexey-milovidov alexey-milovidov merged commit bcede10 into ClickHouse:master Apr 24, 2021
robot-clickhouse pushed a commit that referenced this pull request Apr 24, 2021
robot-clickhouse pushed a commit that referenced this pull request Apr 24, 2021
robot-clickhouse pushed a commit that referenced this pull request Apr 24, 2021
alexey-milovidov added a commit that referenced this pull request Apr 24, 2021
Backport #23312 to 21.5: Correct sample_block in HashJoin for dict join with join_algorithm
alexey-milovidov added a commit that referenced this pull request Apr 24, 2021
Backport #23312 to 21.3: Correct sample_block in HashJoin for dict join with join_algorithm
alexey-milovidov added a commit that referenced this pull request Apr 24, 2021
Backport #23312 to 21.4: Correct sample_block in HashJoin for dict join with join_algorithm
@vdimir vdimir deleted the issue-23002 branch May 14, 2021 10:01
robot-clickhouse pushed a commit that referenced this pull request May 28, 2021
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.

(JOIN with dictionary) HashJoin: container overflow (range check)
4 participants