Analytics context
FeatureQL features are pure functions — they describe what to compute, not where the data lives or which rows to process. Batch analytics is where you connect those features to real data and evaluate them across entire entity populations.
From single-entity to population-scale
In real-time serving, you evaluate features for one entity at a time: "What is the lifetime value of customer 42?" Batch analytics flips this: "What is the lifetime value of every customer who was active last month?"
The building blocks for this are:
EXTERNAL_COLUMNS()andEXTERNAL_SQL()— connect features to columns in your data warehouse tables@BIND_KEYSET()— define which entity keys to evaluate, often filtered by date or business criteriaGROUP BYandUNNEST()— aggregate results or flatten nested structures for reporting- Window functions — compute running totals, rankings, and row-level analytics with
OVER()clauses - Hybrid queries — embed FeatureQL inside SQL (or vice versa) for seamless integration with existing tools
Query structure
A batch analytics query follows this general shape:
WITH
<feature definitions>
SELECT
<features to compute>
FOR
<bind entity keys>
WHERE <filter>
GROUP BY <aggregate>
ORDER BY <sort>
LIMIT <rows>The WITH and SELECT clauses define features. The FOR clause binds entity keys — this is what makes the query evaluate across a population rather than a single entity. The remaining clauses (WHERE, GROUP BY, ORDER BY, LIMIT) shape the output.
Analytics clauses (WHERE, GROUP BY, ORDER BY, LIMIT) work only in evaluation queries, not in CREATE FEATURES statements. Feature definitions are always pure; filtering and sorting happen at query time.
What's in this section
Each page covers one piece of the batch analytics workflow:
| Page | What it covers |
|---|---|
| External Columns | Mapping features to table columns with EXTERNAL_COLUMNS() |
| Bind Keyset | Defining entity populations with @BIND_KEYSET() for offline evaluation |
| Grouping & Unnesting | Aggregating with GROUP BY and flattening arrays with UNNEST() |
| Window Functions | Running totals, rankings, and row-level analytics with OVER() |
| Hybrid Queries | Embedding FeatureQL inside SQL for BI tools and existing workflows |