All Products
Search
Document Center

MaxCompute:ADD PY

Last Updated:Mar 26, 2026

Add Python type resources to a MaxCompute project for data processing and analysis.

Use ADD PY to register a local Python file as a project resource. Once registered, SQL UDFs and MapReduce jobs can reference the file by its resource name.

Limitations

  • External tables cannot be added as resources.

  • Tables added as resources do not support schema evolution. If schema evolution occurs on a table resource, re-add the table as a resource.

  • Each resource file cannot exceed 2,048 MB. Resources referenced by a single SQL or MapReduce job cannot exceed 2,048 MB in total.

  • ADD PY is a CMD statement and can only be run on the MaxCompute client (odpscmd).

Syntax

add py <local_file> [comment '<comment>'][-f];

Parameters

Parameter Required Description
py Yes Resource type. For a full list of resource types, see Resource.
local_file Yes Local file path. The file name becomes the resource name and serves as a unique identifier. If the file is in the odpscmd bin folder, specify only the file name — no path required.
comment No A comment for the resource.
-f No Overwrites an existing resource with the same name. Without this flag, the operation fails if a resource with the same name already exists.

Examples

Add a new Python resource

add py python.py;

Expected output:

OK: Resource 'python.py' have been created.

Overwrite an existing Python resource

Use the -f flag to replace a resource that already exists under the same name:

add py python.py -f;

Expected output:

OK: Resource 'python.py' have been created.

Related statements

Statement Description
ADD ARCHIVE Adds a compressed archive file as a resource
ADD FILE Adds a generic file as a resource
ADD JAR Adds a JAR file as a resource
ADD TABLE Adds a table as a resource
DESC RESOURCE Displays details about a resource
LIST RESOURCES Lists all resources in the current project
ALIAS Creates an alias for a resource
GET RESOURCE Downloads a resource to a local path
DROP RESOURCE Deletes a resource from the project