diff --git a/dbms/src/Interpreters/ProjectionManipulation.cpp b/dbms/src/Interpreters/ProjectionManipulation.cpp index 69a81618174..1fb3bb071fb 100644 --- a/dbms/src/Interpreters/ProjectionManipulation.cpp +++ b/dbms/src/Interpreters/ProjectionManipulation.cpp @@ -1,23 +1,20 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -namespace DB { +namespace DB +{ +ProjectionManipulatorBase::~ProjectionManipulatorBase() {} -ProjectionManipulatorBase::~ProjectionManipulatorBase() -{} - -DefaultProjectionManipulator::DefaultProjectionManipulator(ScopeStack & scopes) - : scopes(scopes) -{} +DefaultProjectionManipulator::DefaultProjectionManipulator(ScopeStack & scopes) : scopes(scopes) {} bool DefaultProjectionManipulator::tryToGetFromUpperProjection(const std::string & column_name) { @@ -34,22 +31,19 @@ std::string DefaultProjectionManipulator::getProjectionExpression() return ""; } -std::string DefaultProjectionManipulator::getProjectionSourceColumn() const { +std::string DefaultProjectionManipulator::getProjectionSourceColumn() const +{ return ""; } -ConditionalTree::Node::Node() - : projection_expression_string(), - parent_node(0), - is_root(false) -{} +ConditionalTree::Node::Node() : projection_expression_string(), parent_node(0), is_root(false) {} size_t ConditionalTree::Node::getParentNode() const { if (is_root) { - throw Exception("Failed to get parent projection node of node " + projection_expression_string, - ErrorCodes::CONDITIONAL_TREE_PARENT_NOT_FOUND); + throw Exception( + "Failed to get parent projection node of node " + projection_expression_string, ErrorCodes::CONDITIONAL_TREE_PARENT_NOT_FOUND); } else { @@ -75,22 +69,19 @@ std::string ConditionalTree::getColumnName(const std::string & col_name) const return getColumnNameByIndex(col_name, current_node); } -std::string ConditionalTree::getProjectionColumnName(const std::string & first_projection_expr, - const std::string & second_projection_expr) const +std::string ConditionalTree::getProjectionColumnName( + const std::string & first_projection_expr, const std::string & second_projection_expr) const { return std::string("P<") + first_projection_expr + "><" + second_projection_expr + ">"; } std::string ConditionalTree::getProjectionColumnName(const size_t first_index, const size_t second_index) const { - return getProjectionColumnName( - nodes[first_index].projection_expression_string, - nodes[second_index].projection_expression_string); + return getProjectionColumnName(nodes[first_index].projection_expression_string, nodes[second_index].projection_expression_string); } -void ConditionalTree::buildProjectionCompositionRecursive(const std::vector & path, - const size_t child_index, - const size_t parent_index) +void ConditionalTree::buildProjectionCompositionRecursive( + const std::vector & path, const size_t child_index, const size_t parent_index) { std::string projection_name = getProjectionColumnName(path[parent_index], path[child_index]); if (parent_index - child_index >= 2 && !scopes.getSampleBlock().has(projection_name)) @@ -98,15 +89,12 @@ void ConditionalTree::buildProjectionCompositionRecursive(const std::vectorgetColumnName(getZerosColumnName()); if (!scopes.getSampleBlock().has(zeros_column_name)) { - scopes.addAction(ExpressionAction::addColumn(ColumnWithTypeAndName( - ColumnUInt8::create(0, 1), std::make_shared(), zeros_column_name), - restore_projection_name, true)); + scopes.addAction(ExpressionAction::addColumn( + ColumnWithTypeAndName(ColumnUInt8::create(0, 1), std::make_shared(), zeros_column_name), + restore_projection_name, + true)); } } @@ -309,7 +282,8 @@ void AndOperatorProjectionAction::preArgumentAction() } else { - throw Exception("Illegal projection manipulator used in AndOperatorProjectionAction", ErrorCodes::ILLEGAL_PROJECTION_MANIPULATOR); + throw Exception( + "Illegal projection manipulator used in AndOperatorProjectionAction", ErrorCodes::ILLEGAL_PROJECTION_MANIPULATOR); } ++projection_levels_count; } @@ -326,17 +300,13 @@ void AndOperatorProjectionAction::preCalculation() { auto final_column = getFinalColumnName(); const FunctionBuilderPtr & function_builder = FunctionFactory::instance().get("one_or_zero", context); - scopes.addAction(ExpressionAction::applyFunction( - function_builder, - { - projection_manipulator->getColumnName(previous_argument_name) - }, - projection_manipulator->getColumnName(final_column), - projection_manipulator->getProjectionSourceColumn())); + scopes.addAction(ExpressionAction::applyFunction(function_builder, + {projection_manipulator->getColumnName(previous_argument_name)}, + projection_manipulator->getColumnName(final_column), + projection_manipulator->getProjectionSourceColumn())); std::string restore_projection_name = conditional_tree->buildRestoreProjectionAndGetName(projection_levels_count); createZerosColumn(restore_projection_name); - conditional_tree->restoreColumn(getZerosColumnName(), final_column, - projection_levels_count, expression_name); + conditional_tree->restoreColumn(getZerosColumnName(), final_column, projection_levels_count, expression_name); conditional_tree->goUp(projection_levels_count); } else @@ -350,14 +320,13 @@ bool AndOperatorProjectionAction::isCalculationRequired() return false; } -ProjectionActionBase::~ProjectionActionBase() -{} +ProjectionActionBase::~ProjectionActionBase() {} ProjectionActionPtr getProjectionAction(const std::string & node_name, - ScopeStack & scopes, - ProjectionManipulatorPtr projection_manipulator, - const std::string & expression_name, - const Context & context) + ScopeStack & scopes, + ProjectionManipulatorPtr projection_manipulator, + const std::string & expression_name, + const Context & context) { if (typeid_cast(projection_manipulator.get()) && node_name == "and") {