{ "columnName": "myDimension", "expression":...
# troubleshooting
a
{ "columnName": "myDimension", "expression": "jsonPath(UserInfo, '$.myDime')" or "expression": "jsonPathString(UserInfo, '$.myDime')" } MyDimention every time coming null, Sample Json {"myDateTime":1732180373,"UserInfo":{"myDime":"SAM NEW nested"},"myMetric":4}, what could be the reason?
x
I think
jsonPathString(UserInfo, '$.myDime')
should work. For the json data, is field
UserInfo
always present?
a
I am doing POC before implementing larger solution yes its always present, i did some more investigation and found below error Caught exception while transforming the record at offset: 42 , row: { 2024-11-21 170345 "nullValueFields" : [ ], 2024-11-21 170345 "fieldToValueMap" : { 2024-11-21 170345 "myMetric" : 4, 2024-11-21 170345 "myDateTime" : 1732188824, 2024-11-21 170345 "UserInfo" : { 2024-11-21 170345 "myDime" : "SAM NEW nested", 2024-11-21 170345 "MyDime1" : "samir", 2024-11-21 170345 "Id" : 1234 2024-11-21 170345 }, 2024-11-21 170345 "myDimension" : null 2024-11-21 170345 } 2024-11-21 170345 } 2024-11-21 170345 java.lang.RuntimeException: Caught exception while transforming data type for column: UserInfo Caused by: java.lang.IllegalStateException: Cannot read single-value from Collection: [SAM NEW nested, samir, 1234] for column: UserInfo,
{ "columnName": "myDimension", "transformFunction": "jsonFormat(UserInfo)" }, {"UserInfo":{"myDime":"SAM NEW nested","Id":1234,"MyDime1":"samir"},"myDateTime":1732189042,"myMetric":4}
x
how do you defined column
UserInfo
in schema
JSON?
cc: @Kartik Khare @Manish in case you know this behavior
a
Json : { "UserInfo": { "myDime": "SAM NEW nested", "Id": 1234, "MyDime1": "samir" }, "myDateTime": 1732189042, "myMetric": 4 } Schema : "dimensionFieldSpecs": [ { "name": "myDimension", "dataType": "STRING" }, { "name": "UserInfo", "dataType": "STRING" } ], Table : "transformConfigs": [ { "columnName": "myDimension", "transformFunction": "jsonFormat(UserInfo)" }, { "columnName": "myMetric", "transformFunction": "jsonPathString(myMetric)" }, { "columnName": "myDateTime", "transformFunction": "jsonPathString(myDateTime)" }, { "columnName": "UserInfo", "transformFunction": "json_format(UserInfo)" } ]
I am not able to see the plugin "pinot-stream-ingestion-kafka" although i can see "pinot-stream-ingestion" might be an reason? i have latest image of Pinot
x
in the schema, can you try to make
Copy code
{
  "name": "UserInfo",
  "dataType": "JSON"
}
?
for transform configs, just do
Copy code
"transformConfigs": [
    {
      "columnName": "myDimension",
      "transformFunction": "jsonPathString(UserInfo, '$.myDime')"
    }
  ]
a
I am able to see the Json Thanks 🙂 but still My Dimension is null can you please help me on this Table :"transformConfigs": [ { "columnName": "myDimension", "transformFunction": "jsonPathString(UserInfo, '$.myDime')" }, { "columnName": "myMetric", "transformFunction": "jsonPathString(myMetric)" }, { "columnName": "myDateTime", "transformFunction": "jsonPathString(myDateTime)" } ] Schema :"dimensionFieldSpecs": [ { "name": "myDimension", "dataType": "STRING", "singleValueField": false }, { "name": "UserInfo", "dataType": "JSON" } ], MyDimension is null
x
for the schema of
myDimension
why it’s an array? it should be
"singleValueField": true
right?
a
yes you are right, it should be true, value was coming null so i was trying multiple available options, although after making it true still Null.
x
are you ingesting data using batch or streaming
hmm, i’ve added example here for sample table/schema https://github.com/apache/pinot/pull/14525
can you please try on your end
which pinot version are you running
also is there any issue with json in your data for something like escape?
this is one sample row:
{"id":"7044874114","type":"PushEvent","actor":{"id":34993993,"login":"TyroLin","display_login":"TyroLin","gravatar_id":"","url":"https://api.github.com/users/TyroLin","avatar_url":"https://avatars.githubusercontent.com/u/34993993?"},"repo":{"id":115913428,"name":"TyroLin/tyro.github.com","url":"https://api.github.com/repos/TyroLin/tyro.github.com"},"payload":{"push_id":2226018070,"size":1,"distinct_size":1,"ref":"refs/heads/master","head":"19b7d90536d46029c5d82a9d41fd3e8be31133e9","before":"1805321bc66612931da0cd347d50c59b3540fb51","commits":[{"sha":"19b7d90536d46029c5d82a9d41fd3e8be31133e9","author":{"name":"TyroLin","email":"9fcc726da9d1b08ed46c67f8755f62f1eed7a873@users.noreply.github.com"},"message":"Set theme jekyll-theme-minimal","distinct":true,"url":"https://api.github.com/repos/TyroLin/tyro.github.com/commits/19b7d90536d46029c5d82a9d41fd3e8be31133e9"}]},"public":true,"created_at":"2018-01-01T11:00:00Z"}
a
I am using Kafka streaming, let me look at examples, and really appreciated your effort to help me :)
@Xiang Fu it worked, thanks for help :)