Here is an example JOLT transformation that combines two rows without using an array:
Input:
{
"id": "123",
"name": "John",
"age": "30"
},
{
"id": "456",
"name": "Jane",
"age": "25"
}
JOLT transformation:
[
{
// Merge the two objects into one
"operation": "shift",
"spec": {
"0": "&",
"1": "&"
}
},
{
// Concatenate the id, name, and age values
"operation": "modify-overwrite-beta",
"spec": {
"id": "=concat(@(0,id),'_',@(1,id))",
"name": "=concat(@(0,name),' ',@(1,name))",
"age": "=concat(@(0,age),'_',@(1,age))"
}
},
{
// Remove the old id, name, and age keys
"operation": "remove",
"spec": {
"0": {"id": "", "name": "", "age": ""},
"1": {"id": "", "name": "", "age": ""}
}
}
]
Output:
{
"id": "123_456",
"name": "John Jane",
"age": "30_25"
}
In this example, we use the "shift" operation to merge the two input objects into one. Then, we use the "modify-overwrite-beta" operation to concatenate the id, name, and age values from each object into a single value. Finally, we remove the old id, name, and age keys using the "remove" operation.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-26 22:17:42 +0000
Seen: 11 times
Last updated: Jun 26 '23
What is the efficient way to obtain query results using the SKIP clause in Apache AGE?
How can JSON objects with dynamic keys be extracted in Athena/Presto?
What is the method and location of data storage in Apache AGE?
How can variables be interpreted as strings?
If values are present in a list of dictionaries, how can they be retrieved?
How can data be aggregated across various factor levels without altering the original levels?
How can I make a call with parameter using Flask (Jinja) and jQuery?
What is the method to retrieve every edge in Apache AGE?
How can we associate the type of a key within an object to that object?