**Describe the bug**
`SELECT i FROM generateRandom('i Array(Int8)', 1048575, 10, 1048577) LIMIT 1048575`

Memory limit should be respected.
{
    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, time_t current_time, UInt64 current_time_microseconds, 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;
    elem.event_time_microseconds = current_time_microseconds;
    elem.query_start_time = current_time;
    elem.query_start_time_microseconds = current_time_microseconds;
    elem.current_database = context.getCurrentDatabase();
    elem.query = query_for_logging;
    elem.exception_code = getCurrentExceptionCode();
    elem.exception = getCurrentExceptionMessage(false);
    elem.client_info = context.getClientInfo();