**Describe the issue**
after succesful update clickhouse from 20.3 to 20.8

a SELECT query which combine `FROM buffer_table` and  `WHERE dictGet` and `filter by date` which doesn't contains data on original MergeTree table, fail with 
Code: 49. DB::Exception: Cannot add simple transform to empty Pipe

**How to reproduce**
```
git clone git@gist.github.com:8a8bb43c43b6257a013753d1ac51c978.git
docker-compose up -d
docker-compose exec clickhouse bash -c "clickhouse-client -mn --echo < /var/lib/clickhouse/user_files/success_query.sql"
docker-compose exec clickhouse bash -c "clickhouse-client -mn --echo < /var/lib/clickhouse/user_files/failed_query.sql"
diff -u failed_query.sql success_query.sql
less clickhouse-server.log
```

* Which ClickHouse server versions are incompatible
failure become in 20.8+

* `CREATE TABLE` statements for all tables involved
https://gist.github.com/Slach/8a8bb43c43b6257a013753d1ac51c978#file-init_schema-sql

* Queries to run that lead to unexpected result
https://gist.github.com/Slach/8a8bb43c43b6257a013753d1ac51c978#file-failed_query-sql

**Error message and/or stacktrace**
#### 20.8 stacktrace
```
2020.10.02 10:08:31.985110 [ 190 ] {1f7e7c9d-86ed-4e5f-a55f-20c045b6c044} <Error> executeQuery: Code: 49, e.displayText() = DB::Exception: Cannot add simple transform to empty Pipe. (version 20.8.3.18 (official build)) (from 127.0.0.1:52718) (in query: SELECT toDate(i.event_date) AS day, coalesce(sum(i.cost), 0) AS pcost FROM wister.rtb_and_mb_left_join_raw_data_buffer i WHERE dictGet('wister.dict_prod_partner_affiliate_links','partner_id',tuple(i.code_affilie))>0 AND i.event_date >= now() - INTERVAL 30 DAY AND i.event_date < now() - INTERVAL 7 DAY GROUP BY day; ), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x1a80cd70 in /usr/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xff9e75d in /usr/bin/clickhouse
2. ? @ 0x17efbaf8 in /usr/bin/clickhouse
3. DB::Pipe::addSimpleTransform(std::__1::function<std::__1::shared_ptr<DB::IProcessor> (DB::Block const&)> const&) @ 0x17ef55c8 in /usr/bin/clickhouse
4. DB::StorageBuffer::read(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&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo const&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0x17ae992f in /usr/bin/clickhouse
5. DB::ReadFromStorageStep::ReadFromStorageStep(std::__1::shared_ptr<DB::RWLockImpl::LockHolderImpl>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const>&, DB::SelectQueryOptions, std::__1::shared_ptr<DB::IStorage>, 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&, DB::SelectQueryInfo const&, std::__1::shared_ptr<DB::Context>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x181e870a in /usr/bin/clickhouse
6. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&, std::__1::shared_ptr<DB::PrewhereInfo> 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&) @ 0x174b9321 in /usr/bin/clickhouse
7. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>) @ 0x174bd1b2 in /usr/bin/clickhouse
8. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0x174be964 in /usr/bin/clickhouse
9. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0x1763b478 in /usr/bin/clickhouse
10. DB::InterpreterSelectWithUnionQuery::execute() @ 0x1763b64a in /usr/bin/clickhouse
11. ? @ 0x177d9262 in /usr/bin/clickhouse
12. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0x177dabc2 in /usr/bin/clickhouse
13. DB::TCPHandler::runImpl() @ 0x17ea1a25 in /usr/bin/clickhouse
14. DB::TCPHandler::run() @ 0x17ea2790 in /usr/bin/clickhouse
15. Poco::Net::TCPServerConnection::start() @ 0x1a72abdb in /usr/bin/clickhouse
16. Poco::Net::TCPServerDispatcher::run() @ 0x1a72b06b in /usr/bin/clickhouse
17. Poco::PooledThread::run() @ 0x1a8a9b46 in /usr/bin/clickhouse
18. Poco::ThreadImpl::runnableEntry(void*) @ 0x1a8a4f40 in /usr/bin/clickhouse
19. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
20. clone @ 0x122103 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
```
#### 20.9 stacktrace
```
2020.10.02 10:15:35.950777 [ 190 ] {791d4417-a240-4a2a-b10f-a16e4af49804} <Error> executeQuery: Code: 49, e.displayText() = DB::Exception: Cannot add simple transform to empty Pipe. (version 20.9.2.20 (official build)) (from 127.0.0.1:52732) (in query: SELECT toDate(i.event_date) AS day, coalesce(sum(i.cost), 0) AS pcost FROM wister.rtb_and_mb_left_join_raw_data_buffer i WHERE dictGet('wister.dict_prod_partner_affiliate_links','partner_id',tuple(i.code_affilie))>0 AND i.event_date >= now() - INTERVAL 30 DAY AND i.event_date < now() - INTERVAL 7 DAY GROUP BY day; ), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x18e02790 in /usr/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xe72fdad in /usr/bin/clickhouse
2. ? @ 0x1651b840 in /usr/bin/clickhouse
3. DB::Pipe::addSimpleTransform(std::__1::function<std::__1::shared_ptr<DB::IProcessor> (DB::Block const&)> const&) @ 0x16514578 in /usr/bin/clickhouse
4. DB::StorageBuffer::read(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&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, DB::SelectQueryInfo const&, DB::Context const&, DB::QueryProcessingStage::Enum, unsigned long, unsigned int) @ 0x1611967f in /usr/bin/clickhouse
5. DB::ReadFromStorageStep::ReadFromStorageStep(std::__1::shared_ptr<DB::RWLockImpl::LockHolderImpl>, std::__1::shared_ptr<DB::StorageInMemoryMetadata const>&, DB::SelectQueryOptions, std::__1::shared_ptr<DB::IStorage>, 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&, DB::SelectQueryInfo const&, std::__1::shared_ptr<DB::Context>, DB::QueryProcessingStage::Enum, unsigned long, unsigned long) @ 0x167ed13a in /usr/bin/clickhouse
6. DB::InterpreterSelectQuery::executeFetchColumns(DB::QueryProcessingStage::Enum, DB::QueryPlan&, std::__1::shared_ptr<DB::PrewhereInfo> 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&) @ 0x15b1dff1 in /usr/bin/clickhouse
7. DB::InterpreterSelectQuery::executeImpl(DB::QueryPlan&, std::__1::shared_ptr<DB::IBlockInputStream> const&, std::__1::optional<DB::Pipe>) @ 0x15b21ec3 in /usr/bin/clickhouse
8. DB::InterpreterSelectQuery::buildQueryPlan(DB::QueryPlan&) @ 0x15b239b4 in /usr/bin/clickhouse
9. DB::InterpreterSelectWithUnionQuery::buildQueryPlan(DB::QueryPlan&) @ 0x15c9d6f8 in /usr/bin/clickhouse
10. DB::InterpreterSelectWithUnionQuery::execute() @ 0x15c9d8ca in /usr/bin/clickhouse
11. ? @ 0x15e1ac62 in /usr/bin/clickhouse
12. DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0x15e1c5c2 in /usr/bin/clickhouse
13. DB::TCPHandler::runImpl() @ 0x164c3585 in /usr/bin/clickhouse
14. DB::TCPHandler::run() @ 0x164c42f0 in /usr/bin/clickhouse
15. Poco::Net::TCPServerConnection::start() @ 0x18d205fb in /usr/bin/clickhouse
16. Poco::Net::TCPServerDispatcher::run() @ 0x18d20a8b in /usr/bin/clickhouse
17. Poco::PooledThread::run() @ 0x18e9f566 in /usr/bin/clickhouse
18. Poco::ThreadImpl::runnableEntry(void*) @ 0x18e9a960 in /usr/bin/clickhouse
19. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
20. __clone @ 0x122103 in /usr/lib/x86_64-linux-gnu/libc-2.31.so

```
**Additional context**
Add any other context about the problem here.

}
    }
    Pipes pipes;
    pipes.emplace_back(std::move(pipe_from_dst));
    pipes.emplace_back(std::move(pipe_from_buffers));
    return Pipe::unitePipes(std::move(pipes));
}
static void appendBlock(const Block & from, Block & to)
{
    if (!to)
        throw Exception("Cannot append to empty block", ErrorCodes::LOGICAL_ERROR);
    assertBlocksHaveEqualStructure(from, to, "Buffer");
    from.checkNumberOfRows();
    to.checkNumberOfRows();
    size_t rows = from.rows();
    size_t bytes = from.bytes();
    CurrentMetrics::add(CurrentMetrics::StorageBufferRows, rows);
    CurrentMetrics::add(CurrentMetrics::StorageBufferBytes, bytes);
    size_t old_rows = to.rows();
    auto temporarily_disable_memory_tracker = getCurrentMemoryTrackerActionLock();
    try
    {
        for (size_t column_no = 0, columns = to.columns(); column_no < columns; ++column_no)
        {
            const IColumn & col_from = *from.getByPosition(column_no).column.get();
            MutableColumnPtr col_to = IColumn::mutate(std::move(to.getByPosition(column_no).column));
            col_to->insertRangeFrom(col_from, 0, rows);
            to.getByPosition(column_no).column = std::move(col_to);
        }
    }