mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fix problems
This commit is contained in:
parent
fb08a96582
commit
70fac9c068
@ -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<ASTColumnDeclaration &>();
|
||||
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -10,8 +10,6 @@
|
||||
#include <Parsers/CommonParsers.h>
|
||||
#include <Poco/String.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -141,8 +139,8 @@ bool IParserColumnDeclaration<NameParser>::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<NameParser>::parseImpl(Pos & pos, ASTPtr & node, E
|
||||
|
||||
if (s_not.check(pos, expected)) {
|
||||
if (s_null.check(pos, expected)) {
|
||||
isNot = std::make_shared<ASTIdentifier>("NOT");
|
||||
isNull = std::make_shared<ASTIdentifier>("NULL");
|
||||
is_not = std::make_shared<ASTIdentifier>("NOT");
|
||||
is_null = std::make_shared<ASTIdentifier>("NULL");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (s_null.check(pos, expected)) {
|
||||
isNull = std::make_shared<ASTIdentifier>("NULL");
|
||||
is_null = std::make_shared<ASTIdentifier>("NULL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,14 +213,14 @@ bool IParserColumnDeclaration<NameParser>::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)
|
||||
|
Loading…
Reference in New Issue
Block a user