Metadata Column __hevo_database_name

Last updated on May 30, 2023

__hevo_database_name is a Hevo-specific column added to the Destination table if you are loading data from multiple databases in the same Pipeline. In such cases, this column is useful to identify the database from which a particular row in the Destination originated.

Note: In case of PostgreSQL WAL mode and Oracle Sources , hevo_schema_name is added to identify the schema of the Source database.

This column is added only for the log-based Pipelines, and is based on a combination of the following settings that you define while creating the Pipeline:

  • Load All Databases

  • Merge Tables

For the Pipeline mode as Table, the database or schema name may be prefixed to the table name. Refer to the section below to know how to derive the database or schema name using a transformation script.

The table below is a quick reckoner for the scenarios when the hevo_database_name or hevo_schema_name column is added to the Destination table:

Source Name Pipeline Mode Load All Databases Merge Tables hevo_database_name added? hevo_schema_name added? Table Name
MySQL Binlog True False No No databasename_tablename
MySQL Binlog False False No No databasename.tablename
MySQL Binlog True True Yes No databasename.tablename
MySQL Binlog False True Yes No NA
MySQL Table NA NA No No databasename.tablename
Oracle Redo Log False: load all schema True No Yes NA
Oracle Redo Log False: load all schema False No No schemaname.tablename
Oracle Redo Log True: load all schema False No No schemaname.tablename
Oracle Redo Log True: load all schema True No Yes NA
Oracle Table NA NA No No schemaname.tablename
PostgreSQL WAL NA True No Yes NA
PostgreSQL WAL NA False No No tablename
PostgreSQL Table NA False No No tablename
MongoDB Change stream True True Yes No NA
MongoDB Change stream True False No No databasename.tablename
MongoDB Change stream False True Yes No NA
MongoDB Change stream False False No No databasename.tablename
MongoDB Op Log True True Yes No NA
MongoDB Op Log False True Yes No NA
MongoDB Op Log False False No No databasename.tablename
SQL Server Table NA NA No No schemaname.tablename

Deriving the Database or Schema Name

You can derive the database and/or schema name by using the following transformation script, as follows:

Script to derive the database name

FROM io.hevo.api import event
def transform(event):

  # Get properties FROM the event
  eventname = event.geteventname()
  properties = event.getproperties()
  res = eventname.rsplit('.', 1)
  # ADD a NEW field TO the event
  properties['database_name'] =res[0]

  return event

Sample output:

{
	"event_name": "leads.country",
	"properties": {
		"_id": "55a0f1d420a4d760b5fbefef",
		"Country Name": "Cocos Islands",
		"Language": "fil",
		"Database_name": "leads"
	}
}

Script to derive the schema name

from io.hevo.api import Event

def transform(event):
   # Get properties from the event
    eventName = event.getEventName()
    properties = event.getProperties()
    res = eventName.rsplit('.', 1)
    # Add a new field to the event
    properties['Schema_name'] =res[0]

    return event

Sample output:

{
	"event_name": "leads.country",
	"properties": {
		"_id": "55a0f1d420a4d760b5fc08cf",
		"Country Name": "France",
		"Language": "fr",
		"Schema_name": "leads"
	}
}


Revision History

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

Date Release Description of Change
Feb-07-2022 1.81 Updated the page to reflect support for __hevo_database_name and __hevo_schema_name columns for table-based and custom SQL-based Pipelines.

Tell us what went wrong