#pragma once #include #include #include namespace DB { using Poco::SharedPtr; /** Выбирает из блока только столбцы, являющиеся результатом вычисления выражения. * Следует применять после ExpressionBlockInputStream. */ class ProjectionBlockInputStream : public IProfilingBlockInputStream { public: ProjectionBlockInputStream( BlockInputStreamPtr input_, SharedPtr expression_, bool without_duplicates_ = false, unsigned part_id_ = 0, ASTPtr subtree_ = NULL) : input(input_), expression(expression_), without_duplicates(without_duplicates_), part_id(part_id_), subtree(subtree_) { children.push_back(input); } Block readImpl() { Block res = input->read(); if (!res) return res; return expression->projectResult(res, without_duplicates, part_id, subtree); } String getName() const { return "ProjectionBlockInputStream"; } BlockInputStreamPtr clone() { return new ProjectionBlockInputStream(input, expression, without_duplicates, part_id, subtree); } private: BlockInputStreamPtr input; SharedPtr expression; bool without_duplicates; unsigned part_id; ASTPtr subtree; }; }