Hi,
I was exploring the QueryRecord this afternoon.
I was hoping to use this to just take a couple of json elements from the
message that has many json elements ( in the incoming flowfile).

I expected "select ingredients, recipe from FLOWFILE"
to produce a json with just the "ingredients, recipe" and not include the
"inventor". ex:
[{"recipe":"Tacos","ingredients":[{"name":"Beef"},{"name":"Lettuce"},{"name":"Cheese"}]}]
instead I got:
[{"recipe":"Tacos","ingredients":[{"name":"Beef"},{"name":"Lettuce"},{"name":"Cheese"}],"inventor":null}]

Having that "inventor:null" is just noise, and misleading. And, for example
if I have 25 unused elements that would be 23 Null's....

I have the same issue if I select a single column too, for example:
select ingredients from FLOWFILE produces:
[{"recipe":null,"ingredients":[{"name":"Beef"},{"name":"Lettuce"},{"name":"Cheese"}],"inventor":null}]

Here is the input
{
    "recipe": "Tacos",
    "ingredients": [
        {
            "name": "Beef"
        },
        {
            "name": "Lettuce"
        },
        {
            "name": "Cheese"
        }
    ],
    "inventor": {
        "name": "Alex",
        "age": 25
    }
}
I used the InferAvroSchema processor to create the avroSchema....
I used the JsonPathReader and have property for each json path
ingredients = $.ingredients
inventor = $.inventor
recipe = $.recipe

I did nothing with the "JsonRecordSetWriter".

Maybe I should attach a template....

Thanks for your help!
Carl

Reply via email to