LinuxCommandLibrary

odps-func

Execute/Run ODPS (MaxCompute) functions

TLDR

Show functions in the current project

$ list functions;
copy

Create a Java function using a .jar resource
$ create function [func_name] as [path.to.package.Func] using '[package.jar]';
copy

Create a Python function using a .py resource
$ create function [func_name] as [script.Func] using '[script.py]';
copy

Delete a function
$ drop function [func_name];
copy

SYNOPSIS

odps-func command [options]

Commands:
  list: List all UDFs in the current project.
  upload: Upload a new UDF or update an existing one.
  delete: Delete a UDF.
  describe: Display details about a specific UDF.

PARAMETERS

--project name, -p name
    Specifies the MaxCompute project name to operate within. This is often an essential parameter for targeting specific data environments.

--endpoint url, -e url
    Specifies the MaxCompute service endpoint URL. This directs the command to the correct MaxCompute region or instance.

--function name, -n name
    The name of the User-Defined Function to be created, updated, deleted, or described. This is the identifier for the UDF within MaxCompute.

--class className, -c className
    For Java UDFs, specifies the fully qualified class name that implements the UDF logic. This class must be present in the uploaded JAR file.

--file filePath, -f filePath
    Specifies the local path to the UDF's executable file (e.g., a JAR file for Java UDFs, or a Python script for Python UDFs) that contains the function's logic.

--resources resourceList, -r resourceList
    A comma-separated list of existing MaxCompute resource names that the UDF depends on. These resources must be uploaded to MaxCompute separately and are required for the UDF to execute correctly.

--udf-type type
    Specifies the type of UDF being managed (e.g., 'java', 'python'). While often inferred, explicit specification ensures correct handling for ambiguous cases.

--overwrite
    Used with the 'upload' command to force an overwrite of an existing UDF with the same name. Without this, an error might occur if the UDF already exists.

--help, -h
    Displays help information for the odps-func command or a specific subcommand, showing available options and usage examples.

DESCRIPTION

odps-func is a command-line utility provided as part of the Alibaba Cloud MaxCompute (formerly ODPS) client tools. Its primary purpose is to manage User-Defined Functions (UDFs), User-Defined Aggregate Functions (UDAFs), and User-Defined Table Functions (UDTFs) within a MaxCompute project.

This tool allows users to upload new function definitions (typically JAR files for Java or Python files for Python UDFs), update existing ones, list all deployed functions, or delete functions from a MaxCompute project. It streamlines the deployment and lifecycle management of custom logic that extends MaxCompute's SQL capabilities, enabling complex data processing and analysis directly within the big data platform.

CAVEATS

This command is part of the Alibaba Cloud MaxCompute client tools and requires an active Alibaba Cloud account with MaxCompute service enabled. Users must have appropriate permissions to manage UDFs within the specified MaxCompute project. Proper configuration of the MaxCompute client (e.g., API keys, project name, endpoint) is crucial for the command to function correctly.

UDF TYPES AND LANGUAGE SUPPORT

MaxCompute supports various programming languages for UDFs, primarily Java and Python. When using odps-func, the `--class` parameter is typically used for Java UDFs, specifying the main entry point class within a JAR file. For Python UDFs, you would usually provide a Python script file. The command handles the nuances of deploying functions written in these different languages, adapting its internal processes based on the file type or explicit `--udf-type` parameter.

RESOURCE MANAGEMENT AND DEPENDENCIES

Complex UDFs often rely on external libraries or data files. In MaxCompute, these are managed as 'resources'. When uploading a UDF using odps-func, you can specify dependent resources using the `--resources` parameter. These resources must be pre-uploaded to your MaxCompute project. MaxCompute ensures these dependencies are available to your UDF at runtime, allowing for highly extensible and modular function development.

HISTORY

odps-func emerged as a specialized component within the broader suite of MaxCompute (formerly known as ODPS, Open Data Processing Service) client tools developed by Alibaba Cloud. Its development is intrinsically linked to the evolution of MaxCompute as a robust big data computing platform. The dedicated `odps-func` utility was introduced to streamline the lifecycle management of User-Defined Functions, acknowledging their critical role in extending the platform's capabilities beyond standard SQL. Its focus on function-specific operations reflects a commitment to providing granular control and simplifying the deployment of custom logic, making it easier for users to encapsulate complex business rules as reusable components within the MaxCompute ecosystem.

SEE ALSO

odpscmd, mc

Copied to clipboard