Hi Nick,

I thought there was a discussion about adding a general database
lookup service, but I can't find LookupService impl available that can
fetch value from external databases.
If there's such controller service, you can use LookupAttribute processor.
(wondering if you're interested in contributing that..)

As a workaround, you may be able to construct a flow like this:

- Pass the input FlowFile into two branches, 'main' and 'lookup'
- At 'lookup' branch, fetch data with ExecuteSQL, then extract the
required data from the result and put it to a cache using
PutDistributedMapCache
- At 'main' branch, use LookupAttribute with
DistributedMapCacheLookupService to lookup the value stored by
'lookup' branch
- 'main' branch may need some retry & timeout mechanism

Or if the dataset is relatively small, you can download and save it as
a CSV file periodically, then lookup using LookupAttribute with
SimpleCsvFileLookupService.

Thanks and Happy Thanksgiving!
Koji
On Thu, Nov 22, 2018 at 5:58 AM Nick Carenza
<[email protected]> wrote:
>
> I would like to add a sql query result to attributes but I don't see a way to 
> do this currently. Anyone know of a processor I am missing or have a 
> workaround?
>
> Preferably the result columns would become attributes.
>
> I think I coooouuld use exctract test to move the current flowfile contents 
> into an attribute, runthe query with ExecuteSQL, convert to json from avro, 
> ExtractJsonPath the columns I want then use ReplaceText to bring the original 
> flowfile back... but that seems excessive and it requires putting the larger 
> of the 2 contents in an attribute.
>
> Thanks and Happy Thanksgiving Nifi-Users,
> Nick

Reply via email to