code: func (t *partitionedTable) locatePartition(ctx sessionctx.Context, pi *model.PartitionInfo, r []types.Datum) (int64, error) {
  	var err error
  	var idx int
  	switch t.meta.Partition.Type {
  	case model.PartitionTypeRange:
  		idx, err = t.locateRangePartition(ctx, pi, r)
  	case model.PartitionTypeHash:
  		idx, err = t.locateHashPartition(ctx, pi, r)
  	}
  	if err != nil {
  		return 0, errors.Trace(err)
  	}
  	return pi.Definitions[idx].ID, nil
  }
docs: // locatePartition returns the partition ID of the input record.