diff --git a/src/Interpreters/processColumnTransformers.cpp b/src/Interpreters/processColumnTransformers.cpp index afd99cb6f07..2a704d4a937 100644 --- a/src/Interpreters/processColumnTransformers.cpp +++ b/src/Interpreters/processColumnTransformers.cpp @@ -25,7 +25,7 @@ ASTPtr processColumnTransformers( TablesWithColumns tables_with_columns; { auto table_expr = std::make_shared(); - table_expr->database_and_table_name = createTableIdentifier(table->getStorageID()); + table_expr->database_and_table_name = std::make_shared(table->getStorageID()); table_expr->children.push_back(table_expr->database_and_table_name); tables_with_columns.emplace_back(DatabaseAndTableWithAlias(*table_expr, current_database), names_and_types); } diff --git a/src/Parsers/ASTCheckQuery.h b/src/Parsers/ASTCheckQuery.h index 0470ba4f875..fdd1179ec90 100644 --- a/src/Parsers/ASTCheckQuery.h +++ b/src/Parsers/ASTCheckQuery.h @@ -9,7 +9,6 @@ namespace DB struct ASTCheckQuery : public ASTQueryWithTableAndOutput { - ASTPtr partition; /** Get the text that identifies this element. */ diff --git a/src/Parsers/New/AST/AlterTableQuery.cpp b/src/Parsers/New/AST/AlterTableQuery.cpp index 6d8a08a2ec8..d118b45bd03 100644 --- a/src/Parsers/New/AST/AlterTableQuery.cpp +++ b/src/Parsers/New/AST/AlterTableQuery.cpp @@ -264,7 +264,7 @@ ASTPtr AlterTableClause::convertToOld() const { auto table = get(FROM)->convertToOld(); command->from_database = table->as()->getDatabaseName(); - command->from_table = table->as()->shortName();; + command->from_table = table->as()->shortName(); command->replace = false; command->type = ASTAlterCommand::REPLACE_PARTITION; } @@ -358,7 +358,7 @@ ASTPtr AlterTableClause::convertToOld() const command->move_destination_type = DataDestinationType::TABLE; { auto table = get(TO)->convertToOld(); - command->to_database = table->as()->getDatabaseName();; + command->to_database = table->as()->getDatabaseName(); command->to_table = table->as()->shortName(); } break; diff --git a/src/Parsers/New/AST/CheckQuery.cpp b/src/Parsers/New/AST/CheckQuery.cpp index 54ad8e4dac4..87a7544ec34 100644 --- a/src/Parsers/New/AST/CheckQuery.cpp +++ b/src/Parsers/New/AST/CheckQuery.cpp @@ -19,9 +19,9 @@ ASTPtr CheckQuery::convertToOld() const { auto query = std::make_shared(); - auto table_id = getTableIdentifier(get(NAME)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(NAME)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); if (has(PARTITION)) query->partition = get(PARTITION)->convertToOld(); diff --git a/src/Parsers/New/AST/CreateLiveViewQuery.cpp b/src/Parsers/New/AST/CreateLiveViewQuery.cpp index b3323824924..18501884f02 100644 --- a/src/Parsers/New/AST/CreateLiveViewQuery.cpp +++ b/src/Parsers/New/AST/CreateLiveViewQuery.cpp @@ -29,18 +29,17 @@ ASTPtr CreateLiveViewQuery::convertToOld() const auto query = std::make_shared(); { - auto table_id = getTableIdentifier(get(NAME)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid - = has(UUID) ? parseFromString(get(UUID)->convertToOld()->as()->value.get()) : table_id.uuid; + auto table = std::static_pointer_cast(get(NAME)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = has(UUID) ? parseFromString(get(UUID)->convertToOld()->as()->value.get()) : table->uuid; } if (has(TIMEOUT)) query->live_view_timeout.emplace(get(TIMEOUT)->convertToOld()->as()->value.get()); if (has(DESTINATION)) - query->to_table_id = getTableIdentifier(get(DESTINATION)->convertToOld()); + query->to_table_id = get(DESTINATION)->convertToOld()->as()->getTableId(); if (has(SCHEMA)) { diff --git a/src/Parsers/New/AST/CreateMaterializedViewQuery.cpp b/src/Parsers/New/AST/CreateMaterializedViewQuery.cpp index 24107d9dd6c..2b8a1b18b5f 100644 --- a/src/Parsers/New/AST/CreateMaterializedViewQuery.cpp +++ b/src/Parsers/New/AST/CreateMaterializedViewQuery.cpp @@ -35,15 +35,14 @@ ASTPtr CreateMaterializedViewQuery::convertToOld() const auto query = std::make_shared(); { - auto table_id = getTableIdentifier(get(NAME)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid - = has(UUID) ? parseFromString(get(UUID)->convertToOld()->as()->value.get()) : table_id.uuid; + auto table = std::static_pointer_cast(get(NAME)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = has(UUID) ? parseFromString(get(UUID)->convertToOld()->as()->value.get()) : table->uuid; } if (has(DESTINATION)) - query->to_table_id = getTableIdentifier(get(DESTINATION)->convertToOld()); + query->to_table_id = get(DESTINATION)->convertToOld()->as()->getTableId(); else if (has(ENGINE)) { query->set(query->storage, get(ENGINE)->convertToOld()); diff --git a/src/Parsers/New/AST/CreateTableQuery.cpp b/src/Parsers/New/AST/CreateTableQuery.cpp index 31a6c73029c..69427812e3f 100644 --- a/src/Parsers/New/AST/CreateTableQuery.cpp +++ b/src/Parsers/New/AST/CreateTableQuery.cpp @@ -132,9 +132,9 @@ ASTPtr CreateTableQuery::convertToOld() const } case TableSchemaClause::ClauseType::TABLE: { - auto table_id = getTableIdentifier(get(SCHEMA)->convertToOld()); - query->as_database = table_id.database_name; - query->as_table = table_id.table_name; + auto table = std::static_pointer_cast(get(SCHEMA)->convertToOld()); + query->as_database = table->getDatabaseName(); + query->as_table = table->shortName(); break; } case TableSchemaClause::ClauseType::FUNCTION: diff --git a/src/Parsers/New/AST/CreateViewQuery.cpp b/src/Parsers/New/AST/CreateViewQuery.cpp index df68687eb13..b9d8031fd53 100644 --- a/src/Parsers/New/AST/CreateViewQuery.cpp +++ b/src/Parsers/New/AST/CreateViewQuery.cpp @@ -26,10 +26,10 @@ ASTPtr CreateViewQuery::convertToOld() const auto query = std::make_shared(); { - auto table_id = getTableIdentifier(get(NAME)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(NAME)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; } query->attach = attach; diff --git a/src/Parsers/New/AST/ExistsQuery.cpp b/src/Parsers/New/AST/ExistsQuery.cpp index 0a91ea01d36..c0d35d346c4 100644 --- a/src/Parsers/New/AST/ExistsQuery.cpp +++ b/src/Parsers/New/AST/ExistsQuery.cpp @@ -31,10 +31,10 @@ ASTPtr ExistsQuery::convertToOld() const } // FIXME: this won't work if table doesn't exist - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; return query; } diff --git a/src/Parsers/New/AST/InsertQuery.cpp b/src/Parsers/New/AST/InsertQuery.cpp index 1f9325d3677..905748ba441 100644 --- a/src/Parsers/New/AST/InsertQuery.cpp +++ b/src/Parsers/New/AST/InsertQuery.cpp @@ -70,7 +70,7 @@ ASTPtr InsertQuery::convertToOld() const query->table_function = get(FUNCTION)->convertToOld(); break; case QueryType::TABLE: - query->table_id = getTableIdentifier(get(IDENTIFIER)->convertToOld()); + query->table_id = get(IDENTIFIER)->convertToOld()->as()->getTableId(); break; } diff --git a/src/Parsers/New/AST/OptimizeQuery.cpp b/src/Parsers/New/AST/OptimizeQuery.cpp index 88bb6cfbe7b..5977a2221b9 100644 --- a/src/Parsers/New/AST/OptimizeQuery.cpp +++ b/src/Parsers/New/AST/OptimizeQuery.cpp @@ -23,10 +23,10 @@ ASTPtr OptimizeQuery::convertToOld() const auto query = std::make_shared(); { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; } if (has(PARTITION)) diff --git a/src/Parsers/New/AST/ShowCreateQuery.cpp b/src/Parsers/New/AST/ShowCreateQuery.cpp index 4210f2cb67c..613b5178e62 100644 --- a/src/Parsers/New/AST/ShowCreateQuery.cpp +++ b/src/Parsers/New/AST/ShowCreateQuery.cpp @@ -47,22 +47,22 @@ ASTPtr ShowCreateQuery::convertToOld() const case QueryType::DICTIONARY: { auto query = std::make_shared(); - auto table_id = getTableIdentifier(get(IDENTIFIER)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(IDENTIFIER)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; return query; } case QueryType::TABLE: { auto query = std::make_shared(); - auto table_id = getTableIdentifier(get(IDENTIFIER)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(IDENTIFIER)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; query->temporary = temporary; return query; diff --git a/src/Parsers/New/AST/SystemQuery.cpp b/src/Parsers/New/AST/SystemQuery.cpp index a9c4b01f218..2be9ff951e0 100644 --- a/src/Parsers/New/AST/SystemQuery.cpp +++ b/src/Parsers/New/AST/SystemQuery.cpp @@ -93,25 +93,25 @@ ASTPtr SystemQuery::convertToOld() const case QueryType::DISTRIBUTED_SENDS: query->type = stop ? ASTSystemQuery::Type::STOP_DISTRIBUTED_SENDS : ASTSystemQuery::Type::START_DISTRIBUTED_SENDS; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; case QueryType::FETCHES: query->type = stop ? ASTSystemQuery::Type::STOP_FETCHES : ASTSystemQuery::Type::START_FETCHES; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; case QueryType::FLUSH_DISTRIBUTED: query->type = ASTSystemQuery::Type::FLUSH_DISTRIBUTED; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; case QueryType::FLUSH_LOGS: @@ -120,9 +120,9 @@ ASTPtr SystemQuery::convertToOld() const case QueryType::MERGES: query->type = stop ? ASTSystemQuery::Type::STOP_MERGES : ASTSystemQuery::Type::START_MERGES; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; case QueryType::RELOAD_DICTIONARIES: @@ -131,9 +131,9 @@ ASTPtr SystemQuery::convertToOld() const case QueryType::RELOAD_DICTIONARY: query->type = ASTSystemQuery::Type::RELOAD_DICTIONARY; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->target_dictionary = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->target_dictionary = table->shortName(); } break; case QueryType::REPLICATED_SENDS: @@ -142,17 +142,17 @@ ASTPtr SystemQuery::convertToOld() const case QueryType::SYNC_REPLICA: query->type = ASTSystemQuery::Type::SYNC_REPLICA; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; case QueryType::TTL_MERGES: query->type = stop ? ASTSystemQuery::Type::STOP_TTL_MERGES : ASTSystemQuery::Type::START_TTL_MERGES; { - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); } break; } diff --git a/src/Parsers/New/AST/WatchQuery.cpp b/src/Parsers/New/AST/WatchQuery.cpp index 224ff935f97..14d71007232 100644 --- a/src/Parsers/New/AST/WatchQuery.cpp +++ b/src/Parsers/New/AST/WatchQuery.cpp @@ -20,10 +20,10 @@ ASTPtr WatchQuery::convertToOld() const { auto query = std::make_shared(); - auto table_id = getTableIdentifier(get(TABLE)->convertToOld()); - query->database = table_id.database_name; - query->table = table_id.table_name; - query->uuid = table_id.uuid; + auto table = std::static_pointer_cast(get(TABLE)->convertToOld()); + query->database = table->getDatabaseName(); + query->table = table->shortName(); + query->uuid = table->uuid; query->is_watch_events = events;