Share

Fetch the Primary Keys of an Event

Definition: getPrimaryKeyFields() → List[str]
Description: Retrieves the primary keys from an Event.
Parameters: This method does not take any arguments.
Returns: An array of strings containing the primary key for the Event.

The following script fetches the list of properties that are primary keys in the Event:

from io.hevo.api import Event

def transform(event):

    # Fetches the current set of primary keys for a given record
    <existing_primary_keys> = event.getPrimaryKeyFields()

    return event

Sample Transformation

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

  1. Retrieves the primary key for the Event.

  2. Adds it to the Event as a property called existing_pk_fields.

from io.hevo.api import Event

def transform(event):

    # Fetches the current set of primary keys for a given record
    pk_fields = event.getPrimaryKeyFields()

    properties = event.getProperties()
    properties['existing_pk_fields'] = pk_fields

    return event

Sample Output

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

Get Primary Key Fields


Last updated on May 30, 2023

Tell us what went wrong

Skip to the section