Share

How do I change the data type of a Destination table column?

You can change the data type of a Destination table column while ingesting data from the Source either through Transformations or the Schema Mapper. You can only change the data type to one with a broader definition. For example, you can change int to float or varchar, but you cannot change varchar to any other type.

Changing the data type of a field that is a primary key can lead to data mismatch in the Destination table. Therefore, all Events having that field are sidelined. If you want to replay or successfully reload those Events, you must undo the changes and replay the Events.

Through Transformations:

In Hevo, you can design and apply the Format Number to String and Format Date to String Transformations on Events and Event Types through Drag-and-Drop or the Python script option.

Examples:

  • Let us assume that the data type int from the Source is mapped to the Destination data type int, and you want to change the Destination data type to string. You can do this using the Format Number to String transformation.

    setting-up-filters

    number-to-string

  • The following Python script converts the data type of nested_field to string using the following commands:

    def transform(event):
    
        properties = event.getProperties()
        properties['nested_field'] = str(properties['nested_field'])
    
        return event
    

Through the Schema Mapper:

  1. Disable Auto Mapping and select Drop Table from the Kebab menu next to the Destination table name.

    drop-table

  2. Click Create Table and Map.

    create-table-&-map

  3. Modify the data types for the fields as required.

    manual-mapping

Read Handling Different Data Types in Source Data for more information.

Last updated on May 30, 2023

Tell us what went wrong

Skip to the section