curl -X PUT -H "Content-Type: application/json" -d...
# troubleshooting
a
curl -X PUT -H "Content-Type: application/json" -d @game_handsNew.json "http://localhost:9000/tables/game_hands_data_REALTIME" {"unrecognizedProperties":{"/tableIndexConfig/jsonIndexConfigs/winnerDetail/includePaths":null,"/tableIndexConfig/jsonIndexConfigs/winnerDetail/excludePaths":null,"/tableIndexConfig/jsonIndexConfigs/winnerDetail/excludeFields":null,"/tableIndexConfig/jsonIndexConfigs/winnerDetail/indexPaths":null,"/tableIndexConfig/jsonIndexConfigs/card/includePaths":null,"/tableIndexConfig/jsonIndexConfigs/card/excludePaths":null,"/tableIndexConfig/jsonIndexConfigs/card/excludeFields":null,"/tableIndexConfig/jsonIndexConfigs/card/indexPaths":null,"/tableIndexConfig/jsonIndexConfigs/communityCard/includePaths":null,"/tableIndexConfig/jsonIndexConfigs/communityCard/excludePaths":null,"/tableIndexConfig/jsonIndexConfigs/communityCard/excludeFields":null,"/tableIndexConfig/jsonIndexConfigs/communityCard/indexPaths":null},"status":"Table config updated for game_hands_data_REALTIME"}%
"tableIndexConfig": {
"autoGeneratedInvertedIndex": false,
"enableDynamicStarTreeCreation": false,
"columnMajorSegmentBuilderEnabled": true,
"optimizeDictionaryForMetrics": false,
"noDictionarySizeRatioThreshold": 0.85,
"varLengthDictionaryColumns": [],
"rangeIndexVersion": 2,
"loadMode": "MMAP",
"streamConfigs": {
"streamType": "kafka",
"stream.kafka.topic.name": "user_stream_primary",
"stream.kafka.broker.list": "localhost:9092",
"stream.kafka.consumer.type": "lowlevel",
"stream.kafka.consumer.prop.auto.offset.reset": "smallest",
"stream.kafka.consumer.factory.class.name": "org.apache.pinot.plugin.stream.kafka20.KafkaConsumerFactory",
"stream.kafka.decoder.class.name": "org.apache.pinot.plugin.stream.kafka.KafkaJSONMessageDecoder",
"realtime.segment.flush.threshold.rows": "0",
"realtime.segment.flush.threshold.segment.rows": "0",
"realtime.segment.flush.threshold.time": "24h",
"realtime.segment.flush.threshold.segment.size": "100M"
},
"enableDefaultStarTree": false,
"aggregateMetrics": false,
"nullHandlingEnabled": false,
"optimizeDictionary": false,
"onHeapDictionaryColumns": [],
"rangeIndexColumns": [],
"sortedColumn": [],
"bloomFilterColumns": [],
"invertedIndexColumns": [],
"noDictionaryColumns": [],
"createInvertedIndexDuringSegmentGeneration": false,
"jsonIndexConfigs": {
"winnerDetail": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"includePaths": null,
"excludePaths": null,
"excludeFields": null,
"indexPaths": null
},
"card": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"includePaths": null,
"excludePaths": null,
"excludeFields": null,
"indexPaths": null
},
"communityCard": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"includePaths": null,
"excludePaths": null,
"excludeFields": null,
"indexPaths": null
}
}
}
not able to understand why it has returned such a responce , is there anything wrong with my configs ? @Maximilian Lau @Gonzalo Ortiz @Mayank
y
This is a deprecated configuration method, consider switching to
fieldConfigList.indexes
- https://docs.pinot.apache.org/basics/indexing/json-index#deprecated-ways-to-configure-json-indexes.
g
also, I would recommend to do not explicitly set the configurations where you are using the default value. They are just creating visual noise which makes it more difficult to find the issue
a
aaahh thats the reason it gave the error ? but in the doc says they are still compatible so i dont think there shoudl be an issue
@Gonzalo Ortiz so should I go with fieldConfig list ?
"jsonIndexConfigs": {
"winnerDetail": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"includePaths": null,
"excludePaths": null,
"excludeFields": null,
"indexPaths": null
}
which of the configurations can I remove or should I remove ?
g
you can find them here
ie you are setting maxLevels to the default value, excludeArrays to the default values... I didn't check all properties, but I would say you are setting everything to the default value
a
jsonIndexConfigs": {
"winnerDetail": {
"excludeArray": false,
"disableCrossArrayUnnest": true,
"indexPaths": null
}
@Gonzalo Ortiz. I have posted the configs again and this is how my json looks
g
I would need more context than just a json 😄
a
Screenshot 2025-01-07 at 2.37.20 PM.png
Copy code
"communityCards": [
    {
        "card_suit": "HEART",
        "card_value": 10
    },
    {
        "card_suit": "SPADE",
        "card_value": 2
    },
    {
        "card_suit": "HEART",
        "card_value": 5
    },
    {
        "card_suit": "SPADE",
        "card_value": 10
    },
    {
        "card_suit": "CLUB",
        "card_value": 9
    }
],
thats the maximun nesting in my json data @Gonzalo Ortiz. let me know if you need anything else
g
can you migrate to the new config mode, as suggested by @Yash Mayya?
a
yes I can will do that but the inner properties will remian same right ? so wanted to take you info on that. let me update to new configs and post it here
{
"tableName": "user_stream_primary_REALTIME",
"tableType": "REALTIME",
"segmentsConfig": {
"timeColumnName": "last_login",
"minimizeDataMovement": false,
"schemaName": "user_stream_primary",
"replication": "1",
"replicasPerPartition": "1"
},
"tenants": {
"broker": "DefaultTenant",
"server": "DefaultTenant",
"tagOverrideConfig": {}
},
"tableIndexConfig": {
"autoGeneratedInvertedIndex": false,
"enableDynamicStarTreeCreation": false,
"columnMajorSegmentBuilderEnabled": true,
"optimizeDictionaryForMetrics": false,
"noDictionarySizeRatioThreshold": 0.85,
"varLengthDictionaryColumns": [],
"rangeIndexVersion": 2,
"loadMode": "MMAP",
"streamConfigs": {
"streamType": "kafka",
"stream.kafka.topic.name": "user_stream_primary",
"stream.kafka.broker.list": "localhost:9092",
"stream.kafka.consumer.type": "lowlevel",
"stream.kafka.consumer.prop.auto.offset.reset": "smallest",
"stream.kafka.consumer.factory.class.name": "org.apache.pinot.plugin.stream.kafka20.KafkaConsumerFactory",
"stream.kafka.decoder.class.name": "org.apache.pinot.plugin.stream.kafka.KafkaJSONMessageDecoder",
"realtime.segment.flush.threshold.rows": "0",
"realtime.segment.flush.threshold.segment.rows": "0",
"realtime.segment.flush.threshold.time": "24h",
"realtime.segment.flush.threshold.segment.size": "100M"
},
"enableDefaultStarTree": false,
"aggregateMetrics": false,
"nullHandlingEnabled": false,
"optimizeDictionary": false,
"onHeapDictionaryColumns": [],
"rangeIndexColumns": [],
"sortedColumn": [],
"bloomFilterColumns": [],
"invertedIndexColumns": [],
"noDictionaryColumns": [],
"createInvertedIndexDuringSegmentGeneration": false
},
"fieldConfigList": [
{
"name": "winnerDetail",
"indexes": {
"json": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"indexPaths": null
}
}
}
]
},
"metadata": {},
"quota": {},
"routing": {
"instanceSelectorType": "strictReplicaGroup"
},
"query": {},
"upsertConfig": {
"mode": "FULL",
"defaultPartialUpsertStrategy": "OVERWRITE",
"upsertViewRefreshIntervalMs": 3000,
"hashFunction": "NONE",
"enablePreload": false,
"consistencyMode": "NONE",
"enableSnapshot": false,
"metadataTTL": 0,
"deletedKeysTTL": 0,
"dropOutOfOrderRecord": false,
"allowPartialUpsertConsumptionDuringCommit": false
},
"ingestionConfig": {
"continueOnError": false,
"rowTimeValueCheck": false,
"transformConfigs": [
{
"columnName": "userstr",
"transformFunction": "json_format(person)"
}
],
"segmentTimeValueCheck": true
},
"isDimTable": false
}
hi @Yash Mayya can you check now if its fine ?
y
Looks okay to me, did you try updating it?
g
I'm sorry Aditya, but we cannot validate your configuration by ourself. We are glad to help, but you need to be more proactive. Please try to apply the new config and report the specific errors if you are not able to fix them by yourself.
a
"fieldConfigList": [
{
"name": "winnerDetail",
"indexes": {
"json": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"indexPaths": null
}
}
}
]
},
I guess I have an extra '}' here I might need to remove it
"fieldConfigList": [
{
"name": "winnerDetail",
"indexes": {
"json": {
"maxLevels": -1,
"excludeArray": false,
"disableCrossArrayUnnest": true,
"indexPaths": null
}
}
}
]
should be like this I suppose. It wont be inside t`ableindexconfig.` right
y
I think the documentation should be sufficient - https://docs.pinot.apache.org/basics/indexing/json-index. Please let us know if something is missing there or unclear.
a
sure @Gonzalo Ortiz apologies , let me try it
Actually my concenr was the properites inside the index "fieldConfigList": [ { "name": "winnerDetail", "indexes": { "json": { "maxLevels": -1, "excludeArray": false, "disableCrossArrayUnnest": true, "indexPaths": null } } }, { "name": "card", "indexes": { "json": { "maxLevels": -1, "excludeArray": false, "disableCrossArrayUnnest": true, "indexPaths": null } } }, { "name": "communityCard", "indexes": { "json": { "maxLevels": -1, "excludeArray": false, "disableCrossArrayUnnest": true, "indexPaths": null } } } ] as you said we might hvae to remove few things.
g
You don't have to, but it is recommended to do not explicity set values to their default value. For example
maxLevels
,
excludeArray
and
indexPaths
are being set to the default values (as specified in the table in the doc)
but unless there is a typo in your config or an error in the documentation (or you are using and older version!), the config you share should work. Again, we are not machines, we didn't validate your document so if there is a typo we cannot know it
which pinot version are you using?
a
actually I pushd it and no errors are there so no worries , I am sorry dodnt really want you to validate it for me without me running into errors I am using 1.2 version
I was reading the documentation and for the index path
Copy code
indexPaths
Index the given paths, e.g. *.*, a.**. Paths
this is mentioned so is it equivalent to *`winnerDetail.` for my data
Copy code
"winnerDetails": [
    {
        "winnerUserId": 12121,
        "winnerUserName": "user12121"
    }
],
g
Then remember to use https://docs.pinot.apache.org/release-1.2.0/basics/indexing/json-index as documentation. For example
indexPaths
is a new field included in 1.3.0 (currently in snapshot)
a
I see got it
so ill remove it probably
then
Json index has been applied successfully but the query time is almost the same which it was before close to 8 seconds and also my segment size has increased from 670MB to 2 GB after I indexed my fields and did a reload all segments again
SELECT userId
FROM game_hands_data
where json_extract_scalar(card, '$[0].card_value', 'STRING') = '4'
group by userId
is it because of the json indexing? its only applied on 3 columns .really couldn't understnd why the size would increase 3 times
Screenshot 2025-01-07 at 3.56.57 PM.png
g
segments include the indexes and json indexes are expensive. That increase doesn't look crazy to me taking into account the kind of documents you are ingesting
tbh your model seems pretty regular. Did you tried to write it in pure SQL? ie having a table with each communityCard?
a
I see , but it was 670 MB earlier and now its 2.13 GB more than three times actually and my single record size in json payload is abount 4kb actually I have 57 columns
g
Pinot is not a database optimized to store jsons. Similar to postgres, Pinot can do some tricks (ie the JSON index) but the expectation is that these json fields are going to be used for very sparse and schema flexible data. If as it looks like, your data is very regular, the best practice would be to try to model it as tables and columns.
a
I see so to break the json into columns right ? so we dont need json indexing , I see what you mean . yeah with and without indexing the query return time is literally the same no improvement. so I guess ill speak and see if we can break the json into columns.
also I read into the documentation tht json_match will be little better to use as using json_scalar is a heavy operation
g
yes, if you do so, probably the space on disk will be reduced to less than 600MBs
a
ahh then I use other indexes or someething else which makes it more relevant
thanks man , really appreciate your inputs and suggestion. Big thank you. @Gonzalo Ortiz
SELECT *
FROM game_hands_data
where JSON_MATCH(winnerDetail, '"$.winnerDetails.winnerUserName"=''user12121''' )
I am trying to run this query but it doesnt seem to run as an alteranative to json_scalar_extract (edited) below is my json data snippet
Copy code
"userId": 12121, 
"handId": 88625293929,
"username": "user12121",
"handRank": "STRAIGHT",
"handRankValue": 8,
"splashDropAmount": None,
"winnerDetail": [
    {
        "winnerUserId": 12121,
        "winnerUserName": "user12121"
    }
],
"isBombpot": True,
"isBombpotConfig": False,
"isDoubleboardGame": True
}
I have index on json column "transformConfigs": [ { "columnName": "winnerDetail", "transformFunction": "json_format(winnerDetails)" } ]
yes, if you do so, probably the space on disk will be reduced to less than 600MBs
this we wont be able to do it as it would create duplicate primary key IDs in the data base for such snippets
Copy code
"cards": [
    {
        "card_suit": "DIAMOND",
        "card_value": 4
    },
    {
        "card_suit": "CLUB",
        "card_value": 6
    }
],
as you can see here card_value will hold two values for the same cards under the same primary key
g
Oh, I see
y
but the query time is almost the same which it was before close to 8 seconds
json_extract_scalar
doesn't use the JSON index. You can try out
json_extract_index
instead - see https://github.com/apache/pinot/pull/12466, https://docs.pinot.apache.org/basics/indexing/json-index#how-to-use-the-json-index.
a
@Yash Mayya Json_extract_index works like a charm
thanks man appreciate it
I will be reading more about he json_insex fetching
y
Glad that worked for you, happy to help!