Member since
11-16-2015
905
Posts
666
Kudos Received
249
Solutions
My Accepted Solutions
| Title | Views | Posted |
|---|---|---|
| 497 | 09-30-2025 05:23 AM | |
| 809 | 06-26-2025 01:21 PM | |
| 742 | 06-19-2025 02:48 PM | |
| 915 | 05-30-2025 01:53 PM | |
| 11649 | 02-22-2024 12:38 PM |
04-19-2018
12:37 PM
For GetFile it does not matter the structure or format of the file, but it does appear that the NiFi process cannot read from that folder.
... View more
04-19-2018
12:18 PM
1 Kudo
It appears you are trying to get files from the /temp folder on the local filesystem, and that folder is not readable by the OS user running NiFi. Can you verify for the owner of the NiFi process that you can read from that folder?
... View more
04-17-2018
02:01 PM
I am working on NIFI-4456 which will allow the JSON reader/writer to support the "one JSON per line" format as well as the "JSON array" format for input and output, so you will be able to read in one JSON per line and output a JSON array, using ConvertRecord (or any other record-aware processor). In the meantime, you can use the following crude script in an ExecuteGroovyScript processor to process your entire file (avoiding the Split/Merge pattern), it should get you what you want: def flowFile = session.get()
if(!flowFile) return
flowFile = session.write(flowFile, {inStream, outStream ->
outStream.write('['.bytes)
inStream.eachLine { line, i ->
if(i > 1) outStream.write(','.bytes)
outStream.write(line.bytes)
}
outStream.write(']'.bytes)
} as StreamCallback)
session.transfer(flowFile, REL_SUCCESS) The script just adds array brackets around the whole doc, and separates the lines by a comma. I did the crude version because it doesn't need to load the entire input content into memory. If you need more control over the JSON objects, you could iterate over the lines (still with eachLine), use JsonSlurper to deserialize each string into a JSON object, then add each object to an array, then use JsonOutput to serialize the whole thing back to a string. However that involves having the entire content in memory and could get unwieldy for large input flow files.
... View more
04-12-2018
01:35 PM
As of NiFi 1.5.0 (via NIFI-4684), you can now specify the prefix in ConvertJSONToSQL. The property defaults to "sql" to maintain existing behavior, but can be changed to "hiveql" for use with PutHiveQL.
... View more
04-06-2018
11:00 PM
You use flowFileIn to get some attributes but don't use it later and don't transfer it either. The former means you'll break the provenance chain and the latter means you'll get an error since flowFileIn exists in the session. For the former, I recommend passing it into session.create(flowFileIn), such that the child flow file will inherit from the parent (keeping the provenance chain). For the latter, since you are transferring the child flow file, you can remove the incoming flow file with session.remove(flowFileIn) at the end of the script. I am just eyeballing the code so if that doesn't fix the errors please let me know and I'll edit my answer after running with your script and looking more at it.
... View more
04-06-2018
03:26 PM
What version of NiFi are you using? You should definitely be able to use it when it is specified in the Module Directory property. Alternatively, if you just need a Connection from the driver, you could create a DBCPConnectionPool that uses that JAR, then access that controller service to get a Connection. See my blog post and the documentation for ExecuteGroovyScript (which makes this a lot easier than the plain ExecuteScript).
... View more
04-06-2018
02:40 PM
You don't need to specify that parameter, in curl the -o lets you pick the destination of the output. In InvokeHttp the response will be in the content of the outgoing flow file. If you want to put that content into a file, you can use PutFile after InvokeHttp.
... View more
04-05-2018
11:26 PM
I think you should be able to provide "Authorization" in Attributes to Send, and have an attribute "Authorization" with value "Bearer [OAUTH2_TOKEN]", with that value replaced with the token (you can use UpdateAttribute with Expression Language to set all that up). Then you should be able to use the URL that works with curl. If that doesn't work, try an attribute with any name (say, "auth") with value "Authorization: Bearer [OAUTH2_TOKEN]" and include "auth" in the Attributes to Send property.
... View more
04-05-2018
01:16 PM
I used Groovy's findAll method for filtering/iterating in my example, you'd just have to use the Javascript idiom, maybe something like: for(var pdMap in context.getProperties()) { if(pd.getKey().isDynamic()) { // This is a user-defined "dynamic" property, the ExecuteScript properties won't show up here } } Having said that, if you are only using Javascript in order to parse JSON, you can keep Groovy and use JsonSlurper and JsonOutput and other handy classes for manipulating JSON objects.
... View more
04-05-2018
01:07 PM
You might be able to use jvm-npm as a bridge to load that module, but see the documentation on the jvm-npm site for restrictions (such as needing to be a "pure" NPM module that does not depend on the Node.js API)
... View more