> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/sdgm/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/sdgm/_mcp/server.

# Filters and Operators

> Use entity selection, context filters, anchor times, and assumptions in Kumo Relational

PQL separates the entities to score from the historical context used to form a prediction.

* `FOR` and the `indices` parameter select the entities for which to generate predictions.
* `WHERE` filters the historical context.
* `ASSUMING` conditions the prediction on a hypothetical attribute value.

## Select entities

Specify an explicit ID or list of IDs in the query:

```sql
PREDICT COUNT(orders.*, 0, 30, days) > 0
FOR customers.customer_id IN (42, 57, 81)
```

For a programmatically generated list, pass the IDs through the `indices` parameter of `predict()`:

```python
from kumo_relational_client import RelationalClient

with RelationalClient(url="http://localhost:8000") as client:
    result = client.relational(graph).predict(
        "PREDICT COUNT(orders.*, 0, 30, days) > 0 "
        "FOR EACH customers.customer_id",
        indices=[42, 57, 81],
    )
```

The `indices` parameter overrides IDs embedded in the query. A single inference call accepts at most 1,000 IDs.

## Filter historical context

Temporal filters restrict the prior events used as context without changing the entity list:

```sql
PREDICT COUNT(orders.*, 0, 30, days) > 0
FOR customers.customer_id=42
WHERE COUNT(orders.*, -30, 0, days) > 0
```

The `WHERE` clause retains historical context with at least one order during the 30 days before the anchor time.

Current Kumo Relational static column filters are limited to columns in the same table. Joined static filters described by broader PQL grammars are not supported by the current Kumo Relational validator.

```sql
PREDICT customers.segment
FOR customers.customer_id=42
WHERE customers.region = "North America"
```

## Combine conditions

Use `AND`, `OR`, and `NOT` with type-compatible expressions:

```sql
PREDICT SUM(orders.amount, 0, 30, days) > 100
    OR COUNT(orders.*, 0, 30, days) > 10
FOR customers.customer_id=42
WHERE COUNT(orders.*, -90, 0, days) > 0
```

Start with one condition, and add other conditions only after the base query succeeds.

## Set the anchor time

The anchor time defines “now” for temporal windows. Pass time controls directly to `predict()`:

```python
import pandas as pd
from kumo_relational_client import RelationalClient

with RelationalClient(url="http://localhost:8000") as client:
    result = client.relational(graph).predict(
        query,
        indices=[42, 57, 81],
        run_mode="fast",
        anchor_time=pd.Timestamp("2025-01-01T00:00:00Z"),
    )
```

An explicit historical anchor time is useful for backtesting. Ensure that both features and labels comply with the time boundary.

Use `"entity"` when each row in the entity table has its own reference timestamp:

```python
result = model.predict(query, anchor_time="entity")
```

Here, `model` is the graph-bound handle returned by `client.relational(graph)`.

You can specify separate anchors for prediction and context:

```python
result = model.predict(
    query,
    anchor_time=pd.Timestamp("2025-06-01T00:00:00Z"),
    context_anchor_time=pd.Timestamp("2025-03-01T00:00:00Z"),
)
```

Verify that the deployed SDK and NIM versions support the optional inference controls.

## Condition with ASSUMING

```sql
PREDICT COUNT(orders.*, 0, 90, days) = 0
FOR customers.customer_id=42
ASSUMING customers.plan = "premium"
```

`ASSUMING` conditions the prediction on in-context examples that have the specified value. It does not estimate a causal treatment effect and must not be interpreted as proof that changing the attribute will cause the predicted outcome.

Use an assumed state only when it has adequate historical representation. Check the stability of the results across related cohorts, protect sensitive attributes, and do not use an assumed association as the sole basis for a high-stakes decision.

See the [`WHERE`](#where) and [`ASSUMING`](#assuming) sections for syntax details.