ClickHouse/src/Functions/tid.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
1.1 KiB
C++
Raw Normal View History

2020-10-09 15:49:14 +00:00
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/FunctionHelpers.h>
2021-05-17 07:30:42 +00:00
#include <Functions/IFunction.h>
2020-10-09 15:49:14 +00:00
2021-10-02 07:13:14 +00:00
#include <base/getThreadId.h>
2020-10-09 15:49:14 +00:00
namespace DB
{
namespace
{
class FunctionTid : public IFunction
{
public:
static constexpr auto name = "tid";
2021-06-01 12:20:52 +00:00
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionTid>(); }
2020-10-09 15:49:14 +00:00
String getName() const override { return name; }
size_t getNumberOfArguments() const override { return 0; }
DataTypePtr getReturnTypeImpl(const DataTypes &) const override { return std::make_shared<DataTypeUInt64>(); }
2021-06-22 16:21:23 +00:00
bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo & /*arguments*/) const override { return false; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override
2020-10-09 15:49:14 +00:00
{
2020-10-10 08:02:04 +00:00
auto current_tid = getThreadId();
2020-10-19 15:27:41 +00:00
return DataTypeUInt64().createColumnConst(input_rows_count, current_tid);
2020-10-09 15:49:14 +00:00
}
};
}
REGISTER_FUNCTION(Tid)
2020-10-09 15:49:14 +00:00
{
factory.registerFunction<FunctionTid>();
}
}