Member since
03-21-2018
13
Posts
1
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
6585 | 03-31-2018 05:26 PM |
12-15-2022
05:16 AM
@Bello as this is an older post, you would have a better chance of receiving a resolution by starting a new thread. This will also be an opportunity to provide details specific to your environment that could aid others in assisting you with a more accurate answer to your question. You can link this thread as a reference in your new post.
... View more
03-31-2018
05:26 PM
1 Kudo
I am able to resolve this. var flowFile = session.get();
if (flowFile != null) {
var StreamCallback = Java.type("org.apache.nifi.processor.io.StreamCallback")
var IOUtils = Java.type("org.apache.commons.io.IOUtils")
var StandardCharsets = Java.type("java.nio.charset.StandardCharsets")
var JString = Java.type("java.lang.String")
var TokenAttr = flowFile.getAttribute('token_value')
var JsonTokenAttr = JSON.parse(TokenAttr) ; flowFile = session.write(flowFile,
new StreamCallback(function(inputStream, outputStream) {
var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
var obj = JSON.parse(text)
var accounts = obj['customer-accounts'];
var convertedAccounts = accounts.map(function(account, index) {
account['account_number'] = JsonTokenAttr.Tokens[index];return account;
});
var newObj = {'customer-accounts' : convertedAccounts }
var builder = new JString()
outputStream.write(JSON.stringify(newObj, null, '\t').getBytes(StandardCharsets.UTF_8))
})) session.transfer(flowFile, REL_SUCCESS)
}
... View more
04-28-2019
02:56 PM
1 Kudo
We can use rank approach which is faster than max , max scans the table twice: Here , partition column is load_date: select ld_dt.txnno , ld_dt.txndate , ld_dt.custno , ld_dt.amount , ld_dt.productno , ld_dt.spendby , ld_dt.load_date from (select *,dense_rank() over (order by load_date desc) dt_rnk from datastore_s2.transactions)ld_dt where ld_dt.dt_rnk=1
... View more