> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blockdb.chaintable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Filters & operators

> Build condition expressions with Column / filter, and filter + deduplicate preprocessing pipelines with Operator.

# Filters & operators

The SDK provides two expression wrappers: `Column` builds column conditions with Python operators, and `Operator` builds chained filter and dedup preprocessing pipelines. Both serialize to JSON, consumed by the server or by BlockX before your function runs.

## Column expressions

`Column(name)` represents a column and supports comparison, logical, and set operations, returning a condition expression:

```python theme={null}
from blockdb import Column

col = Column("value")

# Comparison
col > 0
col == "Transfer"

# Logical combination
(col > 0) & (col < 100)
(Column("name") == "Transfer") | (Column("name") == "Deposit")

# Sets
Column("tx_id").in_(["0x...", "0x..."])
Column("addr").not_in(["0x..."])
```

## Serializing with filter

`filter(expr)` serializes a Column expression into a condition JSON string for downstream use:

```python theme={null}
from blockdb import Column, filter

expr = (Column("value") > 0) & (Column("name") == "Transfer")
cond = filter(expr)
# -> '{"type":"And","left":{"type":"GreaterThan",...},"right":{...}}'
```

`filter` also accepts input that is already a JSON string and passes it through unchanged.

## Operator pipelines

`Operator` builds chained `filter` / `deduplicate` preprocessing pipelines, serialized into a structured execution plan:

```python theme={null}
from blockdb import Column, Operator

op = (
    Operator()
    .filter(
        (Column("value") > 0) &
        (Column("name") == "Transfer")
    )
    .deduplicate(Column("tx_id"))
)

op.to_dict()   # the structured execution plan as a dict
op.to_json()   # as a JSON string
```

This pipeline describes "filter by condition first, then dedup by `tx_id`". It is usually attached to a BlockX task's `triggerSource` so the engine preprocesses rows before calling your business function — source rows are trimmed first, and your function only handles the subset you actually care about.

<Info>
  Preprocessing pipelines are optional: simple logic is clearer written inside the function body, while a large number of rows with a high filter ratio benefits from filtering and deduping on the engine side first.
</Info>

## Related topics

* [High-concurrency compute with BlockX](/guides/blockx)
* [Read and write data](/guides/data-access)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.