ClickHouse/dbms/Functions/FunctionJoinGet.h

90 lines
3.0 KiB
C++
Raw Normal View History

#include <Functions/IFunctionImpl.h>
#include <Storages/IStorage_fwd.h>
2019-03-05 10:12:20 +00:00
#include <Storages/TableStructureLockHolder.h>
namespace DB
{
2019-09-09 19:43:37 +00:00
class Context;
class Join;
2019-09-09 19:43:37 +00:00
using HashJoinPtr = std::shared_ptr<Join>;
2019-12-09 14:41:55 +00:00
class ExecutableFunctionJoinGet final : public IExecutableFunctionImpl
{
public:
2019-12-09 14:41:55 +00:00
ExecutableFunctionJoinGet(HashJoinPtr join_, String attr_name_)
: join(std::move(join_)), attr_name(std::move(attr_name_)) {}
static constexpr auto name = "joinGet";
bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForConstants() const override { return true; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return true; }
2019-12-09 14:41:55 +00:00
void execute(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override;
String getName() const override { return name; }
private:
HashJoinPtr join;
const String attr_name;
};
class FunctionJoinGet final : public IFunctionBaseImpl
{
public:
static constexpr auto name = "joinGet";
FunctionJoinGet(TableStructureReadLockHolder table_lock_, StoragePtr storage_join_,
HashJoinPtr join_, String attr_name_,
DataTypes argument_types_, DataTypePtr return_type_)
2019-08-03 11:02:40 +00:00
: table_lock(std::move(table_lock_))
, storage_join(std::move(storage_join_))
, join(std::move(join_))
2019-12-09 14:41:55 +00:00
, attr_name(std::move(attr_name_))
, argument_types(std::move(argument_types_))
2019-08-03 11:02:40 +00:00
, return_type(std::move(return_type_))
2019-01-25 14:50:31 +00:00
{
}
String getName() const override { return name; }
2019-12-09 14:41:55 +00:00
const DataTypes & getArgumentTypes() const override { return argument_types; }
const DataTypePtr & getReturnType() const override { return return_type; }
2019-12-09 14:41:55 +00:00
ExecutableFunctionImplPtr prepare(const Block & sample_block, const ColumnNumbers & arguments, size_t result) const override;
private:
TableStructureReadLockHolder table_lock;
2019-01-25 14:50:31 +00:00
StoragePtr storage_join;
2019-09-09 19:43:37 +00:00
HashJoinPtr join;
const String attr_name;
2019-12-09 14:41:55 +00:00
DataTypes argument_types;
2019-01-25 14:50:31 +00:00
DataTypePtr return_type;
};
class JoinGetOverloadResolver final : public IFunctionOverloadResolverImpl
{
public:
static constexpr auto name = "joinGet";
static FunctionOverloadResolverImplPtr create(const Context & context) { return std::make_unique<JoinGetOverloadResolver>(context); }
explicit JoinGetOverloadResolver(const Context & context_) : context(context_) {}
String getName() const override { return name; }
2019-12-09 14:41:55 +00:00
FunctionBaseImplPtr build(const ColumnsWithTypeAndName & arguments, const DataTypePtr &) const override;
DataTypePtr getReturnType(const ColumnsWithTypeAndName & arguments) const override;
bool useDefaultImplementationForNulls() const override { return false; }
bool useDefaultImplementationForLowCardinalityColumns() const override { return true; }
bool isVariadic() const override { return true; }
size_t getNumberOfArguments() const override { return 0; }
private:
const Context & context;
};
}