repeat
Copies input data a specified number of times and outputs it.
Command properties
| Item | Description |
|---|---|
| Command type | Processing query |
| Required permission | None |
| License usage | N/A |
| Parallel execution | Supported |
| Distributed execution | Not supported |
Syntax
repeat count=INT [_repidx={t|f}]
Options
count=INT- Number of times to repeat each input record.
_repidx={t|f}- Whether to output the repeat index field (default:
f)
t: Adds a_repidxfield to each copy with a zero-based index value.f: Does not add a repeat index field.
Output fields
| Field | Type | Description |
|---|---|---|
| _repidx | integer | Repeat index (zero-based). Output only when the _repidx=t option is specified. |
Error codes
Parse errors
| Error code | Message | Description |
|---|---|---|
| missing-count-option | - | The count option is not specified |
Runtime errors
N/A
Description
The repeat command copies each input record the number of times specified by count and outputs the copies. For example, specifying count=3 outputs 3 identical records for each input record.
With the _repidx=t option, a zero-based repeat index field (_repidx) is added to each copy, allowing you to distinguish which copy it is.
Examples
-
Repeating records 3 times
json "[{'name': 'Alice'}, {'name': 'Bob'}]" | repeat count=3Each record is copied 3 times, outputting a total of 6 records.
-
Outputting with the repeat index
json "[{'name': 'Alice'}]" | repeat count=3 _repidx=tOutputs 3 records with
_repidxvalues of 0, 1, and 2. -
Generating consecutive dates using the repeat index
json "[{'base_date': '2025-01-01'}]" | repeat count=7 _repidx=t | eval date = dateadd(date(base_date, "yyyy-MM-dd"), "day", _repidx) | fields dateGenerates 7 consecutive dates starting from the base date.