Member since
08-01-2021
48
Posts
10
Kudos Received
7
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1731 | 11-18-2022 09:06 AM | |
2118 | 11-15-2022 05:46 PM | |
1655 | 10-12-2022 03:18 AM | |
1123 | 10-11-2022 08:52 AM | |
2922 | 10-08-2022 08:23 AM |
10-12-2022
03:18 AM
1 Kudo
Perhaps JoltTransformRecord could help you. The jolt transformation "shift" let's you rename fields - in a csv file's case, headers. If you know all your replaces ahead of time, you could define a transformation like: { operation: shift spec: { "kgg":"g", "c34":"c", "*":"&" } } Note the last shift, "*":"&" , which would transfer over the rest of the headers you didn't specifically rename.
... View more
10-11-2022
08:52 AM
1 Kudo
Perhaps you can use the processor CalculateRecordStats to count how many records of each situation code you have in a given file, then once that is put in your attributes you can try a couple of different methods to decide what to do, for example you can use RouteOnAttribute and then check if attribute sit_code.pod>0 then send to extract_one_pod_element and there you could use QueryRecord to take out exactly one POD element, otherwise route to LIV, AAR, etc.
... View more
10-11-2022
07:56 AM
I believe ForkRecord is exactly the solution you are looking for. Read here: https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.17.0/org.apache.nifi.processors.standard.ForkRecord/additionalDetails.html The processor will allow you to split 1 json which has a nested array field "result" into many jsons with the same parent fields but only 1 result per json. Hope this helps!
... View more
10-11-2022
07:49 AM
I believe you could use QueryRecord to take you in the right direction. You could define properties to route files based on their situation code, for example: Key: POD Value: SELECT * FROM flowfile WHERE situation_code = 'POD' LIMIT 1 This would route 1 element in your input array where the code is POD to the new relationship "POD" (same as the dynamic property name). This doesn't exactly match your case of retrieving an element only if higher priority codes weren't found, but perhaps you could use this example to get closer to a solution. Good luck!
... View more
10-10-2022
10:43 PM
Perhaps the connection you set between PutHDFS and UpdateHive3Table doesn't send the original file? I am a bit confused by your flow in general.. why convert to avro? Where are you reading files from? Why do you PutHDFS and then UpdateHiveTable instead of just using PutHiveQL?
... View more
10-10-2022
10:36 PM
@morti To add to this, this is essentially (if not just very similar) to nifi's Record API where Record processors require a RecordReader/Writer controller service where the schema for the incoming/outgoing files is defined. All these processors can get their schema from some registry, or have it configured hard-coded, or try to infer the schema, or simply rely on the schema that was given to the flowfile earlier in the flow. I think it's worth looking into Records in nifi, they're designed specifically for well-defined data and use-cases similar to what your described
... View more
10-08-2022
10:15 PM
1 Kudo
The ReplaceText procesor has a prepend/append mode which might be of help
... View more
10-08-2022
08:23 AM
1 Kudo
Hey @Fredi , I believe the answer for your problem is the processor UpdateRecord. Update record allows you to directly manipulate the fields in your file content. You add dynamic properties to the processor where the key of the property is /<field> (so in your case, '/api_value'), and in the value of this dynamic property you can write down some logic to determine what value to insert into api_value. In the processor, there is a field called "Replacement Value Strategy", which defines how the value of the property will be read. If you set this to "Record Path Value", it means you can now give a path to a different field in your file (url_value!) - I can't test this right now because I'm not at my office, but I'm not entirely sure whether you can manipulate the result after giving a record path (to extract the api_value from the evaluated url_value). Regardless, I'm just about 100% sure this can be done with two processors - One EvaluateJsonPath to extract the url_value into an attribute, then UpdateRecord that uses the 'Literal Value' replacement strategy - with this strategy, you can just add a property with key '/api_value' and value '${url_value}' (or whatever attribute name you gave to the extracted url_value) and once you can access url_value with the expression language (via ${url_value}) you can use all the available functions to manipulate expression language variables. Here's an article with a couple of examples on UpdateRecord: https://community.cloudera.com/t5/Community-Articles/Update-the-Contents-of-FlowFile-by-using-UpdateRecord/ta-p/248267 (I noticed in the article they used some recordPath related functions like "replaceRegex", so I believe there might be a way to use these and then limit the entire issue to just one UpdateRecord processor! Sadly I'm not too familiar with these myself and this was the first time I've seen them) And here's the expression language documentation: https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html You can see there are lots of useful functions to extract your api_value once you have ${url_value} as an attribute variable, for example "substring", "find"/"replace", "ifElse", etc. all of which you can try and use to ensure only the api_value is left in the end. Hope this helps! I'm sure using ReplaceText and possibly JoltTransform could provide alternate solutions to the issue, however I believe UpdateRecord is the cleanest solution for this and truly makes use of the processor's abilities. If you struggle to use it correctly, you can reply with an example json and expected output and I'll try to write down the flow when I have time.
... View more
10-06-2022
08:33 AM
1 Kudo
Since ReplaceText can make use of regex groups, I believe you could do something along the lines of Match text: (.*) Replace text:<xml> '$1'</xml> $1 allows you to inject the first regex group you match, which in case of the regex above would match the entire file content. I may be wrong about needing to surround it with single quotes but a quick read of the processor's documentation should clear things up. This could be a hefty task if you need to load massive files into memory, however I don't believe your encoded strings should pose a problem. Hope this helps, it's always nice to optimize flows 🙂
... View more
10-06-2022
04:20 AM
I believe a ReplaceText where you just match the entire encoded content and then inject it into an xml already written as the replacement value would be the ideal way to do this.
... View more