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

Replace old _shard_num implementation with shardNum() function #33392

Merged
merged 8 commits into from
Jan 28, 2022

Conversation

azat
Copy link
Collaborator

@azat azat commented Jan 4, 2022

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Replace _shard_num via constants (from #7624) with shardNum() function (from #27020), to avoid possible issues (like those that had been found in #16947)

Detailed description / Documentation draft:
This patch changes the behavior of _shard_num slightly for nested distributed tables,
now it returns nested shard number, but this should be minor.

Cc: @amosbird

@robot-clickhouse robot-clickhouse added the pr-improvement Pull request with some product improvements label Jan 4, 2022
@azat azat mentioned this pull request Jan 4, 2022
@azat azat marked this pull request as draft January 4, 2022 13:48
@amosbird
Copy link
Collaborator

amosbird commented Jan 5, 2022

Yeah, functions are better than literals.

One test is broken.

SELECT 'remote(Distributed)';
SELECT _shard_num, key FROM remote('127.0.0.1', currentDatabase(), dist_2) order by _shard_num, key;

It seems the shardNum() answer is more reasonable : The definition of shard_num should be related to the related main table only without inheritance.

_shard_num via constant identifier (from ClickHouse#7624) has too much issues,
take a look at ClickHouse#16947 for example.

shardNum() function (from ClickHouse#27020) should works better.

This changes the behaviour of _shard_num slightly, now it returns nested
shard number in case of nested distributed tables (Distributed over
Distributed), but this should be minor.

v2: Rewrite _shard_num to shardNum() in TreeRewriter
- move CREATE/INSERT at the beginning
- add echoOn
@azat azat marked this pull request as ready for review January 10, 2022 18:23
@azat
Copy link
Collaborator Author

azat commented Jan 11, 2022

@azat
Copy link
Collaborator Author

azat commented Jan 21, 2022

@alexey-milovidov can you please take a look?

@KochetovNicolai
Copy link
Member

I can't describe how I love this change.

@KochetovNicolai
Copy link
Member

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jan 27, 2022

update

✅ Branch has been successfully updated

@azat
Copy link
Collaborator Author

azat commented Jan 27, 2022

@KochetovNicolai KochetovNicolai merged commit 94999e8 into ClickHouse:master Jan 28, 2022
@azat azat deleted the _shard_num branch January 28, 2022 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants