0
votes

I have a simple FlowFile which contains JSON:

{
  "name" : "ga:sessions",
  "val" : "0"
}

And some attributes:

account.login = "[email protected]"
account.id = "123456789"

I want to use QueryRecord processor to prepare JSON for saving into database. processor

But I get an error:

error

QueryRecord successfully set account_login from attribute but returns error. What is the problem? If I will not use attributes in QueryRecord SQL statement, I'll not get an error:

[{
  "metric_name" : "ga:sessions",
  "metric_value" : "0"
}]

How to solve it?

1
I am confused by this part in query to add the email... I think you need to do the select from the flowfile, to get those results in the flowfile - which is actually no different than the original flowfile. Assuming you have a larger upstream data set, the query should dial that down to results you want. Then after that add the email value to flowfile with another processor.... I believe the root cause is that the SQL inside the flowfile query is limited in functionality. - DS Steven Matison
I used QueryRecord before in the same way, but now it doesn't work. You can prepare JSON with Expression Language and put attributes to content. But i just used JoltTransform instead and all works fine. - funnelCONN
I tried to do it yesterday to add a string or attribute in the left side of the select and it definitely did not work. - DS Steven Matison

1 Answers

3
votes

In order for QueryRecord to recognize the literal string value in the query, you should use apostrophes.

Your query should look like this:

SELECT name AS metric_name,
val AS metric_value,
'${account.login}' as account_login
FROM FLOWFILE