Updated on 2026-11-06 GMT+08:00

Registering a Data-Juicer Operator

This section describes how to register a Data-Juicer operator (an instance of a Filter or Mapper subclass) as a scalar UDF. Internally, the SDK uses dj_operator_to_aura_udf to adapt the operator into a callable UDF, and then delegates the registration to create_udf.

Since cloudpickle serializes Data-Juicer operator classes by reference, the SDK automatically adds py-data-juicer to runtime_env.pypi to ensure that the package is installed in the Aura runtime. User-defined runtime_env takes precedence over automatically injected items.

Prerequisites

The data_juicer package has been installed (used to construct operator instances locally).

Function Signature

client.create_datajuicer_operator(
    operator, /, *,
    name,
    input_columns,
    output_columns=None,
    database=None,
    signature=None,
    imports=None,
    runtime_env=None,
    description=None,
    pretty_name=None,
    is_strict=True,
    volatility="VOLATILE",
    is_batch=False,
    batch_size=None,
    cpu_arch=None,
    cpus=None,
    memory=None,
    device_type=None,
    devices=None,
) -> Function

Parameter Description

Parameter

Mandatory (Yes/No)

Type

Default Value

Description

operator

Yes

Any (location parameter)

-

Initialized Data-Juicer operator instance (subclass of Filter or Mapper).

name

Yes

str

-

Name of the function registered with LakeFormation.

input_columns

Yes

list[str]

-

The input column names expected by the operator. The sequence aligns with the location parameter passed by the engine.

output_columns

No

list[str] | None

None

The output column names produced by the operator. This parameter is required for Mapper operations and can be ignored for Filter operations.

database

No

str | None

default_database

Name of the target database.

signature

No

Signature | None

None

Explicit function signature. For more information about the signature, see signature.

imports

No

str | Iterable[str] | None

None

Additional files, directories, or URLs to be included in the UDF package.

runtime_env

No

str | Mapping | None

None

Runtime environment configuration, which will be merged with {"pypi": ["py-data-juicer"]}.

For more information about runtime_env, see runtime_env.

description

No

str | None

None

Description of the function.

pretty_name

No

str | None

None

Display name.

is_strict

No

bool

True

Whether the function is strict.

volatility

No

str

VOLATILE

Function volatility.

is_batch

No

bool

False

Whether to enable batch processing.

batch_size

No

int | None

None

Batch size.

cpu_arch

No

str | None

None

CPU architecture. The value can be arm or x86.

cpus

No

float | None

None

Number of CPU cores. The minimum value is 0.33.

memory

No

int | None

None

Memory size, in MB. The minimum value is 1.

device_type

No

str | None

None

Device type.

devices

No

float | None

None

Number of devices.

Return Value

Returns a Function object (actually returned by create_udf).

Exception Description

Exception

Trigger Condition

ValueError

The operator is a Mapper, but output_columns is not provided.

ImportError

The data_juicer package is not installed.

Sample Code

from data_juicer.ops.mapper import LowercaseMapper

op = LowercaseMapper(text_column="content")

func = client.create_datajuicer_operator(
    operator=op,
    name="dj_lowercase",
    input_columns=["content"],
    output_columns=["content"],          # Mandatory for Mapper
    description="Data-Juicer lowercase mapping operator",
)
  • The Mapper and Filter operator types are supported.
  • The Filter operators do not require output_columns. If provided, they are ignored.
  • runtime_env merging rule: User-defined configurations take precedence. py-data-juicer is automatically added as a supplementary dependency. Duplicate package names are handled based on the deduplication policy.