Skip to main content

WHERE <Aggregation_Function>(<table>.<column_name>, <start>, <end>) <comparison_operator> <constant> (Optional)

Description

The WHERE clause filters data before running predictions, allowing you to exclude irrelevant entities or targets from aggregation. Filters can be static (based on direct column values) or temporal (using aggregations over time).

Static Filters

A static filter does not involve aggregations and applies direct conditions to table columns.

Example 1: Basic Static Filter

PQL

Example 2: Using a Static Filter in an Aggregation

PQL

Example 3: One-Hop Filters (Connected Tables) (num_neighbors)

PQL
Note: A unique foreign key must link user to region to ensure each user belongs to a single region.

Example 4: Combining Multiple Filters

PQL

Temporal Filters

Temporal filters apply conditions based on past activity within a specified time window.

Example 5: Temporal Filter Usage

PQL

Inline and Nested WHERE Filters

Using WHERE Within an Aggregation

PQL

Nested Temporal Filters

PQL

Multiple Target Tables

Example 6: Multiple Targets

PQL
Invalid Example (Mixing Static & Temporal)
PQL

Filtering by Specific Date/Time

PQL

Modifying Filters for Batch Prediction

Example 7: Changing Entity Filters

PQL

Modifying Target Filters at Batch Prediction Time

Example 8: Adjusting Target Conditions

PQL
PQL

Summary

  • WHERE filters exclude irrelevant entities or targets before aggregation.
  • Static filters apply direct column conditions.
  • Temporal filters use past activity to refine predictions.
  • You can combine multiple filters with AND/OR/NOT.
  • One-hop filters allow filtering based on connected tables (requires a unique foreign key).
  • Batch prediction filters let you modify conditions at inference without retraining, but must align with training distribution.