diff --git a/dbms/include/DB/Common/VirtualColumnUnitls.h b/dbms/include/DB/Common/VirtualColumnUnitls.h deleted file mode 100644 index a52dc06df937a525e0baa85276e9783dea0762ef..0000000000000000000000000000000000000000 --- a/dbms/include/DB/Common/VirtualColumnUnitls.h +++ /dev/null @@ -1,110 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace DB -{ - -class VirtualColumnUtils{ -public: -static String chooseSuffix(const NamesAndTypesList &columns, const String &name) -{ - int id = 0; - String current_suffix; - while (true) - { - bool done = true; - for (auto & it : columns) - if (it.first == name + current_suffix) - { - done = false; - break; - } - if (done) break; - id ++; - current_suffix = toString(id); - } - return current_suffix; -} - - -static String chooseSuffix(const NamesAndTypesList &columns, const std::vector &names) -{ - int id = 0; - String current_suffix; - while (true) - { - bool done = true; - for (auto & it : columns) - { - for (size_t i = 0; i < names.size(); ++i) - { - if (it.first == names[i] + current_suffix) - { - done = false; - break; - } - } - if (!done) - break; - } - if (done) - break; - id ++; - current_suffix = toString(id); - } - return current_suffix; -} - -static void rewriteEntityInAst(ASTPtr ast, const String & column_name, const Field &value) -{ - { - ASTSelectQuery & select = dynamic_cast(*ast); - ASTExpressionList & node = dynamic_cast(*select.select_expression_list); - ASTs & asts = node.children; - ASTLiteral * cur = new ASTLiteral(StringRange(NULL, NULL), value); - cur->alias = column_name; - ASTPtr column_value = cur; - asts.insert(asts.begin(), column_value); - return; - } - - - - - if (ASTExpressionList * node = dynamic_cast(&*ast)) - { - ASTs & asts = node->children; - for (int i = static_cast(asts.size()) - 1; i >= 0; --i) - { - if (ASTIdentifier * child = dynamic_cast(&*asts[i])) - { - if (child->kind == ASTIdentifier::Column && child->getColumnName() == column_name) - { - ASTLiteral * cur = new ASTLiteral(StringRange(NULL, NULL), value); - cur->alias = column_name; - - ASTPtr column_value = cur; - - asts.erase(asts.begin() + i); - asts.insert(asts.begin() + i, column_value); - } - } - } - } - - for (auto it : ast->children) - rewriteEntityInAst(it, column_name, value); -} - -}; - -}