Member since
07-29-2020
574
Posts
323
Kudos Received
176
Solutions
My Accepted Solutions
| Title | Views | Posted |
|---|---|---|
| 2155 | 12-20-2024 05:49 AM | |
| 2452 | 12-19-2024 08:33 PM | |
| 2201 | 12-19-2024 06:48 AM | |
| 1463 | 12-17-2024 12:56 PM | |
| 2107 | 12-16-2024 04:38 AM |
05-03-2023
06:52 PM
1 Kudo
Hi, It seems like you are generating your SQL from JSONToSQL kind of processor and then using PUT SQL to execute the generated SQL statement from earlier processor , is this correct? If that is the case I dont think there is an easy way to capture the actual values in the SQL statement as they are expected to be part of the generated sql flow file attribute in the format of "sql.args.N.value" based on the PUTSQL documentation. The only suggestion I have to overcome such thing is to write your custom code inside ExecuteScript processpr after the "retries-exceeded" relationship to replace the place holders (?,?,?..) in the flowfile content with sql.args.N.value attribute where the N = place holder Index + 1, so you have to write some logic to extract the place holder , save into variable , split the variable using (,), loop through the array of "?", construct new variable with sql.args.[i+1]ivalue , when the loop finish replace the place holder string with the new value string , then store new result into new flowfile content and send to success. For more info on writing custom script using ExecuteScript : https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-1/ta-p/248922 https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018 If anyone has a better idea please feel free to provide your input. If that helps please accept solution. Thanks
... View more
05-02-2023
09:48 AM
2 Kudos
Hi, This one was a little trickier from the first post, but it seems that there is nothing that you cant do with Jolt 🙂 . Please try the following spec: [
{
// combine all resourceRelationshipCharacteristic under one group
// and assign each element under the group unique key depending on
// its index location starting from first array under resourceRelationship (&3) and
// and ending with nested array resourceRelationshipCharacteristic ($1) so
// each element will have unique name 00,01,10,11...
"operation": "shift",
"spec": {
"resource": {
"resourceRelationship": {
"*": {
"resourceRelationshipCharacteristic": {
"*": {
"@(6,header.action)": "&3&1.action",
"@(6,header.timeStamp)": "&3&1.timeStamp",
"@(2,relationDrniId)": "&3&1.relationDrniId",
"*": "&3&1.&"
}
}
}
}
}
}
},
{
// bucket each element (00,01,10,11) value into new Array records
"operation": "shift",
"spec": {
"*": "records.[#1]"
}
}
] Hope that helps. I wonder if there is better\cleaner way @araujo @cotopaul @steven-matison
... View more
05-01-2023
06:30 AM
Hi , Can you provide the expected json output? The json you provided seems complex and nested. I'm not sure what exactly you are expecting.
... View more
04-26-2023
10:58 AM
1 Kudo
Hi, Try the following spec: [
{
// This is to remove the @ character from @type property because I could not
// figure out how to make it work in the second shift using escape character '\'
"operation": "shift",
"spec": {
"header": "&",
"resource": {
"\\@type": "resource.type",
"*": "resource.&"
}
}
},
{
"operation": "shift",
"spec": {
"resource": {
"resourceCharacteristic": {
"*": {
"name": "records[&1].propname",
"*": "records[&1].&",
"@(2,name)": "records[&1].name",
"@(2,type)": "records[&1].type",
"@(2,subtype)": "records[&1].subtype",
"@(2,drniId)": "records[&1].drniId",
"@(3,header.activityId)": "records[&1].activityId",
"@(3,header.timeStamp)": "records[&1].timeStamp"
}
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"records": {
"*": {
"value": "=join(',', @(1,value))"
}
}
}
}
] If that helps please accept solution. Thanks
... View more
04-20-2023
11:03 AM
1 Kudo
Hi , Can you replace the following: {
"operation": "shift",
"spec": {
"properties": {
"*": {
// simple match. Put the value '4' in the output under the "Rating" field
"title": "Questions[&1].question",
"type": {
"number": {
"#select": "Questions[&3].type"
},
"string": {
"#textarea": "Questions[&3].type"
},
"array": {
"#multiselect": "Questions[&3].type"
}
},
"$": "Questions[&1].id"
}
} with the following spec: {
"operation": "shift",
"spec": {
"properties": {
"*": {
// simple match. Put the value '4' in the output under the "Rating" field
"title": "Questions_&1.question",
"type": {
"number": {
"#select": "Questions_&3.type"
},
"string": {
"#textarea": "Questions_&3.type"
},
"array": {
"#multiselect": "Questions_&3.type"
}
},
"$": "Questions_&1.id"
}
}
}
}
,
{
"operation": "shift",
"spec": {
"*": "&",
"Questions_*": "Questions[]"
}
} Reference : https://stackoverflow.com/questions/70394715/remove-null-from-array-using-jolt If that helps please accept solution. Thanks
... View more
04-19-2023
09:42 AM
Hi, Can you explain on what basis are you trying to extract "options": 9876 & 9875 only and not 9874? Is it based on the index as in the first option and the second option only and ignore anything after?
... View more
04-17-2023
01:18 PM
Hi , Did you try the following: ${latitude:toDecimal():math("toRadians")} Or ${latitude:math("toRadians")}
... View more
04-17-2023
09:21 AM
Try the below spec. Again not sure if this is the most efficient way. You might need to rethink your strategy if you are dealing with a lot of data: [
{
//package all test fields into an outer object
"operation": "shift",
"spec": {
"test*": "outer.&",
"Details": "Details"
}
},
{
// Insert each outer object into Details element 0,1,..
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details.&1.&",
"@(3,outer)": "Details.&1.outer"
}
}
}
},
{
//Bucket each outer object (test1, test2...) into each details element
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details.&1.&",
"outer": {
"*": {
"@": "Details.&3.&"
}
}
}
}
}
},
{
//package details into seperate element under an Array
"operation": "shift",
"spec": {
"Details": {
"*": "[#1].Details.&"
}
}
}
]
... View more
04-16-2023
11:49 AM
Im not sure what you specified is makes sense because you would have two keys with the same name "Details" but different values. I assume what you want is this: {
"Details": {
"0": {
"test1": "test output",
"test2": "test output",
"id": "first",
"name": "the first one"
},
"1": {
"test1": "test output",
"test2": "test output",
"id": "second",
"name": "the second one"
}
}
} In this case the spec would be like this: [
{
//package all test fields into an outer object
"operation": "shift",
"spec": {
"test*": "outer.&",
"Details": "Details"
}
},
{
// Insert each outer object into Details element 0,1,..
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details.&1.&",
"@(3,outer)": "Details.&1.outer"
}
}
}
},
{
//Bucket each outer object (test1, test2...) into each details element
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details.&1.&",
"outer": {
"*": {
"@": "Details.&3.&"
}
}
}
}
}
}
] Not sure if this is the best way, if someone knows a better way please provide your suggestion. If that answers your question please accept solution. Thanks
... View more
04-16-2023
08:19 AM
Hi, You have not specified the desired output, but would the following give you what you are looking for: [
{
"operation": "shift",
"spec": {
"Details": {
"*": {
"*": "Details[#2].&"
}
},
"*": "outer[].&"
}
},
{
"operation": "shift",
"spec": {
"Details": "Details",
"outer": {
"*": {
"*": "Details[&1].&"
}
}
}
}
] if that helps please accept solution. Thanks
... View more