Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this service in Lookup attribute? #20

Open
MormonJesus69420 opened this issue Oct 3, 2023 · 4 comments
Open

How to use this service in Lookup attribute? #20

MormonJesus69420 opened this issue Oct 3, 2023 · 4 comments

Comments

@MormonJesus69420
Copy link

Hi!
I would like to use this service in LookupAttribute processor to find an Agent ID based on Agent Name and Agent Version that I get from FlowFile.

I've tried using this service in LookupAttribute but I don't know how to provide those two values to the service through the processor.

In your example you say that this service supports named parameters, for example:

SELECT name FROM foo WHERE sequence = :sequence AND catalog = :catalog

So I've tried putting it in the service with following query:

SELECT agent_id FROM agent WHERE agent_name = :agent_name AND agent_version = :agent_version

I've tried many ways of trying to provide values for these two parameters, but couldn't get it to work with LookupAttribute.
Then I've tried to simplify the SQL query, just to see if I can get it to work and used:

SELECT agent_id FROM agent WHERE agent_name = :agent_name

In LookupAttribute I've defined the property agent _id and given it various values such as "agent_name", "${agent_name}", "agent_name=${agent_name}", "agent_name,${agent_name}", and more, but it didn't work, every time I got following error when I tried running the LookupAttribute processor:

LookupAttribute[id=d9aa39f8-4bc7-1fe5-a4e4-9130dd75dfbf] Processing halted: yielding [1 sec]: org.springframework.dao.InvalidDataAccessApiUsageException: No value supplied for the SQL parameter 'agent': No value registered for key 'agent_name'

I've tried looking through source code to figure out how to fix this, but I have no idea.
Could you help me?

@mrcsparker
Copy link
Owner

I can definitely help you out. What version of NiFi are you using?

@MormonJesus69420
Copy link
Author

MormonJesus69420 commented Oct 4, 2023

Hi, I am using NiFi 1.22 currently. I had to hack the source code a tiny bit to use the service with LookupAttribute as it requires a StringLookupService, not a LookupService<String>. I done that just by adding implements StringLookupService and it seems to have worked.

@MormonJesus69420
Copy link
Author

Here's how I have configured the service SQL Query:
image
Here is the service itself:
image
And the LookupAttribute processor:
image
Like I've said before I have tried to set the value of agent_name in various ways, but nothing seems to work. It just throws the same error every time:

LookupAttribute[id=d9aa39f8-4bc7-1fe5-a4e4-9130dd75dfbf] Processing halted: yielding [1 sec]: org.springframework.dao.InvalidDataAccessApiUsageException: No value supplied for the SQL parameter 'agent_name': No value registered for key 'agent_name'

If I hardcode the value in SQL query it works just fine:
image
image
image

@MormonJesus69420
Copy link
Author

I have also tried following setup to no avail
MicrosoftTeams-image
MicrosoftTeams-image (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants