-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Shard-level const column #27020
Shard-level const column #27020
Conversation
src/Functions/buildId.cpp
Outdated
@@ -42,6 +47,9 @@ class FunctionBuildId : public IFunction | |||
{ | |||
return DataTypeString().createColumnConst(input_rows_count, SymbolIndex::instance()->getBuildIDHex()); | |||
} | |||
|
|||
private: | |||
ContextPtr context; |
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.
Let's better store only is_distributed
flag instead of whole context.
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.
Done
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.
Awesome!
e8b7017
to
9bdd9c9
Compare
a7941a9
to
edaf8ea
Compare
edaf8ea
to
c03b20d
Compare
src/Functions/getScalar.cpp
Outdated
/** Get special scalar values | ||
*/ | ||
template <typename Scalar> | ||
class FunctionGetSpecialScalar : public IFunction, WithContext |
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.
Looks like we don't actually need WithContext
here.
Context is used only to get scalar in the constructor
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.
Indeed.
Fast test is ok. |
Internal documentation ticket: DOCSUP-14057. |
_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
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Now functions can be shard-level constants, which means if it's executed in the context of some distributed table, it generates a normal column, otherwise it produces a constant value. Notable functions are:
hostName()
,tcpPort()
,version()
,buildId()
,uptime()
, etc.This PR also introduces two functions:
shardNum()
andshardCount()
. They are also shard-level constants and provide shard info during query execution.The old
_shard_num
virtual column will still work but should be deprecated.Detailed description / Documentation draft:
.