```
create table test (x UInt64) engine=Null;
insert into function remote('127.0.0.1',default,test) values (1);
-- ok
set async_insert=1;
insert into function remote('127.0.0.1',default,test) values (1);
-- fail
```

exception

```
Received exception from server (version 22.3.1):
Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Both table name and UUID are empty. Stack trace:

0. ./build_docker/../contrib/libcxx/include/exception:133: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x15bff96c in /usr/bin/clickhouse
1. ./build_docker/../src/Common/Exception.cpp:58: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xa8d817a in /usr/bin/clickhouse
2. DB::StorageID::assertNotEmpty() const @ 0x10225ff1 in /usr/bin/clickhouse
3. ./build_docker/../contrib/libcxx/include/string:1444: DB::StorageID::getDatabaseName() const @ 0x131ec0d6 in /usr/bin/clickhouse
4. ./build_docker/../src/Interpreters/Context.cpp:0: DB::Context::checkAccess(DB::AccessFlags const&, DB::StorageID const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) const @ 0x12b96564 in /usr/bin/clickhouse
5. ./build_docker/../contrib/libcxx/include/vector:463: DB::AsynchronousInsertQueue::push(std::__1::shared_ptr<DB::IAST>, std::__1::shared_ptr<DB::Context const>) @ 0x12b61130 in /usr/bin/clickhouse
6. ./build_docker/../src/Interpreters/executeQuery.cpp:0: DB::executeQueryImpl(char const*, char const*, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x132fbb4e in /usr/bin/clickhouse
7. ./build_docker/../src/Interpreters/executeQuery.cpp:985: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<DB::Context>, bool, DB::QueryProcessingStage::Enum) @ 0x132fa4cd in /usr/bin/clickhouse
8. ./build_docker/../src/Server/TCPHandler.cpp:0: DB::TCPHandler::runImpl() @ 0x13b66440 in /usr/bin/clickhouse
9. ./build_docker/../src/Server/TCPHandler.cpp:1918: DB::TCPHandler::run() @ 0x13b75759 in /usr/bin/clickhouse
10. ./build_docker/../contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0x15aef967 in /usr/bin/clickhouse
11. ./build_docker/../contrib/libcxx/include/memory:1397: Poco::Net::TCPServerDispatcher::run() @ 0x15aefe27 in /usr/bin/clickhouse
12. ./build_docker/../contrib/poco/Foundation/src/ThreadPool.cpp:213: Poco::PooledThread::run() @ 0x15c619e7 in /usr/bin/clickhouse
13. ./build_docker/../contrib/poco/Foundation/include/Poco/SharedPtr.h:156: Poco::ThreadImpl::runnableEntry(void*) @ 0x15c5f3c6 in /usr/bin/clickhouse
14. ? @ 0x7f742d0b7609 in ?
15. clone @ 0x7f742cfde293 in ?
. (UNKNOWN_TABLE)
```
if (auto maybe_pipeline = table->distributedWrite(query, getContext()))
        {
            pipeline = std::move(*maybe_pipeline);
            is_distributed_insert_select = true;
        }
    }
    std::vector<Chain> out_chains;
    if (!is_distributed_insert_select || query.watch)
    {
        size_t out_streams_size = 1;
        if (query.select)
        {
            bool is_trivial_insert_select = false;
            if (settings.optimize_trivial_insert_select)
            {
                const auto & select_query = query.select->as<ASTSelectWithUnionQuery &>();
                const auto & selects = select_query.list_of_selects->children;
                const auto & union_modes = select_query.list_of_modes;
                
                const auto mode_is_all = [](const auto & mode) { return mode == SelectUnionMode::ALL; };
                is_trivial_insert_select =
                    std::all_of(union_modes.begin(), union_modes.end(), std::move(mode_is_all))
                    && std::all_of(selects.begin(), selects.end(), isTrivialSelect);
            }
            if (is_trivial_insert_select)
            {
                /** When doing trivial INSERT INTO ... SELECT ... FROM table,
                  * don't need to process SELECT with more than max_insert_threads
                  * and it's reasonable to set block size for SELECT to the desired block size for INSERT