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

```

{
    return std::chrono::duration_cast<std::chrono::microseconds>(timepoint.time_since_epoch()).count();
}
inline UInt64 time_in_seconds(std::chrono::time_point<std::chrono::system_clock> timepoint)
{
    return std::chrono::duration_cast<std::chrono::seconds>(timepoint.time_since_epoch()).count();
}
static void onExceptionBeforeStart(const String & query_for_logging, Context & context, UInt64 current_time_us, ASTPtr ast)
{
    
    if (auto quota = context.getQuota())
        quota->used(Quota::ERRORS, 1,  false);
    const Settings & settings = context.getSettingsRef();
    
    QueryLogElement elem;
    elem.type = QueryLogElementType::EXCEPTION_BEFORE_START;
    
    
    
    elem.event_time = current_time_us / 1000000;
    elem.event_time_microseconds = current_time_us;