Look up structured data with retrieval UDFs

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

Agents · Notebook · Updated

Colab runs it in your browser. If it calls a model provider, it asks for that provider's API key in a cell.

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
terminal
pip install pixeltable
Pixeltable calls
pxt.create_table()pxt.retrieval_udf()insert()add_computed_column()

A look at the code

pattern-data-lookup.ipynb
# 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()

One cell of the notebook, copied as it is. Open it in Colab for the rest.

Browse all 103
  • Agentic Patterns

    Build the six architectural patterns of agentic AI (prompt chaining, routing, parallelization, tool use, evaluator-optimizer, orchestrator-worker) and the ReAct and planning strategies as Pixeltable tables and computed columns.

    Updated Open in Colab
  • LLM as judge

    Score model output with a second model, as a chain of computed columns

    Recipe · Updated