Create an Event

Last updated on Jun 30, 2023
Definition: Event(eventname: str, properties: Dict[str, Any]) → Event
Description: Constructs a new Event. If you want to retain the original Event, you should include it in the return statement of the transform method.
Parameters: - eventname: The name of the Event.
- properties: The properties of the Event in a Python dict format.
Returns: The newly created Event.
Note: The new Event is available for further use only if it is returned by the transform method.

The following script creates a new Event and returns it as the transformed Event:

from io.hevo.api import Event

def transform(event):

    # Get properties from the Event #
    properties = event.getProperties()

    <newEvent> = Event('<new Event Name>', properties)

    return <newEvent>

Note: You cannot set the primary key while creating an an Event Type through Transformations. However, you can use the Schema Mapper page of your Pipeline and set the primary key for that Event Type.

Sample Transformation

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

  1. Creates the subject and marks Events from the Student.Sheet1 Event.

  2. Includes only the new Events in the return statement of the transform method. As a result, the original Event,Student.Sheet1 is dropped.

from io.hevo.api import Event

def transform(event):

    # Get properties from the Event #
    properties = event.getProperties()

    # Create two events 'subject' and 'marks' from the original Event
    subject = Event('subject', properties)
    marks = Event('marks', properties)

    # return an array of new Events
    return [subject, marks]

Sample Output

The Transformation script creates the subject and marks Events with the same properties as the Student.Sheet1 Event.

Create Events



Revision History

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

Date Release Description of Change
Apr-10-2023 NA Updated the page to add a note regarding setting the primary key through the Schema Mapper page.
Feb-14-2023 NA New document.

Tell us what went wrong