The only way to use this feature is to specify an empty database name in Distributed table definition, but then you get a warning:

```
CREATE TABLE `demo_loan_all` (...) ENGINE=Distributed(test_cluster_two_shards_different_databases, '', demo_loan_01568, cityHash64(id));

<Warning> StorageDistributed (demo_loan_all): Name of remote database is empty. Default database will be used implicitly.
```
{
    auto modified_query_ast = query->clone();
    ASTSelectQuery & select_query = modified_query_ast->as<ASTSelectQuery &>();
    
    
    
    select_query.setExpression(ASTSelectQuery::Expression::SETTINGS, {});
    if (table_function_ptr)
        select_query.addTableFunction(table_function_ptr);
    else
        select_query.replaceDatabaseAndTable(database, table);
    
    
    if (!table_function_ptr)
    {
        RestoreQualifiedNamesVisitor::Data data;
        data.distributed_table = DatabaseAndTableWithAlias(*getTableExpression(query->as<ASTSelectQuery &>(), 0));
        data.remote_table.database = database;
        data.remote_table.table = table;
        data.rename = true;
        RestoreQualifiedNamesVisitor(data).visit(modified_query_ast);
    }
    return modified_query_ast;
}
ASTPtr createInsertToRemoteTableQuery(const std::string & database, const std::string & table, const Block & sample_block_non_materialized)