Modify the Primary Keys of an Event

Last updated on Feb 13, 2023
Definition: setPrimaryKeyFields([fieldnames]: List[str]) → None
Description: Sets the specified fields as the new primary keys for the Event.
Parameters: fieldnames: The list of fields to be set as primary keys for the Event.
Returns: No return value, which is indicated by None.

The following script sets the primary key of the Event:

from io.hevo.api import Event

def transform(event):


    return event

Sample Transformation

The script below demonstrates how this method can be used. It:

  1. Sets the primary keys of the Event to a composite key comprising the ID and Student Name fields.

  2. Retrieves the new primary keys.

  3. Adds the new_pk_fields property to the Event.

from io.hevo.api import Event

def transform(event):

    # Set a field (or a list of fields) as the primary key
    event.setPrimaryKeyFields(['ID', 'Student Name'])

    properties = event.getProperties()
    properties['new_pk_fields'] = event.getPrimaryKeyFields()

    return event

Sample Output

The Transformation adds the list of primary key fields for the Event as a new property called new_pk_fields.

Set Primary Key Fields

Revision History

Refer to the following table for the list of key updates made to this page:

Date Release Description of Change
Feb-14-2023 NA New document.

Tell us what went wrong