2015-01-27 21:24:24 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-06-06 17:18:32 +00:00
|
|
|
#include <ext/shared_ptr_helper.h>
|
2016-08-26 21:25:05 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Storages/StorageSet.h>
|
|
|
|
#include <Parsers/ASTTablesInSelectQuery.h>
|
2015-01-27 21:24:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-01-14 09:00:19 +00:00
|
|
|
class Join;
|
|
|
|
using JoinPtr = std::shared_ptr<Join>;
|
|
|
|
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/** Allows you save the state for later use on the right side of the JOIN.
|
|
|
|
* When inserted into a table, the data will be inserted into the state,
|
|
|
|
* and also written to the backup file, to restore after the restart.
|
|
|
|
* Reading from the table is not possible directly - only specifying on the right side of JOIN is possible.
|
2015-01-28 00:38:10 +00:00
|
|
|
*
|
2017-04-16 15:00:33 +00:00
|
|
|
* When using, JOIN must be of the appropriate type (ANY|ALL LEFT|INNER ...).
|
2015-01-27 21:24:24 +00:00
|
|
|
*/
|
2017-06-06 18:36:13 +00:00
|
|
|
class StorageJoin : public ext::shared_ptr_helper<StorageJoin>, public StorageSetOrJoinBase
|
2015-01-27 21:24:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 07:20:54 +00:00
|
|
|
String getName() const override { return "Join"; }
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Access the innards.
|
2017-04-01 07:20:54 +00:00
|
|
|
JoinPtr & getJoin() { return join; }
|
|
|
|
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Verify that the data structure is suitable for implementing this type of JOIN.
|
2017-04-01 07:20:54 +00:00
|
|
|
void assertCompatible(ASTTableJoin::Kind kind_, ASTTableJoin::Strictness strictness_) const;
|
2015-01-28 02:37:05 +00:00
|
|
|
|
2015-01-27 21:24:24 +00:00
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
const Names & key_names;
|
|
|
|
ASTTableJoin::Kind kind; /// LEFT | INNER ...
|
|
|
|
ASTTableJoin::Strictness strictness; /// ANY | ALL
|
|
|
|
|
|
|
|
JoinPtr join;
|
|
|
|
|
2017-11-03 21:50:22 +00:00
|
|
|
void insertBlock(const Block & block) override;
|
|
|
|
size_t getSize() const override;
|
|
|
|
|
|
|
|
protected:
|
2017-04-01 07:20:54 +00:00
|
|
|
StorageJoin(
|
|
|
|
const String & path_,
|
|
|
|
const String & name_,
|
|
|
|
const Names & key_names_,
|
|
|
|
ASTTableJoin::Kind kind_, ASTTableJoin::Strictness strictness_,
|
|
|
|
NamesAndTypesListPtr columns_,
|
|
|
|
const NamesAndTypesList & materialized_columns_,
|
|
|
|
const NamesAndTypesList & alias_columns_,
|
|
|
|
const ColumnDefaults & column_defaults_);
|
2015-01-27 21:24:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|