SELECT statements
SELECT statements are used to transform data in Cloudflare Pipelines. The general form is:
[WITH with_query [, ...]]SELECT select_expr [, ...]FROM from_item[WHERE condition]The WITH clause allows you to define named subqueries that can be referenced in the main query. This can improve query readability by breaking down complex transformations.
Syntax:
WITH query_name AS (subquery) [, ...]Simple example:
WITH filtered_events AS    (SELECT user_id, event_type, amount        FROM user_events WHERE amount > 50)SELECT user_id, amount * 1.1 as amount_with_taxFROM filtered_eventsWHERE event_type = 'purchase';The SELECT clause is a comma-separated list of expressions, with optional aliases. Column names must be unique.
SELECT select_expr [, ...]Examples:
-- Select specific columnsSELECT user_id, event_type, amount FROM events
-- Use expressions and aliasesSELECT    user_id,    amount * 1.1 as amount_with_tax,    UPPER(event_type) as event_type_upperFROM events
-- Select all columnsSELECT * FROM eventsThe FROM clause specifies the data source for the query. It will be either a table name or subquery. The table name can be either a stream name or a table created in the WITH clause.
FROM from_itemTables can be given aliases:
SELECT e.user_id, e.amountFROM user_events eWHERE e.event_type = 'purchase'The WHERE clause filters data using boolean conditions. Predicates are applied to input rows.
WHERE conditionExamples:
-- Filter by field valueSELECT * FROM events WHERE event_type = 'purchase'
-- Multiple conditionsSELECT * FROM eventsWHERE event_type = 'purchase' AND amount > 50
-- String operationsSELECT * FROM eventsWHERE user_id LIKE 'user_%'
-- Null checksSELECT * FROM eventsWHERE description IS NOT NULLThe UNNEST operator converts arrays into multiple rows. This is useful for processing list data types.
UNNEST restrictions:
- May only appear in the SELECT clause
 - Only one array may be unnested per SELECT statement
 
Example:
SELECT    UNNEST([1, 2, 3]) as numbersFROM events;This will produce:
+---------+| numbers |+---------+|       1 ||       2 ||       3 |+---------+Was this helpful?
- Resources
 - API
 - New to Cloudflare?
 - Directory
 - Sponsorships
 - Open Source
 
- Support
 - Help Center
 - System Status
 - Compliance
 - GDPR
 
- Company
 - cloudflare.com
 - Our team
 - Careers
 
- © 2025 Cloudflare, Inc.
 - Privacy Policy
 - Terms of Use
 - Report Security Issues
 - Trademark