Skip to content

SQL Segment Extensions

You can generate a Segment Extension using Snowflake SQL queries of Snowflake data. SQL can help you unlock new segment use cases because it offers the flexibility to describe the relationships between data in ways that aren’t achievable through other segmentation features.

Creating Segment Extensions using SQL

To create a Segment Extension using SQL:

  1. Go to Segments > Segment Extensions.
  2. Click Create New Extension and select SQL Editor.

    Dropdown button on the Segment Extension page to open the SQL editor.

  3. Add a name for your Segment Extension and input your SQL. See the following sections for requirements and resources.

    SQL editor showing an example SQL Segment Extension.

  4. Save your Segment Extension.

When the extension finishes processing, you can create a segment using your Segment Extension and target this new segment with your campaigns and Canvases.

Writing SQL

Your SQL query should be written using Snowflake syntax. Consult the table reference for a full list of tables and columns available to be queried.

Your SQL must additionally adhere to the following rules:

  • Write a single SQL statement. Do not include any semicolons.
  • Your SQL must select only one column: the user_id column. This means your SQL must contain:
1
SELECT DISTINCT user_id FROM "INSERT TABLE NAME"

Previewing results

Before saving, you can run a preview of your query. Query previews are automatically limited to 100 rows and will timeout after 60 seconds. The user_id column requirement does not apply when running a preview.

Managing SQL Segment Extensions

On the Segment Extensions page, segments generated using SQL are denoted with next to their name.

Select a SQL Segment Extension to view where the extension is being used, archive the extension, or manually refresh the segment membership.

Messaging Use section of the SQL Editor showing where the SQL segment is being used.

Refreshing segment membership

To refresh the segment membership of any Segment Extension created using SQL, open the Segment Extension and select Refresh. Currently SQL Segment Extensions do not automatically regenerate.

Troubleshooting

Your query may fail for any of the following reasons:

  • Syntax errors in your SQL query
  • SQL does not adhere to the SQL rules
  • Processing timeout (after 20 minutes)
WAS THIS PAGE HELPFUL?
New Stuff!