Python transform (python)¶
Calls a function in a project Python module and emits a @dp.temporary_view.
The whole module file is copied to generated/<pipeline>/custom_python_functions/
and imported as from custom_python_functions.<module> import <function>.
Minimal example¶
Add this entry to the actions list in your flowgroup.
- name: transform_enrich
type: transform
transform_type: python
source: v_orders
target: v_orders_enriched
module_path: "transforms/enrich.py"
function_name: enrich
parameters:
lookup: regions
Options¶
Field |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string / list |
Yes |
— |
Input view name(s); |
|
string |
Yes |
— |
Path to a |
|
string |
Yes |
— |
Name of the function to call. |
|
dict |
No |
|
Passed to the function as its |
|
string |
No |
|
|
Function signature: single source def fn(df, spark, parameters); list source
def fn(dataframes, spark, parameters). A source is required. To create a
DataFrame without an input view, use a Python load.
Common fields¶
Fields accepted by every transform_type. Type-specific fields are listed in
the options above.
Field |
Type |
Required |
Default |
Description |
|---|---|---|---|---|
|
string |
Yes |
— |
Action name, unique within the flowgroup. |
|
string |
Yes |
— |
Always |
|
string |
Yes |
— |
One of |
|
string |
Yes |
— |
Name of the produced view (or temporary table). Required for all transforms. |
|
string / list / mapping |
Yes |
— |
Upstream view name(s). Accepted shape and requirement vary per type — see this type’s options. |
|
string |
No |
auto |
Comment on the generated view/table. Defaults to an auto-generated string. |
|
bool / list |
No |
— |
Add operational metadata columns; a list selects column names. Honored by |
|
list |
No |
— |
Extra upstream table or view references added to the dependency graph. See Dependency analysis reference. |