v.21.9Improvement
Shard-Level Constants for Functions in Distributed Tables
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. #27020 (Amos Bird).
Why it matters
This feature solves the problem of obtaining shard-specific metadata in distributed queries consistently. It enables users to get meaningful per-shard information directly within distributed table queries, improving observability and debugging without complex workarounds.How to use it
Use any of the supported functions (e.g.,hostName(), version()) in queries on distributed tables. When executed inside a distributed query, these functions behave like normal columns returning shard-specific values; otherwise, they return constant values for non-distributed contexts.