Shape / rows · All operations
Repeat each row
A variant of Split a list into rows
Emit several copies of each row, a set or column-given number of times or along a generated sequence.
Status
- In arcform
Runs as a SQL step
arcform carries it as a
sql:step today.
The DuckDB step
Repeat each row a set number of times, a column-given number of times or along a sequence
CREATE TEMP TABLE items AS SELECT * FROM (VALUES ('a', 2), ('b', 0), ('c', 3)) t(sku, copies);
-- a set number of copies
CREATE TEMP TABLE fixed AS SELECT sku FROM items, range(2) r(copy);
-- the number of copies is in a column; a row with 0 copies disappears
CREATE TEMP TABLE by_column AS SELECT sku, r.copy + 1 AS copy FROM items, range(items.copies) r(copy);
-- one copy for each day of a generated sequence
CREATE TEMP TABLE along_sequence AS
SELECT sku, d::DATE AS day FROM items, generate_series(DATE '2026-03-01', DATE '2026-03-03', INTERVAL 1 DAY) g(d);
SELECT * FROM by_column ORDER BY sku, copy;
SELECT CASE WHEN ((SELECT count(*) FROM fixed) = 6 AND (SELECT list((sku, copy) ORDER BY sku, copy) FROM by_column) = [('a', 1), ('a', 2), ('c', 1), ('c', 2), ('c', 3)] AND (SELECT count(*) FROM along_sequence) = 9 AND (SELECT list(day ORDER BY day) FROM along_sequence WHERE sku = 'b') = [DATE '2026-03-01', DATE '2026-03-02', DATE '2026-03-03']) THEN 'as expected' ELSE error('the rows were not repeated twice each, by their own count (2, 0 and 3) or along three days') END AS verdict;- The statement builds its own data.
- It needs nothing installed beyond DuckDB itself.
- The statement checks its own result and raises an error when it is wrong: “the rows were not repeated twice each, by their own count (2, 0 and 3) or along three days”.
- It passed on DuckDB
v2.0.0 (Cyanoptera) d54cbbe3df.
What other tools call it
Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).
Alteryx Designer (1)
Generate Rowsread 2026-09-27Create new rows per record from a loop expression: number, date or transaction sequences
Apache Hop (1)
Clone rowread 2026-09-27Emit N copies after each row, optionally flagging which rows are clones
EasyMorph (1)
Repeat rowsread 2026-09-27Repeat each row as many times as a column says
Pentaho Data Integration (1)
Clone rowread 2026-09-27Emit each row as many times as required
Power Query M (1)
Table.Repeatread 2026-09-27Repeat the whole set of rows a given number of times
Talend (1)
tDuplicateRowread 2026-09-27Generate duplicate copies of input rows, flagging the original of each group, as test data
Background
In EasyMorph, the Repeat rows action repeats each row as many times as a column specifies, then numbers the copies from 1 to n in that column.[1] In Apache Hop, Clone row adds a set number of clones after each original row, and in Power Query M, Table.Repeat repeats a table's rows a set number of times.[2][3] In tidyr, uncount performs the opposite operation to dplyr::count(), duplicating rows according to a weighting variable or expression.[4]
When to use it
In EasyMorph, Repeat rows can expand a table holding a number of shifts per date into one row per shift for each day.[1] Repeat a row when the data records a count or a span and the next step needs one row per unit, such as one row per day of a booking. (Meridian's view)
In tidyr, the .id argument of uncount creates a variable giving a unique identifier for each created row.[4] In Apache Hop, the Clone row transform can add a boolean field marking each output row as the original or a clone.[2] Give each copy a number or flag of its own, so the copies can be told apart and a later step can tell which row it came from. (Meridian's view)
In PostgreSQL, generate_series(4,3), whose stop lies below its start, returns 0 rows.[5] Decide what a row with a count of zero or less should become before repeating, and check the result holds the rows you expect. (Meridian's view)
The method
In DuckDB, range creates a list of values from start to stop with stop exclusive, while generate_series includes stop.[6] Choose between the two functions by whether the stop should be included, since an off-by-one there adds or loses a copy of every row. (Meridian's view)
Compared with the alternatives
In Apache Hop, the Clone row transform outputs the copies of a row directly after the original row.[2] In Power Query M, Table.Repeat returns a table with the rows of the input table repeated a given number of times.[3] Where the order of the output matters, check whether a tool places each row's copies together or repeats the whole table in turn. (Meridian's view) Repeating a row differs from splitting a list in where the number of rows comes from: a count or a sequence, rather than the elements of a value the row already holds. (Meridian's view)
Sources
- [1]REPEAT ROWS [EasyMorph Help]documentation
- [2]Clone row | Apache Hopdocumentation
- [3]Table.Repeat - PowerQuery M | Microsoft Learndocumentation
- [4]"Uncount" a data frame — uncount • tidyrdocumentation
- [5]PostgreSQL: Documentation: 18: 9.26. Set Returning Functionsdocumentation
- [6]List Functions – DuckDBdocumentation