Fix build

This commit is contained in:
Ivan Lezhankin 2020-12-31 14:52:28 +03:00
parent 5e89145a42
commit 4a72ad62ea
14 changed files with 65 additions and 68 deletions

View File

@ -25,7 +25,7 @@ ASTPtr processColumnTransformers(
TablesWithColumns tables_with_columns;
{
auto table_expr = std::make_shared<ASTTableExpression>();
table_expr->database_and_table_name = createTableIdentifier(table->getStorageID());
table_expr->database_and_table_name = std::make_shared<ASTTableIdentifier>(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);
}

View File

@ -9,7 +9,6 @@ namespace DB
struct ASTCheckQuery : public ASTQueryWithTableAndOutput
{
ASTPtr partition;
/** Get the text that identifies this element. */

View File

@ -264,7 +264,7 @@ ASTPtr AlterTableClause::convertToOld() const
{
auto table = get(FROM)->convertToOld();
command->from_database = table->as<ASTTableIdentifier>()->getDatabaseName();
command->from_table = table->as<ASTTableIdentifier>()->shortName();;
command->from_table = table->as<ASTTableIdentifier>()->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<ASTTableIdentifier>()->getDatabaseName();;
command->to_database = table->as<ASTTableIdentifier>()->getDatabaseName();
command->to_table = table->as<ASTTableIdentifier>()->shortName();
}
break;

View File

@ -19,9 +19,9 @@ ASTPtr CheckQuery::convertToOld() const
{
auto query = std::make_shared<ASTCheckQuery>();
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<ASTTableIdentifier>(get(NAME)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
if (has(PARTITION)) query->partition = get(PARTITION)->convertToOld();

View File

@ -29,18 +29,17 @@ ASTPtr CreateLiveViewQuery::convertToOld() const
auto query = std::make_shared<ASTCreateQuery>();
{
auto table_id = getTableIdentifier(get(NAME)->convertToOld());
query->database = table_id.database_name;
query->table = table_id.table_name;
query->uuid
= has(UUID) ? parseFromString<DB::UUID>(get(UUID)->convertToOld()->as<ASTLiteral>()->value.get<String>()) : table_id.uuid;
auto table = std::static_pointer_cast<ASTTableIdentifier>(get(NAME)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = has(UUID) ? parseFromString<DB::UUID>(get(UUID)->convertToOld()->as<ASTLiteral>()->value.get<String>()) : table->uuid;
}
if (has(TIMEOUT))
query->live_view_timeout.emplace(get(TIMEOUT)->convertToOld()->as<ASTLiteral>()->value.get<UInt64>());
if (has(DESTINATION))
query->to_table_id = getTableIdentifier(get(DESTINATION)->convertToOld());
query->to_table_id = get(DESTINATION)->convertToOld()->as<ASTTableIdentifier>()->getTableId();
if (has(SCHEMA))
{

View File

@ -35,15 +35,14 @@ ASTPtr CreateMaterializedViewQuery::convertToOld() const
auto query = std::make_shared<ASTCreateQuery>();
{
auto table_id = getTableIdentifier(get(NAME)->convertToOld());
query->database = table_id.database_name;
query->table = table_id.table_name;
query->uuid
= has(UUID) ? parseFromString<DB::UUID>(get(UUID)->convertToOld()->as<ASTLiteral>()->value.get<String>()) : table_id.uuid;
auto table = std::static_pointer_cast<ASTTableIdentifier>(get(NAME)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = has(UUID) ? parseFromString<DB::UUID>(get(UUID)->convertToOld()->as<ASTLiteral>()->value.get<String>()) : table->uuid;
}
if (has(DESTINATION))
query->to_table_id = getTableIdentifier(get(DESTINATION)->convertToOld());
query->to_table_id = get(DESTINATION)->convertToOld()->as<ASTTableIdentifier>()->getTableId();
else if (has(ENGINE))
{
query->set(query->storage, get(ENGINE)->convertToOld());

View File

@ -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<ASTTableIdentifier>(get(SCHEMA)->convertToOld());
query->as_database = table->getDatabaseName();
query->as_table = table->shortName();
break;
}
case TableSchemaClause::ClauseType::FUNCTION:

View File

@ -26,10 +26,10 @@ ASTPtr CreateViewQuery::convertToOld() const
auto query = std::make_shared<ASTCreateQuery>();
{
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<ASTTableIdentifier>(get(NAME)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = table->uuid;
}
query->attach = attach;

View File

@ -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<ASTTableIdentifier>(get(TABLE)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = table->uuid;
return query;
}

View File

@ -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<ASTTableIdentifier>()->getTableId();
break;
}

View File

@ -23,10 +23,10 @@ ASTPtr OptimizeQuery::convertToOld() const
auto query = std::make_shared<ASTOptimizeQuery>();
{
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<ASTTableIdentifier>(get(TABLE)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = table->uuid;
}
if (has(PARTITION))

View File

@ -47,22 +47,22 @@ ASTPtr ShowCreateQuery::convertToOld() const
case QueryType::DICTIONARY:
{
auto query = std::make_shared<ASTShowCreateDictionaryQuery>();
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<ASTTableIdentifier>(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<ASTShowCreateTableQuery>();
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<ASTTableIdentifier>(get(IDENTIFIER)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = table->uuid;
query->temporary = temporary;
return query;

View File

@ -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<ASTTableIdentifier>(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<ASTTableIdentifier>(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<ASTTableIdentifier>(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<ASTTableIdentifier>(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<ASTTableIdentifier>(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<ASTTableIdentifier>(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<ASTTableIdentifier>(get(TABLE)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
}
break;
}

View File

@ -20,10 +20,10 @@ ASTPtr WatchQuery::convertToOld() const
{
auto query = std::make_shared<ASTWatchQuery>();
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<ASTTableIdentifier>(get(TABLE)->convertToOld());
query->database = table->getDatabaseName();
query->table = table->shortName();
query->uuid = table->uuid;
query->is_watch_events = events;