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

Memory limit should be respected.
element.profile_counters = std::move(info.profile_counters);
            };
            
            auto finish_callback = [elem, &context, ast, log_queries, log_queries_min_type = settings.log_queries_min_type,
                status_info_to_query_log]
                (IBlockInputStream * stream_in, IBlockOutputStream * stream_out, QueryPipeline * query_pipeline) mutable
            {
                QueryStatus * process_list_elem = context.getProcessListElement();
                if (!process_list_elem)
                    return;
                
                CurrentThread::finalizePerformanceCounters();
                QueryStatusInfo info = process_list_elem->getInfo(true, context.getSettingsRef().log_profile_events);
                double elapsed_seconds = info.elapsed_seconds;
                elem.type = QueryLogElementType::QUERY_FINISH;
                
                
                const auto time_now = std::chrono::system_clock::now();
                elem.event_time = time_in_seconds(time_now);
                elem.event_time_microseconds = time_in_microseconds(time_now);
                status_info_to_query_log(elem, info, ast);
                auto progress_callback = context.getProgressCallback();
                if (progress_callback)
                    progress_callback(Progress(WriteProgress(info.written_rows, info.written_bytes)));
                if (stream_in)
                {
                    const BlockStreamProfileInfo & stream_in_info = stream_in->getProfileInfo();
                    
                    elem.result_rows = stream_in_info.rows;
                    elem.result_bytes = stream_in_info.bytes;