0

I am trying to imitate the behaviour of "generate_series". My table contains various fields. One of these is "count". I want to output each row as often as "count" because each row is going to serve as an independent object.

Dremio, however, does not support "generate_series".

Does anyone know how to accomplish the given task?

regards Muffex

Edit:

Table:

id name count
0123 ABC 3
2345 EFG 0
3456 HIK 2

Desired Output:

id name
0123 ABC
0123 ABC
0123 ABC
3456 HIK
3456 HIK
Muffex
  • 55
  • 1
  • 12

1 Answers1

1

You can generate a list of numbers that are "big enough" and then joining. Assuming 100 is big enough and that your original table has at least 100 rows:

with n as (
      select row_number() over (order by null) as n
      from t
      limit 100
      )
select t.*, n.n
from t join
     n
     on n.n <= t.cnt;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • I am VERY grateful for your reply. The output is as intended. The caveat is that "count" can differ greatly and performance might suffer under the current solution. If there is no (even) better alternative, I will accept this solution. – Muffex Jul 12 '21 at 21:07