Hello Experts, Issue extracting values from Kafka...
# troubleshooting
r
Hello Experts, Issue extracting values from Kafka Stream JSON using JSONPATH_STRING or equivalent JSON:
Copy code
{
  "_id": "56c6d0eb0cf2f1de556d486b",
  "leadId": "ff80818152f816fc0152f8a016cb2184",
  "city": "PUNE",
  "agreementType": "LL_AGREEMENT"
}
TableConfig:
Copy code
"ingestionConfig": {
      "transformConfigs": [
        {
          "columnName": "doc_agreement_type",
          "transformFunction": "JSONPATH_STRING('', '$.agreementType')"
        },
        {
          "columnName": "doc_lead_id",
          "transformFunction": "lower(leadId)"
        }
  ]
Issue:
doc_lead_id
is populated but
doc_agreement_type
is not (remains blank)
b
Hi . I think first argument of
JSONPATH_STRING('', '$.agreementType')
should not be blank but refer to a field name.
r
@Bolek Ziobrowski, As can be seen my JSON is a single column json. What field name should be used ?
I also tried adding a column in schema called
kafka_message
of type String hoping pinot would store the whole JSON there and i can refer to that column in Transformation function , but the column
kafka_message
remains NULL
b
Unfortunately I didn't find and anything similar in source code. The example I've seen refers to a nested field of a more complex json. Have you tried using something like :
Copy code
JSONPATH_STRING('agreementType', '$')
?
r
Wow! this works - but no clue what this signature means. There is no documentation of this function anywhere.
BTW, ‘$’ doesnot seem to mean whole JSON document.
JSONPATH_STRING('$', '$')
doesnt return the document. Wonder what exactly is this ‘$’
b
JsonPathString() function is documented at -> https://docs.pinot.apache.org/configuration-reference/functions/jsonpathstring . If you follow the json path link on that page - https://goessner.net/articles/JsonPath/ - you'll see that $ corresponds to root object.
r
I can see doc on
JSONPATHSTRING
and not
JSONPATH_STRING
. Even assuming they are same function, signature is:
JSONPATHSTRING(jsonField, 'jsonPath', [defaultValue]).
The usage
JSONPATH_STRING('agreementType', '$')
seems like first argument is ‘jsonPath’ !
I could not get to save whole JSON using:
JSONPATH_STRING('$', '$')
, any thoughts?