private async Task ConsumeAsync(CancellationToken token)
        {
            await using var queryStream = await _ksqlRestClient.ExecuteQueryAsync(_query, token);

            using var streamReader = new StreamReader(queryStream);

            while (!streamReader.EndOfStream && !token.IsCancellationRequested)
            {
                var line = await streamReader.ReadLineAsync();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var streamResponse = JsonConvert.DeserializeObject <StreamResponse>(line);

                if (streamResponse.Row?.Columns is null || !streamResponse.Row.Columns.Any())
                {
                    break;
                }

                var values  = streamResponse.Row.Columns.Skip(2).SelectMany(FlattenNestedValues).ToArray();
                var payload = _mapper.Map <TRow>(values);

                _streamSubject.OnNext(payload);
            }
        }
        public async Task <IEnumerable <T> > ExecuteQuery <T>(KsqlQuery query)
        {
            await using var queryStream = await _ksqlRestClient.ExecuteQueryAsync(query);

            using var streamReader = new StreamReader(queryStream);
            var results = new List <T>();

            while (!streamReader.EndOfStream)
            {
                var line = await streamReader.ReadLineAsync();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var streamResponse = JsonConvert.DeserializeObject <StreamResponse>(line);

                if (streamResponse.Row?.Columns is null || !streamResponse.Row.Columns.Any())
                {
                    break;
                }

                var values  = streamResponse.Row.Columns.Skip(2).SelectMany(FlattenNestedValues).ToArray();
                var payload = _mapper.Map <T>(values);
                results.Add(payload);
            }

            return(results);
        }