#pragma once #include #include namespace DB { class ExpressionActions; using ExpressionActionsPtr = std::shared_ptr; class ActionsDAG; /** Executes a certain expression over the block. * The expression consists of column identifiers from the block, constants, common functions. * For example: hits * 2 + 3, url LIKE '%clickhouse%' * The expression processes each row independently of the others. */ class ExpressionTransform final : public ISimpleTransform { public: ExpressionTransform( const Block & header_, ExpressionActionsPtr expression_); String getName() const override { return "ExpressionTransform"; } static Block transformHeader(const Block & header, const ActionsDAG & expression); protected: void transform(Chunk & chunk) override; private: ExpressionActionsPtr expression; }; class ConvertingTransform final : public ExceptionKeepingTransform { public: ConvertingTransform( const Block & header_, ExpressionActionsPtr expression_); String getName() const override { return "ConvertingTransform"; } protected: void onConsume(Chunk chunk) override; GenerateResult onGenerate() override { GenerateResult res; res.chunk = std::move(cur_chunk); return res; } private: ExpressionActionsPtr expression; Chunk cur_chunk; }; }