Skip to content

API Reference parrot.tools.dataset_manager.computed

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.tools.dataset_manager.computed

View source

Computed Columns for DatasetManager.

Provides:

  • ComputedColumnDef: Pydantic model describing a single computed column.
  • COMPUTED_FUNCTIONS: Global registry mapping function names to callables.
  • Public API: register_computed_function, get_computed_function, list_computed_functions.
  • Built-in fallback functions that work without QuerySource installed: _builtin_math_operation, _builtin_concatenate.

All functions in the registry follow the QuerySource pattern::

def fn(df: pd.DataFrame, field: str, columns: list, **kwargs) -> pd.DataFrame:
    ...

The function must return the DataFrame with the new column field added.

QuerySource functions are loaded lazily on first call to get_computed_function or list_computed_functions; the built-ins are always available.

Attribute COMPUTED_FUNCTIONS

Type: Dict[str, Callable]

Class ComputedColumnDef

Definition of a computed column applied post-materialization.

The function identified by func must be present in COMPUTED_FUNCTIONS at the time the column is applied. Functions are loaded lazily from the QuerySource catalog (if available) and always fall back to the built-in implementations.

Fields:

Field Type Default Description
name str Name of the new column to create in the DataFrame.
func str Function name from the COMPUTED_FUNCTIONS registry.
columns List[str] Source column names that the function operates on.
kwargs Dict[str, Any] Extra keyword arguments forwarded to the function.
description str '' Human-readable description shown in the LLM guide and column metadata.

Function get_computed_function

Look up a function by name from the registry.

Lazily loads built-ins and QuerySource functions on the first call.

get_computed_function(name: str) -> Optional[Callable]

Parameter Type Default Description
name str Function name to look up.

Returns: Optional[Callable] — The callable if found, or None if the name is not registered.

Function list_computed_functions

Return a sorted list of all registered function names.

Lazily loads built-ins and QuerySource functions on the first call.

list_computed_functions() -> List[str]

Returns: List[str] — Sorted list of function name strings.

Attribute logger

Function register_computed_function

Register a custom function in the computed-columns registry.

Once registered, the function can be referenced by name in ComputedColumnDef.func.

register_computed_function(name: str, fn: Callable) -> None

Parameter Type Default Description
name str Registry key (must be unique; overwrites existing entry).
fn Callable Callable following the QuerySource pattern: fn(df, field, columns, **kwargs) -> df.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally