---
title: "Look up structured data with retrieval UDFs"
description: "Create lookup functions that query tables by key—for customer records, product catalogs, or financial data."
url: "https://www.pixeltable.com/notebooks/pattern-data-lookup"
updated: "2026-10-27"
---

# Look up structured data with retrieval UDFs

Create lookup functions that query tables by key—for customer records, product catalogs, or financial data.

- **Type:** Notebook
- **Group:** Agents

## How it works

Use pxt.retrieval_udf(table) to automatically create a function that queries the table by its columns.

## What it covers

- Create lookup functions from tables with retrieval_udf
- Query by single or multiple keys
- Use lookups in computed columns for data enrichment

## What it uses

- **Install:** `pip install pixeltable`
- **Pixeltable calls:** `pxt.create_table()`, `pxt.retrieval_udf()`, `insert()`, `add_computed_column()`

## A look at the code

```python
# Add a computed column that enriches orders with product details
orders.add_computed_column(
    product_info=get_product(sku=orders.product_sku)
)

# View enriched orders
orders.select(
    orders.order_id,
    orders.product_sku,
    orders.quantity,
    orders.product_info,
).collect()
```

## Open it

- **Open in Colab:** https://colab.research.google.com/github/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-data-lookup.ipynb
- **Docs page:** https://docs.pixeltable.com/howto/cookbooks/agents/pattern-data-lookup
- **Source on GitHub:** https://github.com/pixeltable/pixeltable/blob/release/docs/release/howto/cookbooks/agents/pattern-data-lookup.ipynb
