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
|
|
|
|
2020-10-10 08:02:04 +00:00
|
|
|
#include <common/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-05-17 13:06:11 +00:00
|
|
|
bool isSuitableForShortCircuitArgumentsExecution(ColumnsWithTypeAndName & /*arguments*/) const override { return false; }
|
2021-04-29 14:48:26 +00:00
|
|
|
|
2020-11-17 13:24:45 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void registerFunctionTid(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionTid>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|