Skip to main content
Open in Kaggle  Open in Colab  Download Notebook
This documentation page is also available as an interactive notebook. You can launch the notebook in Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the above links.
Convert a table with computed columns into a callable function for multi-agent workflows and pipeline composition.

Problem

You have a table that runs a complex pipeline—LLM calls, tool use, post-processing—and you want to reuse that entire pipeline from other tables. Copy-pasting computed column definitions is error-prone and hard to maintain.

Solution

What’s in this recipe:
  • Create an “agent” table with computed columns
  • Convert the table to a callable UDF with pxt.udf(table, return_value=...)
  • Use the table UDF in other tables’ computed columns
You wrap an entire table pipeline as a function. When you call this function from another table, it inserts a row into the agent table, runs all computed columns, and returns the specified output column.

Setup

Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘table_udf_demo’.
<pixeltable.catalog.dir.Dir at 0x17fd6e9d0>

Create an agent table with computed columns

You create a table that encapsulates a complete pipeline. This example builds a summarization agent:
Created table ‘summarizer’.
Added 0 column values with 0 errors.
No rows affected.
Added 0 column values with 0 errors.
No rows affected.

Convert the table to a UDF

You use pxt.udf(table, return_value=...) to convert the table into a callable function. The return_value specifies which column to return:

Use the table UDF in another table

You can now use summarize() as a computed column in any other table:
Created table ‘articles’.
Added 0 column values with 0 errors.
No rows affected.
Inserting rows into `articles`: 2 rows [00:00, 196.58 rows/s]
Inserted 2 rows with 0 errors.
2 rows inserted, 6 values computed.

Explanation

How table UDFs work:
Consumer table row → Table UDF called → Agent table inserts row →
Computed columns run → Return value extracted → Consumer gets result
When to use table UDFs vs @pxt.query:
Key benefits:
  • Encapsulation: Hide complex pipeline details behind a simple function call
  • Reusability: Use the same agent from multiple consumer tables
  • Persistence: All intermediate results are stored in the agent table for debugging
  • Composition: Chain agents together for multi-stage workflows

See also

Last modified on June 24, 2026