Search code examples
apache-nifi

QueryRecord returns error while using attributes (Apache NiFi)


I have a simple FlowFile which contains JSON:

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

And some attributes:

account.login = "some_email@gmail.com"
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?


Solution

  • 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