QueryRecord adds whitespace within CASE WHEN statament
06:00 20 Oct 2023

I have a JSON file:

[ {
  "id": 1
}, {
  "id": 2
} ]

And attribute ad.cost_type. For example now it contains value 0. I want to modify JSON's based on this attribute and wrote simple SQL-like script inside QueryRecord:

SELECT
    CASE
    WHEN ${ad.cost_type} = 0 THEN 'cpc'
    WHEN ${ad.cost_type} = 1 THEN 'cpm'
    WHEN ${ad.cost_type} = 3 THEN 'ocpm'
END AS type
*
FROM FLOWFILE

Result is:


[ {
  "type" : "cpc ",
  "id": 1
}, {
  "type" : "cpc ",
  "id": 2
} ]

As you can see I have an extra whitespace after value from attribute and i don't understand from where it came. What did i miss?

apache-nifi