> ## Documentation Index
> Fetch the complete documentation index at: https://moengage-partner-guide.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Databricks

[Databricks](https://www.databricks.com/resources/ebook/maximize-your-organizations-potential-data-and-ai?scid=7018Y000001Fi1AQAS\&utm_medium=paid+search\&utm_source=google\&utm_campaign=15418435374\&utm_adgroup=130717555576\&utm_content=ebook\&utm_offer=maximize-your-organizations-potential-data-and-ai\&utm_ad=703594935116\&utm_term=databricks\&gad_source=1\&gclid=CjwKCAjwvr--BhB5EiwAd5YbXpGh4ugWZyyOwJrqbfr-c5cZhP9HVrGMKQmBuZRlVcC_BRLco-zKVxoCmZkQAvD_BwE) is a platform that allows organizations to store, analyze, and process large volumes of structured and semi-structured data in a highly scalable and efficient manner. With its unique architecture, Databricks allows organizations to consolidate their data, perform quick analytics, and gain valuable data-driven insights accessible to all users.

# MoEngage × Databricks

The MoEngage × Databricks integration allows you to set up a direct connection between your Databricks instance and MoEngage app to sync data regularly. You can define a schedule to run the sync periodically; periodic syncs can be frequent or with a time interval, such as once every month. During synchronization, MoEngage will directly connect to your data warehouse instance, retrieve all new data from the specified table or the table you have access to, and update the corresponding data on your MoEngage dashboard.

## Use Cases

Databricks integration with MoEngage helps you with the following use cases:

* Sync real-time audiences from Databricks
* Import users and events from Databricks
* Export campaign interaction events to Databricks

## Advantages

The integration with MoEngage helps you with the following advantages:

### Reduce Integration Time

* No more searching for the right ETL (Extract, Transform, and Load) tool, as MoEngage directly integrates with Databricks.
* Long and complicated ETL pipelines are now replaced with a one-time integration setup that gives MoEngage direct access to your data.
* This decreases the dependency on tech teams significantly.

### Faster Data Processing

* The power of the Databricks infrastructure enables us to store, process, and query massive amounts of data in near real-time.
* Any changes in the original schema are propagated immediately without having to change any configuration on MoEngage’s end, which is a significant advantage over the traditional ETL pipelines.
* Since there is no need for ETL tools and external cloud providers, the cost of import is significantly lower than traditional data pipelines.

# Integration

<Info>
  **Prerequisites**

  Ensure you have a Databricks account with permission to create new users, schemas, or tables.
</Info>

## Step 1: Grant Permissions to MoEngage

<Tabs>
  <Tab title="Audience Sync and Imports">
    To run queries on data from Databricks or Import data into MoEngage, you must connect to your Databricks warehouse. Ensure you have administrative privileges on the Databricks platform and that your PAT does not expire. Steps to grant read access to MoEnagage:

    * Add a service principal in Databricks
    * Assign a service principal to Databricks workspace
    * Provide data reader access to the service principal
    * Provide compute permissions on SQL warehouses to service principal
    * Create a personal access token (PAT)
    * Fetch the HTTP path and Hostname
    * Share details with MoEngage

    **Add a Service Principal in Databricks**

    Account admins can add service principals to the Databricks account using the account console. For more information, refer here.

    Perform the following steps to add a service principal:

    1. Log in to your account console in Databricks as an admin.
    2. In the sidebar, click User Management.
    3. On the Service principals tab, click Add Service principal.
    4. Enter a name for the service principal.
    5. Click Add.

    **Assign a Service Principal to Databricks Workspace**

    An admin can assign a service principal to a workspace using the account console. For more information, refer here.

    Perform the following steps to assign permissions:

    1. Log in to your account console in Databricks as an admin.
    2. In the sidebar, click Workspaces.
    3. Click your workspace name.
    4. On the Permissions tab, click Add permissions.
    5. Search for and select the service principal, and assign the permission level (Workspace User). You can assign the workspace admin role on the workspace admin settings page.
    6. Click Save.

    **Provide Data Reader Access to the Service Principal**

    Provide data reader access, as shown below, to the entire workspace or individual schemas to the service principal, ensuring that the tables you want to query in MoEngage are available in the schema:

    1. Go to your Databricks Dashboard Catalog.
    2. Select your desired Catalog.
    3. On the Permissions tab, click Add permissions.
    4. Click on "Grant" and select the following permissions:

           <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_35794662935444.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=0721eaf2f44f9c3c84eb7e47b322184f" alt="Screenshot 2025-02-25 at 5.37.34 PM.png" width="1754" height="1418" data-path="images/partner_35794662935444.png" />

    **Provide Permissions to the Service Principal to Compute on SQL Warehouses**

    Perform the following steps to provide compute permissions:

    1. In the Databricks dashboard, Click Settings Compute SQL warehouses.
    2. Select the warehouse that needs to be accessed by the service principal.
    3. Click Permissions. In the list, select Can use for the service principal.

           <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_35794647019796.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=522d483e662a2c40fc8094604281eda6" alt="" width="978" height="360" data-path="images/partner_35794647019796.png" />

    **Create a Personal Access Token (PAT)**

    You can create a PAT for a service principal using Databricks CLI. For more information, refer [here](https://docs.databricks.com/aws/en/dev-tools/auth/pat#databricks-personal-access-tokens-for-service-principals).
  </Tab>

  <Tab title="Exports">
    To export data from MoEngage to Databricks, you must connect MoEngage to your Databricks warehouse. Ensure you have administrative privileges on the Databricks platform and that your PAT has no expiry. Steps to grant write access to MoEnagage:

    * Add a service principal in Databricks
    * Assign a service principal to Databricks workspace
    * Provide Write Access to the Service Principal
    * Provide compute permissions on SQL warehouses to service principal
    * Create a personal access token (PAT)
    * Fetch the HTTP path and Hostname
    * Share details with MoEngage

    **Add a Service Principal in Databricks**

    Account admins can add service principals to the Databricks account using the account console. For more information, refer here.

    Perform the following steps to add a service principal:

    1. Log in to your account console in Databricks as an admin.
    2. In the sidebar, click User Management.
    3. On the Service principals tab, click Add Service principal.
    4. Enter a name for the service principal.
    5. Click Add.

    **Assign a Service Principal to Databricks Workspace**

    An admin can assign a service principal to a workspace using the account console. For more information, refer here.

    Perform the following steps to assign permissions:

    1. Log in to your account console in Databricks as an admin.
    2. In the sidebar, click Workspaces.
    3. Click your workspace name.
    4. On the Permissions tab, click Add permissions.
    5. Search for and select the service principal, and assign the permission level (Workspace User). You can assign the workspace admin role on the workspace admin settings page.
    6. Click Save.

    **Provide Write Access to the Service Principal**

    Provide Writer Access, as shown below, to the entire workspace or individual schemas to the service principal, ensuring that MoEngage has sufficient permissions to create tables and write data into them:

    1. Go to your Databricks Dashboard Catalog.
    2. Select your desired Catalog.
    3. On the Permissions tab, click Add permissions.
    4. Click on "Grant" and select the following permissions:

           <img src="https://mintcdn.com/moengage-partner-guide/pRJtSUVtTOyaJazb/images/partner_37121905945748.png?fit=max&auto=format&n=pRJtSUVtTOyaJazb&q=85&s=d3c8bd784a4db348362daed218e96330" alt="" width="1752" height="1398" data-path="images/partner_37121905945748.png" />

    **Provide Permissions to the Service Principal to Compute on SQL Warehouses**

    Perform the following steps to provide compute permissions:

    1. In the Databricks dashboard, Click Settings Compute SQL warehouses.
    2. Select the warehouse that needs to be accessed by the service principal.
    3. Click Permissions. In the list, select Can use for the service principal.

           <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_35794647019796.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=522d483e662a2c40fc8094604281eda6" alt="" width="978" height="360" data-path="images/partner_35794647019796.png" />

    **Create a Personal Access Token (PAT)**

    You can create a PAT for a service principal using Databricks CLI. For more information, refer [here](https://docs.databricks.com/aws/en/dev-tools/auth/pat#databricks-personal-access-tokens-for-service-principals).
  </Tab>
</Tabs>

<Accordion title="Create a PAT for a user (optional)">
  You can also create a user, assign appropriate access to the user, and allow MoEngage to access your warehouse from that user’s role. However, Databricks recommends the service principal approach. If you want to create a personal access token for a user, please follow the steps below. Alternatively, you can follow the steps mentioned here (From 6 through 12).

  1. In your Databricks workspace, select your Databricks username in the title bar, and then select **Settings** from the list.
  2. On the **Access Tokens** tab, select **Generate New Token.**
  3. Enter a comment to identify this token, and change the token’s lifetime to no lifetime by leaving the Lifetime box empty.
  4. Click **Generate** and copy the generated token.
  5. Click **Done**.

  <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_35794647020308.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=52a7122733ec68002ee49a547bd8cf3e" alt="Screenshot 2025-02-25 at 6.03.21 PM.png" width="2880" height="1570" data-path="images/partner_35794647020308.png" />
</Accordion>

## Step 2: Obtain Databricks Credentials for App Marketplace Integration

To obtain Databricks credentials for the App marketplace, perform the following steps:

1. Login to your Databricks account.
2. On the left navigation menu, click the **SQL Warehouses** tab.
3. Click **Serverless Starter Warehouse**. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367580709652.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=04bff2152a48ff3a3698fdd9fd9485ce" width="2620" height="1340" data-path="images/partner_36367580709652.png" />
4. On the **Serverless Starter Warehouse** page, click the **Connection details** tab. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367580712212.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=704f1e32e58582c6e03419e66771b6ff" width="2618" height="1338" data-path="images/partner_36367580712212.png" />
5. Copy the **Server hostname** and **HTTP path** credentials to paste into the MoEngage App marketplace. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367580713108.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=f2996da05409d7e36dac76563bf5ef79" width="2626" height="1332" data-path="images/partner_36367580713108.png" />
   <Info>
     To create a generated access token, you can also follow the steps mentioned in the **Create a Personal Access Token (PAT)** section.
   </Info>
6. Click **Create a personal access token** at the upper-right corner. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367541202068.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=49e96c34fa17342f969b82c2059edf38" width="2628" height="1340" data-path="images/partner_36367541202068.png" />
7. On the Access tokens page, click **Generate new token**. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367580715668.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=53d4ecc7d0cf6eac3310feda9800aa67" width="2614" height="1336" data-path="images/partner_36367580715668.png" />
8. On the **Generate new token** pop-up window:
   1. In the **Comment** box, type the token name.
   2. In the **Lifetime** box, type the token's lifespan.
   3. Click **Generate**. <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367541204372.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=69b3b98dcf08e48e75e2d322122362e6" width="1154" height="786" data-path="images/partner_36367541204372.png" /> Your token is now generated successfully.
9. Copy the token to paste into the MoEngage App marketplace.
10. Click **Done**. <img src="https://mintcdn.com/moengage-partner-guide/pRJtSUVtTOyaJazb/images/partner_36645238283540.png?fit=max&auto=format&n=pRJtSUVtTOyaJazb&q=85&s=c6a81587af2337309557404bab332843" width="1082" height="516" data-path="images/partner_36645238283540.png" /> <img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367580721812.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=562f169f72fc0af0806a8fbc1ce4f623" width="2632" height="1346" data-path="images/partner_36367580721812.png" /> The generated token is available on the **Access tokens** page.
    <Info>
      The generated token is only visible once.
    </Info>

## Step 3: Connect Databricks on the App Marketplace

To connect Databricks on the App marketplace, perform the following steps:

1. On the left navigation menu in the MoEngage dashboard, click **App marketplace**.
2. On the App Marketplace page, search for **Databricks**.

<img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_36367541210132.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=ba237ec46532f2f15f9bf119d9da8a84" alt="" width="2624" height="1346" data-path="images/partner_36367541210132.png" />

3. Click the **Databricks** tile.
4. On the Databricks page, go to the **Integrate** tab and click +**Add Connection**.
5. Enter the following details:

| Field           | Required | Description                                                                                                                                                                                                                                                                                                 |
| --------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Connection name | Yes      | Type a name for the Databricks connection.                                                                                                                                                                                                                                                                  |
| Host name       | Yes      | This refers to the unique identifier assigned to a specific cluster. Type the hostname that you want to connect. To find your server hostname, visit the Databricks web console and locate your cluster. Then, click to reveal **Advanced options** and navigate to the **JDBC/ODBC** tab.                  |
| Port            | Optional | Type the port to which you want to connect your Databricks server. It defaults to 443.                                                                                                                                                                                                                      |
| HTTP path       | Yes      | Type the HTTP path of your compute resource on Databricks. To find your HTTP path, go to your Databricks workspace, locate your warehouse, and then get your HTTP path from the connection details tab.                                                                                                     |
| Access token    | Yes      | This is an authentication token used to access Databricks APIs securely. Type the Access token, which helps you make authorized requests to the Databricks server with the necessary permissions. On your Databricks workspace, go to **Settings** > **Developer** > **Access tokens** > **Manage tokens**. |
| Catalog         | Yes      | Type the Databricks Catalog name to which MoEngage will have access.                                                                                                                                                                                                                                        |

<img src="https://mintcdn.com/moengage-partner-guide/pVAWNiS-GH4F8Mq2/images/partner_35794647020948.png?fit=max&auto=format&n=pVAWNiS-GH4F8Mq2&q=85&s=bf257e6e41fa2039084d14544bc71f21" alt="Databricks connection form" width="1096" height="1168" data-path="images/partner_35794647020948.png" />

6. Click **Connect**. Your Databricks connection is now integrated.

After you have set up a Databricks connection, you can use it to set up various imports and exports in MoEngage.

### Supported Datetime Formats

| Date and Time Format                            | Examples                                                                                                                     |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `"datetime_format": "YYYY-MM-DD"`               | <ul><li>2022-01-22</li></ul>                                                                                                 |
| `"datetime_format": "YYYY/MM/DD"`               | <ul><li>2022/01/22</li></ul>                                                                                                 |
| `"datetime_format": "DD/MM/YYYY"`               | <ul><li>22/01/2022</li></ul>                                                                                                 |
| `"datetime_format": "DD-MM-YYYY"`               | <ul><li>22-01-2022</li></ul>                                                                                                 |
| `"datetime_format": "DD-MM-YYYY hh:mm:ss"`      | <ul><li>31-12-2022 12:10:33</li></ul>                                                                                        |
| `"datetime_format": "DD/MM/YYYY hh:mm:ss"`      | <ul><li>31/12/2022 12:10:33</li></ul>                                                                                        |
| `"datetime_format": "YYYY-MM-DD hh:mm:ss"`      | <ul><li>2019-02-22 17:54:14</li></ul>                                                                                        |
| `"datetime_format": "YYYY/MM/DD hh:mm:ss"`      | <ul><li>2019/02/22 17:54:14</li></ul>                                                                                        |
| `"datetime_format": "DD-MM-YYYYThh:mm:ss.s"`    | <ul><li>31-12-2022T12:10:33.882</li></ul>                                                                                    |
| `"datetime_format": "DD/MM/YYYYThh:mm:ss.s"`    | <ul><li>31/12/2022T12:10:33.882</li></ul>                                                                                    |
| `"datetime_format": "DD-MM-YYYYThh:mm:ssTZD"`   | <ul><li>31-12-2022T12:10:33Z</li><li>31-12-2022T12:10:33+08:00</li><li>31-12-2022T12:10:33-08:00</li></ul>                   |
| `"datetime_format": "DD/MM/YYYYThh:mm:ssTZD"`   | <ul><li>31/12/2022T12:10:33Z</li><li>31/12/2022T12:10:33+08:00</li><li>31/12/2022T12:10:33-08:00</li></ul>                   |
| `"datetime_format": "YYYY-MM-DD hh:mm:ss.s"`    | 2019-02-22 17:54:14.933                                                                                                      |
| `"datetime_format": "YYYY/MM/DD hh:mm:ss.s"`    | 2019/02/22 17:54:14.933                                                                                                      |
| `"datetime_format": "YYYY-MM-DDThh:mm:ssTZD"`   | <ul><li>2019-11-14T00:01:02Z</li><li>2019-11-14T00:01:02+08:00</li><li>2019-11-14T00:01:02Z-08:00</li></ul>                  |
| `"datetime_format": "YYYY/MM/DDThh:mm:ssTZD"`   | <ul><li>2019/11/14T00:01:02Z</li><li>2019/11/14T00:01:02+08:00</li><li>2019/11/14T00:01:02-08:00</li></ul>                   |
| `"datetime_format": "YYYY-MM-DDThh:mm:ss.sTZD"` | <ul><li>2019-02-22T17:54:14.957Z</li><li>2019-02-22T17:54:14.957299-08:00</li><li>2019-02-22T17:54:14.957299+08:00</li></ul> |
| `"datetime_format": "YYYY/MM/DDThh:mm:ss.sTZD"` | <ul><li>2019/02/22T17:54:14.957Z</li><li>2019/02/22T17:54:14.957299-08:00</li><li>2019/02/22T17:54:14.957299+08:00</li></ul> |

## Warehouse Segments Using Databricks

Databricks is available in our Warehouse Segments. For more information, refer to [Warehouse Segments](https://www.moengage.com/docs/user-guide/segment/segment-operations/warehouse-segments).

## Import Users and Events from Databricks into MoEngage

To set up MoEngage × Databricks imports for your account, refer to the [Databricks Imports guide](https://www.moengage.com/docs/user-guide/data/imports/data-warehouses-imports/databricks-imports).

## Export Events from MoEngage to Databricks

You can export events from MoEngage to your Databricks tables. To set up an export, refer to the [Databricks Exports guide](https://www.moengage.com/docs/user-guide/data/exports/events/data-warehouse/databricks-exports).
