Skip to main content

Ingest data from Reddit Ads

Beta

This feature is in Beta. Workspace admins can control access to this feature from the Previews page. See Manage Databricks previews.

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

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.

    • To create a new connection, you must have CREATE CONNECTION privileges on the metastore. See Manage privileges in Unity Catalog.

      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.

    • 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.

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>").

Create an ingestion pipeline

  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. Create connection to create a new connection with the authentication details in Create a Reddit Ads connection.
  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. 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. 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. Create schedule. Set the frequency to refresh the destination tables.
  13. (Optional) Click Plus icon. Add notification to set email notifications for pipeline operation success or failure, then click Save and run pipeline.

Examples

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}

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.

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

Common patterns

For advanced pipeline configurations, see Common patterns for managed ingestion pipelines.

Next steps

Start, schedule, and set alerts on your pipeline. See Common pipeline maintenance tasks.

Additional resources