Anyone know how to extract data from nested json: ...
# troubleshooting
h
Anyone know how to extract data from nested json: Not sure how to extract “data.device” and put it in “device” column.
Copy code
Event coming in kafka:
{
  "user_id": "1234",
  "data": {
    "device": "abcd"
  }
}


Schema I need for table:
{
  {
    "name": "user_id",
    "dataType": "STRING"
  },
  {
    "name": "device",
    "dataType": "STRING"
  },
}
🟢 1
f
{
"columnName": "device",
"transformFunction": "\"data.device\""
},
-> that should do the trick 😉
h
Let me try
f
Or using
Copy code
{
      "columnName": "device",
      "transformFunction": "JSONPATHSTRING(data,'$.device')"
    },
h
First one did not work. Thanks “jsonpathstring” worked.
f
I was thinking from you question you’ve been exploding the neasted JSON my first answer 😉 For reference you will find usefull example here https://docs.pinot.apache.org/developers/advanced/ingestion-level-transformations#inbuilt-pinot-functions (offcicial doc) or here https://dev.startree.ai/docs/pinot/recipes/