The error `{"code":400,"error":"The upsert table c...
# troubleshooting
a
The error
{"code":400,"error":"The upsert table cannot have star-tree index."}
occurs because Apache Pinot does not support Star-Tree Indexes in tables configured for Upserts. The reason is that upsert operations require real-time updates to primary key-based records, whereas Star-Tree Indexes are pre-aggregated and immutable after segment creation, making them incompatible with upsert functionality.
g
yep
you have to decide between upsert and startree index
a
so I have one table and its real time ingestion so definitely star tree wont work on it but what else can I use in indexing my use case has , SUM, count ,AVG function , where clause and group by's so what kind of index I can use for which column?
@Gonzalo Ortiz
g
realtime tables support ST indexes. In realtime tables segments are created in ingestion mode and once the commit criteria is reached (aka number of rows, time, etc) they are committed, which means they are closed (no more changes will be applied to the segment) and then they behave like offline segments, so any index can be created
a
I have upsert in my realtime table so that would not be ideal
g
ok, that is a different situation. If you are using upsert, then you cannot use ST index and AFAIK there is no other optimization to improve aggregate functions (like SUM, COUNT or AVG).
a
ok got it .
I am using json indexes as of now for some of my json queries for some of the data like this
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
    }
] "communityCard": { "maxLevels": 2, "excludeArray": false, "disableCrossArrayUnnest": true, "includePaths": null, "excludePaths": null, "excludeFields": null, "indexPaths": null }, ]. I am not able to understand the MaxLevels here can you explain what does it mean ?
and what would be the maxLevel in this snippet
Copy code
"winnerDetails": [
    {
        "winnerUserId": 12121,
        "winnerUserName": "user12121"
    }
],
g
JSON indexes flatten documents. So internally your document is transformed into something like:
Copy code
winnerDetails.0.winnerUserId=12121
winnerDetails.0.winnerUserId="user12121"
for very deep documents, that means to keep a lot of information in the index, so max depth can be used to only keep a subset of the tree
a
so for this how will I know the max level
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
    }
]
and how will i know which maxLevel I need to keep , I red somewhere someone had maxLevel -1
g
max levels is the max depth you want to keep. How to know the correct value? With experience. If there were an automatic way to decide that we would have tried to infer the value automatically 😆 . As explained, the deepest the document, the more memory the index will use. But at the same time the smaller the value, less useful is the index. Basically if your query needs to go to the 5th level (in the JSON tree) but your index is configured to only keep 3 levels, then the index could not be used. The -1 value is specified in the documentation. It means that no limit will be applied, so the whole document will be indexed. That is the recommended value and unless you find some memory issue (with very large and deep docs), it is not recommended to change it
a
I see what you mean so for this , I can put maxLevel = -1 so this whole json object communityCards will be indexes right ?
"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
}
]
@Gonzalo Ortiz
g
You can also simply not set the maxLevel and it will use the default -1
but yeah, with -1 (either implicit or explicit) the whole document should be indexed
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"}%
{
"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,
"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
}
}
},
"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
}
this is my json config
"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
}
}
@Gonzalo Ortiz