From 1ae82df3c0561b0f5968b919e124926212b02310 Mon Sep 17 00:00:00 2001 From: potya Date: Mon, 25 May 2020 14:20:33 +0300 Subject: [PATCH] at start --- src/Interpreters/InterpreterCreateQuery.cpp | 15 +++++++------ src/Parsers/ASTColumnDeclaration.cpp | 20 ++++++++--------- src/Parsers/ASTColumnDeclaration.h | 4 ++-- src/Parsers/ParserCreateQuery.h | 24 ++++++++++----------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/Interpreters/InterpreterCreateQuery.cpp b/src/Interpreters/InterpreterCreateQuery.cpp index 586f2d0f056..4c220d43b17 100644 --- a/src/Interpreters/InterpreterCreateQuery.cpp +++ b/src/Interpreters/InterpreterCreateQuery.cpp @@ -71,6 +71,7 @@ namespace ErrorCodes extern const int BAD_DATABASE_FOR_TEMPORARY_TABLE; extern const int SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY; extern const int DICTIONARY_ALREADY_EXISTS; + extern const int ILLEGAL_SYNTAX_FOR_DATA_TYPE } @@ -287,25 +288,25 @@ ColumnsDescription InterpreterCreateQuery::getColumnsDescription(const ASTExpres const auto & col_decl = ast->as(); DataTypePtr column_type = nullptr; - if (!col_decl.isNULL && col_decl.isNot) - throw Exception{"Cant use NOT without NULL", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED}; + if (!col_decl.is_null && col_decl.is_not) + throw Exception{"Cant use NOT without NULL", ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE}; if (col_decl.type) { column_type = DataTypeFactory::instance().get(col_decl.type); - if (col_decl.isNot && col_decl.isNULL) { + if (col_decl.is_not && col_decl.is_null) { if (column_type->isNullable()) - throw Exception{"Cant use NOT NULL with Nullable", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED}; - } else if (col_decl.isNULL && !col_decl.isNot) { + throw Exception{"Cant use NOT NULL with Nullable", ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE}; + } else if (col_decl.is_null && !col_decl.is_not) { if (column_type->isNullable()) - throw Exception{"Cant use NULL with Nullable", ErrorCodes::EMPTY_LIST_OF_COLUMNS_PASSED}; + throw Exception{"Cant use NULL with Nullable", ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE}; else { column_type = makeNullable(column_type); } } - if (context.getSettingsRef().data_type_default_nullable && !column_type->isNullable() && !col_decl.isNot && !col_decl.isNULL) + if (context.getSettingsRef().data_type_default_nullable && !column_type->isNullable() && !col_decl.is_not && !col_decl.is_null) column_type = makeNullable(column_type); column_names_and_types.emplace_back(col_decl.name, column_type); diff --git a/src/Parsers/ASTColumnDeclaration.cpp b/src/Parsers/ASTColumnDeclaration.cpp index 40513b45586..de5abe28ffb 100644 --- a/src/Parsers/ASTColumnDeclaration.cpp +++ b/src/Parsers/ASTColumnDeclaration.cpp @@ -16,16 +16,16 @@ ASTPtr ASTColumnDeclaration::clone() const res->children.push_back(res->type); } - if (isNULL) + if (is_null) { - res->isNULL = isNULL; - res->children.push_back(res->isNULL); + res->is_null = is_null; + res->children.push_back(res->is_null); } - if (isNot) + if (is_not) { - res->isNot = isNot; - res->children.push_back(res->isNot); + res->is_not = is_not; + res->children.push_back(res->is_not); } if (default_expression) @@ -71,16 +71,16 @@ void ASTColumnDeclaration::formatImpl(const FormatSettings & settings, FormatSta type->formatImpl(settings, state, frame); } - if (isNot) + if (is_not) { settings.ostr << ' '; - isNot->formatImpl(settings, state, frame); + is_not->formatImpl(settings, state, frame); } - if (isNULL) + if (is_null) { settings.ostr << ' '; - isNULL->formatImpl(settings, state, frame); + is_null->formatImpl(settings, state, frame); } diff --git a/src/Parsers/ASTColumnDeclaration.h b/src/Parsers/ASTColumnDeclaration.h index 406a8cebded..34afd771de2 100644 --- a/src/Parsers/ASTColumnDeclaration.h +++ b/src/Parsers/ASTColumnDeclaration.h @@ -13,8 +13,8 @@ class ASTColumnDeclaration : public IAST public: String name; ASTPtr type; - ASTPtr isNULL; - ASTPtr isNot; + ASTPtr is_null; + ASTPtr is_not; String default_specifier; ASTPtr default_expression; ASTPtr comment; diff --git a/src/Parsers/ParserCreateQuery.h b/src/Parsers/ParserCreateQuery.h index 8976de8f1bc..c2b36460397 100644 --- a/src/Parsers/ParserCreateQuery.h +++ b/src/Parsers/ParserCreateQuery.h @@ -10,8 +10,6 @@ #include #include -#include - namespace DB { @@ -141,8 +139,8 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, ASTPtr & node, E */ ASTPtr type; String default_specifier; - ASTPtr isNull; - ASTPtr isNot; + ASTPtr is_null; + ASTPtr is_not; ASTPtr default_expression; ASTPtr comment_expression; ASTPtr codec_expression; @@ -175,14 +173,14 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, ASTPtr & node, E if (s_not.check(pos, expected)) { if (s_null.check(pos, expected)) { - isNot = std::make_shared("NOT"); - isNull = std::make_shared("NULL"); + is_not = std::make_shared("NOT"); + is_null = std::make_shared("NULL"); } else { return false; } } else { if (s_null.check(pos, expected)) { - isNull = std::make_shared("NULL"); + is_null = std::make_shared("NULL"); } } @@ -215,14 +213,14 @@ bool IParserColumnDeclaration::parseImpl(Pos & pos, ASTPtr & node, E column_declaration->children.push_back(std::move(type)); } - if (isNull) { - column_declaration->isNULL = isNull; - column_declaration->children.push_back(std::move(isNull)); + if (is_null) { + column_declaration->is_null = is_null; + column_declaration->children.push_back(std::move(is_null)); } - if (isNot) { - column_declaration->isNot = isNot; - column_declaration->children.push_back(std::move(isNot)); + if (is_not) { + column_declaration->is_not = is_not; + column_declaration->children.push_back(std::move(is_not)); } if (default_expression)