arrayReplaceAll
Description
Returns a new array where all instances of a specified value are replaced with a new value.
- The element type must match the array type.
- Supported element types include
string,bool,number,interval,timestamp,regexp, andenum.
Syntax
Like many functions in DataPrime, arrayReplaceAll supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
| array | array | true | The array to modify |
| value | T | true | The value to replace |
| newValue | T | true | The replacement value, must match the array type |
Example
Use case: Replace outdated schema values in arrays
Suppose you have a list of values where some still use an outdated schema. Consider the following inputs:
By replacing all occurrences of "OldVal1" with "NewVal1", you ensure data consistency before further processing.
Example query
Example output
The result will replace all outdated values:
Theme
Light