QueryRecord - Filter out object containing empty array field
Hi Team,
Using QueryRecord to filter the incoming array of objects where each object has an array field.
The field can be an empty array or it contains some objects in it but it is not null. Tried a lot of SQL queries but didn't succeed. Also, I am trying to consider Record based approach as I want to work on multiple flow files instead of single ones
In Actual flow wanted to use ForkRecord on this array but it outputs an empty array if any object contains an empty array in the path so had to use QueryRecord before ForkRecord to filter those empty arrays. Not sure if it's the bug/expected behavior in ForkRecord
Flow:

GenerateFlowFile:

Custom Text:
[
{
"fields": [
{
"field": "field1"
},
{
"field": "field1"
}
]
},
{
"fields": []
},
{
"fields": [
{
"field": "field2"
},
{
"field": "field2"
}
]
},
{
"fields": [
{
"field": "field3"
},
{
"field": "field3"
}
]
}
]
Expected output: To filter out the 2nd object whose field is an empty array
QueryRecord:

Record Reader and Writer services are set to infer the schema
Solutions Tried:
1.


2.


3.

No Error but didn't filter out

4.


5.

No Error but didn't filter out
Using RPATH I was not able to pick specifically the first element to check if it exists or not


Got stuck because of this particular processor. Please help me out with the problem and let me know if any better way to do this with other processors. I'm avoiding working with single-flow files as am aware of the EvaluateJsonPath -> RouteOnAttribute solution and want to work specifically on Record based.

