---
title: Ingest data from Reddit Ads
description: Learn how to create a managed ingestion pipeline to ingest data from Reddit Ads into Databricks.
canonical_url: https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-pipeline
---

# Ingest data from Reddit Ads

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md). To use it, a workspace admin must turn on **Lakeflow Connect for Reddit Ads** from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md).

Learn how to create a managed ingestion pipeline to ingest data from Reddit Ads into Databricks.

## <a id="requirements" />Requirements

* To create an ingestion pipeline, you must meet the following requirements:

  * Your workspace must be enabled for Unity Catalog.

  * Serverless compute must be enabled for your workspace. See [Serverless compute requirements](https://docs.databricks.com/gcp/en/compute/serverless/index.md#requirements).

  * To create a new connection, you must have `CREATE CONNECTION` privileges on the metastore. See [Manage privileges in Unity Catalog](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/manage-privileges/index.md).

    If the connector supports UI-based pipeline authoring, an admin can create the connection and the pipeline at the same time by completing the steps on this page. However, if the users who create pipelines use API-based pipeline authoring or are non-admin users, an admin must first create the connection in Catalog Explorer. See [Connect to managed ingestion sources](https://docs.databricks.com/gcp/en/connect/managed-ingestion.md).

  * To use an existing connection, you must have `USE CONNECTION` privileges or `ALL PRIVILEGES` on the connection object.

  * You must have `USE CATALOG` privileges on the target catalog.

  * You must have `USE SCHEMA` and `CREATE TABLE` privileges on an existing schema or `CREATE SCHEMA` privileges on the target catalog.

* To ingest from Reddit Ads, you must complete the steps in [Create a Reddit Ads connection](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-connection.md).

## Source schemas

Reddit Ads organizes tables into source schemas (namespaces):

* The `ad_account` entity table lives in the special `default` schema (`source_schema: "default"`). It lists the ad accounts accessible to the authenticated user.
* All account-scoped tables — `campaign`, `ad_group`, `ad`, and all report tables — live under a schema named by the ad account ID (`source_schema: "<ad_account_id>"`).

## <a id="create-an-ingestion-pipeline" />Create an ingestion pipeline

### Databricks UI

1. In the sidebar of the Databricks workspace, click **Data Ingestion**.
2. On the **Add data** page, under **Databricks connectors**, click **Reddit Ads**.
3. On the **Connection** page of the ingestion wizard, select the connection that stores your Reddit Ads access credentials. If you have the `CREATE CONNECTION` privilege on the metastore, you can click **![Plus icon.](https://docs.databricks.com/gcp/en/images/product-icons/PlusIcon.svg) Create connection** to create a new connection with the authentication details in [Create a Reddit Ads connection](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-connection.md).
4. Click **Next**.
5. On the **Ingestion setup** page, enter a unique name for the pipeline.
6. Select a catalog and a schema to write event logs to. If you have `USE CATALOG` and `CREATE SCHEMA` privileges on the catalog, you can click **![Plus icon.](https://docs.databricks.com/gcp/en/images/product-icons/PlusIcon.svg) Create schema** in the drop-down menu to create a new schema.
7. Click **Create pipeline and continue**.
8. On the **Source** page, select the tables to ingest.
9. Click **Save and continue**.
10. On the **Destination** page, select a catalog and a schema to load data into. If you have `USE CATALOG` and `CREATE SCHEMA` privileges on the catalog, you can click **![Plus icon.](https://docs.databricks.com/gcp/en/images/product-icons/PlusIcon.svg) Create schema** in the drop-down menu to create a new schema.
11. Click **Save and continue**.
12. (Optional) On the **Schedules and notifications** page, click **![Plus icon.](https://docs.databricks.com/gcp/en/images/product-icons/PlusIcon.svg) Create schedule**. Set the frequency to refresh the destination tables.
13. (Optional) Click **![Plus icon.](https://docs.databricks.com/gcp/en/images/product-icons/PlusIcon.svg) Add notification** to set email notifications for pipeline operation success or failure, then click **Save and run pipeline**.

### Declarative Automation Bundles

This tab describes how to deploy an ingestion pipeline using Declarative Automation Bundles. Bundles can contain YAML definitions of jobs and tasks, are managed using the Databricks CLI, and can be shared and run in different target workspaces (such as development, staging, and production). For more information, see [What are Declarative Automation Bundles?](https://docs.databricks.com/gcp/en/dev-tools/bundles/index.md).

1. Create a bundle using the Databricks CLI:

   ```bash
   databricks bundle init
   ```

2. Add two new resource files to the bundle:

   * A pipeline definition file (for example, `resources/reddit_ads_pipeline.yml`).
   * A job definition file that controls the frequency of data ingestion (for example, `resources/reddit_ads_job.yml`).

   See [pipeline.ingestion\_definition](https://docs.databricks.com/gcp/en/dev-tools/bundles/resources.md#pipeline-ingestion_definition) and [Examples](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-pipeline.md#examples).

3. Deploy the pipeline using the Databricks CLI:

   ```bash
   databricks bundle deploy
   ```

### Databricks notebook

1. Import the following notebook into your Databricks workspace:

   [Get notebook](https://docs.databricks.com/notebooks/source/saas-cdc/reddit-ads-pipeline.html)

2. Leave cell one as-is.

3. Modify cell two with your pipeline configuration details, depending on your use case. See [Examples](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-pipeline.md#examples).

4. Click **Run all**.

## <a id="examples" />Examples

### Declarative Automation Bundles

The following pipeline definition file ingests all current and future account-scoped tables from one ad account:

```yaml
resources:
  pipelines:
    pipeline_reddit_ads:
      name: <pipeline-name>
      catalog: <destination-catalog>
      target: <destination-schema>
      ingestion_definition:
        connection_name: <connection-name>
        objects:
          - schema:
              source_schema: <ad-account-id>
              destination_catalog: <destination-catalog>
              destination_schema: <destination-schema>
              connector_options:
                reddit_ads_options:
                  sync_start_date: <sync-start-date>
                  lookback_window_days: <lookback-window-days>
```

The following pipeline definition file selects specific tables from an account:

```yaml
resources:
  pipelines:
    pipeline_reddit_ads:
      name: <pipeline-name>
      catalog: <destination-catalog>
      target: <destination-schema>
      ingestion_definition:
        connection_name: <connection-name>
        objects:
          - table:
              source_schema: default
              source_table: ad_account
              destination_catalog: <destination-catalog>
              destination_schema: <destination-schema>
          - table:
              source_schema: <ad-account-id>
              source_table: campaign_report
              destination_catalog: <destination-catalog>
              destination_schema: <destination-schema>
              destination_table: <destination-table>
              connector_options:
                reddit_ads_options:
                  sync_start_date: <sync-start-date>
                  lookback_window_days: <lookback-window-days>
```

The following is an example job definition file:

```yaml
resources:
  jobs:
    reddit_ads_dab_job:
      name: reddit_ads_dab_job
      trigger:
        periodic:
          interval: 1
          unit: DAYS
      email_notifications:
        on_failure:
          - <email-address>
      tasks:
        - task_key: refresh_pipeline
          pipeline_task:
            pipeline_id: ${resources.pipelines.pipeline_reddit_ads.id}
```

### Databricks notebook

The following pipeline specification ingests all current and future account-scoped tables from one ad account. To also ingest the `ad_account` table, add a second object with `"source_schema": "default"`.

```python
pipeline_spec = {
  "name": "<pipeline-name>",
  "ingestion_definition": {
    "connection_name": "<connection-name>",
    "objects": [
      {
        "schema": {
          "source_schema": "<ad-account-id>",
          "destination_catalog": "<destination-catalog>",
          "destination_schema": "<destination-schema>",
          "connector_options": {
            "reddit_ads_options": {
              "sync_start_date": "2024-01-01",
              "lookback_window_days": 30
            }
          }
        }
      }
    ]
  }
}

json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
```

The following pipeline specification selects specific tables from an account:

```python
pipeline_spec = {
  "name": "<pipeline-name>",
  "ingestion_definition": {
    "connection_name": "<connection-name>",
    "objects": [
      {
        "table": {
          "source_schema": "default",
          "source_table": "ad_account",
          "destination_catalog": "<destination-catalog>",
          "destination_schema": "<destination-schema>"
        }
      },
      {
        "table": {
          "source_schema": "<ad-account-id>",
          "source_table": "campaign_report",
          "destination_catalog": "<destination-catalog>",
          "destination_schema": "<destination-schema>",
          "destination_table": "<destination-table>",
          "connector_options": {
            "reddit_ads_options": {
              "sync_start_date": "2024-01-01",
              "lookback_window_days": 30
            }
          }
        }
      }
    ]
  }
}

json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
```

### Custom reports

In addition to the prebuilt tables, you can define a custom report that lets you choose the exact breakdown dimensions and metric fields you want. Set `source_table` to `custom_report` and provide the report definition under `connector_options.reddit_ads_options.custom_report_options`. The `destination_table` name is required for custom reports.

* **`breakdowns`**: The dimensions to group by, for example `CAMPAIGN_ID`, `DATE`, `COUNTRY`. You must include at least one time dimension — `DATE` or `HOUR` — which becomes the table's incremental cursor.
* **`fields`**: The metric fields to select, for example `IMPRESSIONS`, `CLICKS`, `SPEND`.

For supported breakdowns and fields, see [Custom report breakdowns and fields](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-reference.md#custom-report-breakdowns-and-fields).

#### Declarative Automation Bundles

```yaml
resources:
  pipelines:
    pipeline_reddit_ads_custom:
      name: <pipeline-name>
      catalog: <destination-catalog>
      target: <destination-schema>
      ingestion_definition:
        connection_name: <connection-name>
        objects:
          - table:
              source_schema: <ad-account-id>
              source_table: custom_report
              destination_catalog: <destination-catalog>
              destination_schema: <destination-schema>
              destination_table: my_ad_group_custom_report
              connector_options:
                reddit_ads_options:
                  sync_start_date: <sync-start-date>
                  lookback_window_days: 30
                  custom_report_options:
                    breakdowns:
                      - AD_GROUP_ID
                      - DATE
                    fields:
                      - IMPRESSIONS
                      - CLICKS
                      - SPEND
                      - CTR
```

#### Databricks notebook

```python
pipeline_spec = {
  "name": "<pipeline-name>",
  "ingestion_definition": {
    "connection_name": "<connection-name>",
    "objects": [
      {
        "table": {
          "source_schema": "<ad-account-id>",
          "source_table": "custom_report",
          "destination_catalog": "<destination-catalog>",
          "destination_schema": "<destination-schema>",
          "destination_table": "my_ad_group_custom_report",
          "connector_options": {
            "reddit_ads_options": {
              "sync_start_date": "2024-01-01",
              "lookback_window_days": 30,
              "custom_report_options": {
                "breakdowns": ["AD_GROUP_ID", "DATE"],
                "fields": ["IMPRESSIONS", "CLICKS", "SPEND", "CTR"]
              }
            }
          }
        }
      }
    ]
  }
}

json_payload = json.dumps(pipeline_spec, indent=2)
create_pipeline(json_payload)
```

## <a id="common-patterns" />Common patterns

For advanced pipeline configurations, see [Common patterns for managed ingestion pipelines](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/common-patterns.md).

## <a id="next-steps" />Next steps

Start, schedule, and set alerts on your pipeline. See [Common pipeline maintenance tasks](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/pipeline-maintenance.md).

## Additional resources

* [Reddit Ads ingestion connector FAQs](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-faq.md)
* [Reddit Ads connector limitations](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-limits.md)
* [Troubleshoot the Reddit Ads connector](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-troubleshoot.md)
* [Reddit Ads connector reference](https://docs.databricks.com/gcp/en/ingestion/lakeflow-connect/reddit-ads-reference.md)
