| 535 | } |
| 536 | |
| 537 | DataTypePtr InterpreterCreateQuery::getColumnType( |
| 538 | const ASTColumnDeclaration & col_decl, const LoadingStrictnessLevel mode, const bool make_columns_nullable) |
| 539 | { |
| 540 | auto col_type = col_decl.getType(); |
| 541 | if (!col_type) |
| 542 | { |
| 543 | /// we're creating dummy DataTypeUInt8 in order to prevent the NullPointerException in ExpressionActions |
| 544 | return std::make_shared<DataTypeUInt8>(); |
| 545 | } |
| 546 | |
| 547 | DataTypePtr column_type = DataTypeFactory::instance().get(col_type); |
| 548 | |
| 549 | if (LoadingStrictnessLevel::ATTACH <= mode) |
| 550 | setVersionToAggregateFunctions(column_type, true); |
| 551 | |
| 552 | if (col_decl.null_modifier) |
| 553 | { |
| 554 | if (column_type->isNullable()) |
| 555 | throw Exception(ErrorCodes::ILLEGAL_SYNTAX_FOR_DATA_TYPE, "Can't use [NOT] NULL modifier with Nullable type"); |
| 556 | if (*col_decl.null_modifier) |
| 557 | column_type = makeNullable(column_type); |
| 558 | } |
| 559 | else if (make_columns_nullable) |
| 560 | { |
| 561 | column_type = makeNullable(column_type); |
| 562 | } |
| 563 | else if (auto default_expr = col_decl.getDefaultExpression(); |
| 564 | !hasNullable(column_type) && col_decl.default_specifier == ColumnDefaultSpecifier::Default && default_expr |
| 565 | && default_expr->as<ASTLiteral>() && default_expr->as<ASTLiteral>()->value.isNull()) |
| 566 | { |
| 567 | if (column_type->lowCardinality()) |
| 568 | { |
| 569 | const auto * low_cardinality_type = typeid_cast<const DataTypeLowCardinality *>(column_type.get()); |
| 570 | chassert(low_cardinality_type); |
| 571 | column_type = std::make_shared<DataTypeLowCardinality>(makeNullable(low_cardinality_type->getDictionaryType())); |
| 572 | } |
| 573 | else |
| 574 | column_type = makeNullable(column_type); |
| 575 | } |
| 576 | return column_type; |
| 577 | } |
| 578 | |
| 579 | ColumnsDescription InterpreterCreateQuery::getColumnsDescription( |
| 580 | const ASTExpressionList & columns_ast, ContextPtr context_, LoadingStrictnessLevel mode, bool is_restore_from_backup) |
nothing calls this directly
no test coverage detected