Hi folks quick question about upsert, If the upser...
# troubleshooting
s
Hi folks quick question about upsert, If the upsert works, will the total docs decrease according to the amount of rows upserted? for instance there are 30 docs total, but 10 of them has the same PK, does it shows 20 total docs or 30?
m
Docs don't decrease per se. The don't increase if you upsert an existing row. For example, if you had 1 row, and you kept upserting the same row 100 times, you will still see 1 row
s
aa I see, thanks sir
So I put this as the table.json and the upsert doesn't work. can u help me with it?
Copy code
{
  "tableName": "topic name",
  "tableType": "REALTIME",
  "segmentsConfig": {
    "schemaName": "topic name",
    "timeColumnName": "datestamp",
    "retentionTimeUnit": "DAYS",
    "retentionTimeValue": "1",
    "segmentPushType": "APPEND",
    "segmentAssignmentStrategy": "BalanceNumSegmentAssignmentStrategy",
    "replicasPerPartition": "1",
    "minimizeDataMovement": false
  },
  "tenants": {
    "broker": "DefaultTenant",
    "server": "DefaultTenant"
  },
  "routing": {
    "instanceSelectorType": "strictReplicaGroup"
  },
  "tableIndexConfig": {
    "streamConfigs": {
      "streamType": "kafka",
      "stream.kafka.consumer.type": "lowlevel",
      "stream.kafka.topic.name": "topic name",
      "stream.kafka.decoder.class.name": "org.apache.pinot.plugin.stream.kafka.KafkaJSONMessageDecoder",
      "stream.kafka.consumer.factory.class.name": "org.apache.pinot.plugin.stream.kafka20.KafkaConsumerFactory",
      "stream.kafka.broker.list": "broker list",
      "realtime.segment.flush.threshold.rows": "0",
      "realtime.segment.flush.threshold.time": "24h",
      "realtime.segment.flush.threshold.segment.size": "50M",
      "stream.kafka.consumer.prop.auto.offset.reset": "smallest"
    },
    "invertedIndexColumns": [
      "c_project_id"
    ],
    "aggregateMetrics": false,
    "enableDefaultStarTree": false,
    "nullHandlingEnabled": false,
    "rangeIndexVersion": 2,
    "optimizeDictionaryForMetrics": false,
    "optimizeDictionary": false,
    "loadMode": "MMAP",
    "enableDynamicStarTreeCreation": false,
    "columnMajorSegmentBuilderEnabled": true,
    "noDictionarySizeRatioThreshold": 0.85,
    "autoGeneratedInvertedIndex": false,
    "createInvertedIndexDuringSegmentGeneration": false
  },
  "metadata": {
    "customConfigs": {}
  },
  "upsertConfig": {
    "mode": "FULL",
    "enableSnapshot": true,
    "enablePreload": true
  },
  "ingestionConfig": {
    "transformConfigs": [
      {
        "columnName": "c_project_id",
        "transformFunction": "JSONPATHLONG(message, '$.c_project_id')"
      }
    ]
  }
}
This is my Schema
Copy code
{
  "schemaName": "cpats_stocks",
  "primaryKeyColumns":["c_project_id],
  "dimensionFieldSpecs": [
  {
    "name": "c_project_id",
    "dataType": "LONG",
    "notNull": false
  },
  {
    "name": "z_id",
    "dataType": "LONG",
    "notNull": false
  },
  {
    "name": "datecreated",
    "dataType": "STRING",
    "notNull": false
  }
],
"metricFieldSpecs": [ 
  {
    "name": "z_qty_total",
    "dataType": "LONG",
    "notNull": false
  },
  {
    "name": "tracking_day",
    "dataType": "LONG",
    "notNull": false
  },
  {
    "name": "z_age",
    "dataType": "LONG",
    "notNull": false
  }
],
"dateTimeFieldSpecs": [
  {
    "name": "z_in_date_actual",
    "dataType": "TIMESTAMP",
    "format": "SIMPLE_DATE_FORMAT|yyyy-MM-dd",
    "granularity": "1:DAYS"
  },
  {
    "name": "datestamp",
    "dataType": "TIMESTAMP",
    "format": "SIMPLE_DATE_FORMAT|yyyy-MM-dd",
    "granularity": "1:DAYS"
  }
]
}