Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 04-14-2023 08:29 AM
Hi All,
Looking for some help with JOLT transformatio, which i am completely new.
my input JSON looks like this
{
"type": "delete",
"timestamp": 1681484884000,
"binlog_filename": "bin.000003",
"binlog_position": 6378700,
"database": "db1",
"table_name": "records",
"table_id": 108,
"columns": [{
"id": 1,
"name": "id",
"column_type": 4,
"value": 259
}, {
"id": 2,
"name": "index_id",
"column_type": 4,
"value": 1
}, {
"id": 3,
"name": "state_id",
"column_type": 4,
"value": 1
}]
}This is from mysql binlogs.
I want to transform it to have a single field..
[{
"id": 259
}]
from one of the tutorials here in cloudera comminity, i saw this JOLT transformation.
[
{
"operation": "shift",
"spec": {
"columns": {
"*": {
"@(value)": "[#1].@(1,name)"
}
}
}
}
]
But it gives all fileds.. but I just need one filed which is the ID. I need to drop rest all fields..
Can someone please help in this regards.
Created 04-15-2023 08:23 AM
Hi,
If you are looking to set the id value for the first element in the columns array you can use the following spec:
[
{
"operation": "shift",
"spec": {
"columns": {
"0": {
"value": "[].@(1,name)"
}
}
}
}
]
If that helps please accept solution.
Created 04-15-2023 08:23 AM
Hi,
If you are looking to set the id value for the first element in the columns array you can use the following spec:
[
{
"operation": "shift",
"spec": {
"columns": {
"0": {
"value": "[].@(1,name)"
}
}
}
}
]
If that helps please accept solution.
Created 04-17-2023 05:21 AM
@SAMSAL Kudos to you.. it worked.. /\