blob: 1789c9ba7d425f5207b1667f9a13a5123fff4586 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunction.h>
#include <base/getThreadId.h>
namespace DB
{
namespace
{
class FunctionTid : public IFunction
{
public:
static constexpr auto name = "tid";
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionTid>(); }
String getName() const override { return name; }
size_t getNumberOfArguments() const override { return 0; }
DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared<DataTypeUInt64>(); }
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override
{
auto current_tid = getThreadId();
return DataTypeUInt64().createColumnConst(input_rows_count, current_tid);
}
};
}
REGISTER_FUNCTION(Tid)
{
factory.registerFunction<FunctionTid>();
}
}
|