#pragma once #include #include #include namespace DB { class IJoin; using JoinPtr = std::shared_ptr; /// Join two data streams. class JoinStep : public IQueryPlanStep { public: JoinStep( const Header & left_header_, const Header & right_header_, JoinPtr join_, size_t max_block_size_, size_t max_streams_, NameSet required_output_, bool keep_left_read_in_order_, bool use_new_analyzer_); String getName() const override { return "Join"; } QueryPipelineBuilderPtr updatePipeline(QueryPipelineBuilders pipelines, const BuildQueryPipelineSettings &) override; void describePipeline(FormatSettings & settings) const override; void describeActions(JSONBuilder::JSONMap & map) const override; void describeActions(FormatSettings & settings) const override; const JoinPtr & getJoin() const { return join; } void setJoin(JoinPtr join_, bool swap_streams_ = false); bool allowPushDownToRight() const; JoinInnerTableSelectionMode inner_table_selection_mode = JoinInnerTableSelectionMode::Right; private: void updateOutputHeader() override; /// Header that expected to be returned from IJoin Block join_algorithm_header; JoinPtr join; size_t max_block_size; size_t max_streams; const NameSet required_output; std::set columns_to_remove; bool keep_left_read_in_order; bool use_new_analyzer = false; bool swap_streams = false; }; /// Special step for the case when Join is already filled. /// For StorageJoin and Dictionary. class FilledJoinStep : public ITransformingStep { public: FilledJoinStep(const Header & input_header_, JoinPtr join_, size_t max_block_size_); String getName() const override { return "FilledJoin"; } void transformPipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &) override; void describeActions(JSONBuilder::JSONMap & map) const override; void describeActions(FormatSettings & settings) const override; const JoinPtr & getJoin() const { return join; } private: void updateOutputHeader() override; JoinPtr join; size_t max_block_size; }; }