How to reproduce:

```sql
EXPLAIN SYNTAX
SELECT x
FROM 
(
    SELECT 1 AS x
    UNION DISTINCT
    SELECT 1
)

Query id: e777bc02-5d1b-4d49-ba89-4ebe31172387


Exception on client:
Code: 32. DB::Exception: Attempt to read after eof: while receiving packet from localhost:9000

```

InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(const ASTPtr & ast_ptr_, const Names & current_required_result_column_names)
{
    if (ast_ptr_->as<ASTSelectWithUnionQuery>())
        return std::make_unique<InterpreterSelectWithUnionQuery>(ast_ptr_, *context, options, current_required_result_column_names);
    else
        return std::make_unique<InterpreterSelectQuery>(ast_ptr_, *context, options, current_required_result_column_names);
}
InterpreterSelectWithUnionQuery::~InterpreterSelectWithUnionQuery() = default;
Block InterpreterSelectWithUnionQuery::getSampleBlock(const ASTPtr & query_ptr_, const Context & context_, bool is_subquery)
{
    auto & cache = context_.getSampleBlockCache();
    
    auto key = queryToString(query_ptr_);
    if (cache.find(key) != cache.end())
    {
        return cache[key];
    }
    if (is_subquery)
        return cache[key]
            = InterpreterSelectWithUnionQuery(query_ptr_, context_, SelectQueryOptions().subquery().analyze()).getSampleBlock();
    else
        return cache[key] = InterpreterSelectWithUnionQuery(query_ptr_, context_, SelectQueryOptions().analyze()).getSampleBlock();
}
void InterpreterSelectWithUnionQuery::buildQueryPlan(QueryPlan & query_plan)