Extracts key-value pairs from a source column and writes them to a new column. |
Source column must be of String type, although the data can be formatted as other data types. The generated column is of Object type.
Your source column (MyKeyValues
) is formatted in the following manner:
key1=value1,key2=value2 |
The following transform extracts the key-value pairs. The key
parameter contains a single pattern that matches all keys that you want to extract:
extractkv col: MyKeyValues key:`{alpha}+{digit}` valueafter: '=' delimiter: ',' |
Output: The generated column contains data that looks like the following:
{"key1":"value1","key2":"value2"} |
If the source data contained additional keys which were not specified in the transform, those key-value pairs would not appear in the generated column.
extractkv col:column_ref delimiter:string_literal_pattern key:string_literal_pattern valueafter:string_literal_pattern [as:'new_column_name'] |
Parameter | Required? | Data Type | Description |
---|---|---|---|
extractkv | Y | transform | Name of the transform |
col | Y | string | Source column name |
delimiter | Y | string | String literal or pattern that identifies the separator between key-value pairs |
key | Y | string | Pattern that identifies the key to match |
valueafter | Y | string | String literal or pattern after which is located a key's value |
as | N | string | Name of the newly generated column |
Identifies the column to which to apply the transform. You can specify only one column.
Required? | Data Type |
---|---|
Yes | String (column name) |
Tip: You can insert the Unicode equivalent character for this parameter value using a regular expression of the form |
Required? | Data Type |
---|---|
Yes | String (literal, regular expression, or |
Required? | Data Type |
---|---|
Yes | Single pattern representing the individual keys to extract. |
Required? | Data Type |
---|---|
Yes | String (literal, regular expression, or |
Required? | Data Type |
---|---|
No | String (column name) |