ReplaceAt¶
Replaces the element at the given 0-based index of an ARRAY with a new value.
ReplaceAt(N, value) returns a new ARRAY with the element at index
N replaced by value. Out-of-range indices are silently ignored —
the array is returned unchanged.
Both the index and the replacement value can be literals or field
references; field references are resolved per row from the current
pipeline state. Field-reference indices must be INT-valued, while
field-reference values can be any scalar. The transformer also supports
infix arithmetic in the index parameter (e.g. :len - 1).
Available in new mode only.
Parameters¶
- 1 —
indexMandatory — accepts: INT, field -
0-based index, either as an integer literal or a field reference to an
INT-valued pipeline field. - 2 —
valueMandatory — accepts: BOOLEAN, DATE, FLOAT, INT, STRING, NULL, field -
Replacement value. May be a scalar literal or a field reference to any non-
ARRAYpipeline field.
Input type¶
ARRAY
Output type¶
ARRAY
Requires¶
- Exactly one ARRAY-typed pipeline input.
- When index is a field reference the referenced field must hold an INT.
Examples¶
Replace a literal position with a literal value
Use field-reference index and value
Replace the last element via infix arithmetic
Errors¶
-
`ReplaceAt': input must be ARRAY-typed- The pipeline value reaching the rule is not an
ARRAY.
-
`ReplaceAt': index field:idx' must be an integer`- The referenced index field is not an
INT.
-
`ReplaceAt': value field:val' could not be resolved`- The referenced value field is not in the pipeline or has no value.
-
`ReplaceAt' is only available in new mode- New mode is not enabled in
etl.conf.