- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
QueryRecord processor issue with nested JSON
- Labels:
-
Apache NiFi
Created 03-14-2022 01:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am facing issue accessing one of the child json attribute while forming SQL in QureyRecord processor. PFB details
here is my Avro schema added for JSON reader and writter.
{
"name": "MyClass",
"type": "record",
"namespace": "com.acme.avro",
"fields": [
{
"name": "labels",
"type": {
"name": "labels",
"type": "record",
"fields": [
{
"name": "__name__",
"type": "string"
},
{
"name": "cucsMemoryUnitInstanceId",
"type": "string"
},
{
"name": "instance",
"type": "string"
},
{
"name": "job",
"type": "string"
},
{
"name": "monitor",
"type": "string"
},
{
"name": "site_identifier",
"type": "string"
}
]
}
},
{
"name": "name",
"type": "string"
},
{
"name": "timestamp",
"type": "string"
},
{
"name": "value",
"type": "string"
},
{
"name": "producedAt",
"type": "string"
}
]
}
now the SQL quary for first level attribute works fine.
like SELECT * from FLOWFILE where name = 'xyz' or
SELECT * from FLOWFILE where producedAt = 'dd-mm-yyyy'
however If I have to access attribute of nested JSON it wont work
e.g
SELECT * from FLOWFILE where site_identifier = 'xyz' --> This throws the error.
Created 03-14-2022 07:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Onkar_Gagre ,
You can use a Record Path expression to do what you want in a QueryRecord processor. Please try the example below:
SELECT *
FROM FLOWFILE
WHERE RPATH(labels, '/site_identifier') = 'xyz'
Cheers,
André
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Created 03-14-2022 07:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, @Onkar_Gagre ,
You can use a Record Path expression to do what you want in a QueryRecord processor. Please try the example below:
SELECT *
FROM FLOWFILE
WHERE RPATH(labels, '/site_identifier') = 'xyz'
Cheers,
André
--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Created 03-14-2022 11:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Araujo. This has helped a lot.
