Pipeline Builder supports both Java and Python user-defined functions (UDF). Learn more about Java UDFs.
This guide assumes you have already authored and published a Python function. Review our getting started with Python functions documentation for a tutorial.
Python functions run in a Pipeline Builder pipeline as a sidecar container. This means that the function does not need to be deployed and scales dynamically with the size of your pipeline. Embedded functions can be previewed similarly to other transforms in Pipeline Builder.
When you use a Python function as a user-defined function (UDF) in Pipeline Builder, the function runs once per row. Pipeline Builder does not pass an entire table, pandas DataFrame, or Spark DataFrame to your function. Instead, you map one or more input columns to the function's parameters, and Pipeline Builder invokes the function for every row, passing that row's cell values as the parameter arguments.
The value your function returns becomes a new column in the output table, with one value produced per row. For this reason, a Python UDF returns a scalar (single-value) type such as str, int, float, bool, or datetime rather than a DataFrame. There is no DataFrame type to return: the column that Pipeline Builder assembles from each row's return value is the resulting tabular output.
The following example takes two columns as input and returns one str value per row, which Pipeline Builder writes to a new column:
Copied!1 2 3 4 5from functions.api import function @function def full_name(first_name: str, last_name: str) -> str: return f"{first_name} {last_name}"
When you configure the transform, map the first_name and last_name parameters to the corresponding input columns. When the transform runs, Pipeline Builder evaluates full_name for each row and writes the returned string to a new output column.
For the full list of supported input and output types and their Python equivalents, review the types reference.
To return multiple related values from a single function, return a custom type (struct) instead of a scalar. Pipeline Builder adds the returned value as a single struct column with one field for each attribute of the custom type. You can then extract individual fields with the Get struct field transform.
Copied!1 2 3 4 5 6 7 8 9 10 11 12from dataclasses import dataclass from functions.api import function, Double @dataclass class Stats: total: Double average: Double @function def compute_stats(a: Double, b: Double) -> Stats: total = a + b return Stats(total=total, average=total / 2)
Follow the steps below to prepare and configure a Python function in your pipeline:
You should now see your Python function on your Pipeline Builder graph and can preview the output of the function.
To make API calls to an external system from Pipeline Builder, you can publish a Python function with access to external systems. This will allow you to write logic that communicates with external systems and use it as part of your pipeline.
To be used as a user-defined function (UDF) in Pipeline Builder, all sources used in your function must be configured to be importable into pipelines. To configure this setting, navigate to the source in Data Connection, then to the Connection settings > Code import configuration tab:

Once you have enabled this option on your source and published your Python function, it can be used in your pipeline in the same way as any other Python function.
Pipeline Builder UDFs do not support direct Ontology access through FoundryClient() or the Ontology SDK (OSDK). Instantiating FoundryClient() and accessing the Ontology from a UDF returns an EnvironmentNotConfigured error. This restriction helps prevent data from being unmarked or leaked across builds.
To access Ontology data from a Pipeline Builder UDF, consider the following approaches: