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
Fix distributed table with a constant sharding key #59606
Fix distributed table with a constant sharding key #59606
Conversation
|
||
CREATE TABLE shard_0.t_local (a Int) ENGINE = Memory; | ||
CREATE TABLE shard_1.t_local (a Int) ENGINE = Memory; | ||
CREATE TABLE t_distr (a Int) ENGINE = Distributed(test_cluster_two_shards_different_databases, '', 't_local', 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A constant sharding key is not very useful but still valid. We must not crash on it.
This is an automated comment for commit 5962ed0 with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page Successful checks
|
const IColumn * column = result.column.get(); | ||
if (const auto * col_const = typeid_cast<const ColumnConst *>(column)) | ||
column = &col_const->getDataColumn(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function StorageDistributed::createSelector()
must return a vector specifying how to split the input block into blocks for each shard according to values of the sharding key. The size of a returned vector must be the same as the number of rows in the input block and must be equal to the number of rows in the result.column
.
This replacement column = &col_const->getDataColumn()
here was wrong because it caused the returned selector to have only one element. Also this replacement was unnecessary because below in this function the createBlockSelector()
function is called which knows how to deal with const columns (see). Thus in this PR I'm just removing this unnecessary and wrong code.
f7f2dbb
to
5962ed0
Compare
…4bfdd8afa78fca304ad823a63d0f49 Cherry pick #59606 to 23.11: Fix distributed table with a constant sharding key
…4bfdd8afa78fca304ad823a63d0f49 Cherry pick #59606 to 23.12: Fix distributed table with a constant sharding key
…bfdd8afa78fca304ad823a63d0f49 Cherry pick #59606 to 24.1: Fix distributed table with a constant sharding key
Backport #59606 to 23.12: Fix distributed table with a constant sharding key
Backport #59606 to 24.1: Fix distributed table with a constant sharding key
Backport #59606 to 23.11: Fix distributed table with a constant sharding key
Changelog category:
Changelog entry:
Fix distributed table with a constant sharding key.
Closes #59589