All Products
Search
Document Center

MaxCompute:Manage resources

Last Updated:Mar 26, 2026

UDF and MapReduce jobs in MaxCompute cannot directly access local files — you must first upload them as project-level resources. Once uploaded, resources are available across jobs without re-uploading. This page explains how to add, alias, download, view, list, and delete resources using the MaxCompute client (odpscmd).

The following table lists the supported operations.

Operation CLI command Required permission
Add a resource add file / add jar / add py / add archive / add table Write permission on resources
Create a resource alias alias Write permission on resources
Download a resource get resource Write permission on resources
View resource details desc resource Read permission on resources
List resources list resources List permission on objects in a project
Delete a resource drop resource Delete permission on resources

Prerequisites

Before you begin, make sure you have:

Add resources

Adds a local file to a MaxCompute project as a resource, making it available to user-defined function (UDF) or MapReduce jobs.

Limitations:

  • External tables cannot be added as resources.

  • The maximum size per resource file is 2,048 MB. The total size of resources referenced by a single SQL or MapReduce job cannot exceed 2,048 MB.

Syntax:

add file <local_file> [as <alias>] [comment '<comment>'] [-f];
add archive <local_file> [as <alias>] [comment '<comment>'] [-f];
add table <table_name> [partition (<spec>)] [as <alias>] [comment '<comment>'] [-f];
add py|jar <local_file> [comment '<comment>'] [-f];

Parameters:

Parameter Required Description
file|archive|table|py|jar Yes The resource type.
local_file Yes The local path of the file to add. The file name becomes the resource name, which uniquely identifies the resource in the project.
table_name Yes (table type) The name of the MaxCompute table to add as a resource.
spec Yes (partitioned table) The partition specification. When specified, only that partition is added as a resource, not the entire table.
alias No A custom name for the resource. If omitted, the file name is used. Not supported for jar or py resources.
comment No A descriptive comment for the resource.
-f No Overwrites an existing resource with the same name. If omitted and a name conflict exists, the operation fails.

Examples:

Add a text file as a resource:

add file banking.txt;

Expected output:

OK: Resource 'banking.txt' have been created.

Add a partition of a table as a resource with an alias:

add table sale_detail partition (ds='20150602') as sale.res comment 'sale detail on 20150602' -f;

Expected output:

OK: Resource 'sale.res' have been updated.

Add a Python file as a resource:

add py python.py;

Expected output:

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

Create an alias for a resource

Creates an alias that points to a resource. Use aliases in MapReduce or UDF code to switch between different resources by name without modifying the code.

Syntax:

alias <alias>=<real>;

Parameters:

Parameter Description
alias The alias to assign.
real The actual resource name.

Example:

The following example runs two MapReduce jobs that reference different date partitions through the same alias resName. Reassigning the alias between jobs eliminates the need to change the code.

-- Add resources for two different date partitions.
add table sale_detail partition (ds='20121208') as res_20121208;
add table sale_detail partition (ds='20121209') as res_20121209;

-- Point resName to the first partition and run the job.
alias resName=res_20121208;
jar -resources resName -libjars work.jar -classpath ./work.jar com.company.MainClass args ...;

-- Reassign resName to the second partition and run the job.
alias resName=res_20121209;
jar -resources resName -libjars work.jar -classpath ./work.jar com.company.MainClass args ...;

View resource information

Returns the details of a specified resource: name, owner, type, comment, creation time, last modification time, last updater, file size, and MD5 checksum.

Note

Resource names in MaxCompute are case-insensitive. resource_A and resource_a refer to the same resource.

Supported platforms: MaxCompute client (odpscmd), Cloud Shell (odpscmd), DataWorks, MaxCompute Studio

Syntax:

desc resource <resource_name>;

Parameters:

Parameter Required Description
resource_name Yes The name of the resource to inspect.

Return fields:

Field Description
Name Resource name.
Owner Account that owns the resource.
Type Resource type.
Comment Resource comment.
CreatedTime Time when the resource was created.
LastModifiedTime Time when the resource was last updated.
LastUpdator Account that performed the last update.
Size Size of the resource file, in MB.
Md5sum MD5 checksum of the resource file.

Example:

-- View details for topn_new.jar.
desc resource topn_new.jar;

Expected output:

Name                                    topn_new.jar
Owner                                   ALIYUN$****@test.aliyunid.com
Type                                    JAR
Comment                                 cloudopenapi
CreatedTime                             2020-12-29 13:55:11
LastModifiedTime                        2020-12-29 13:55:11
LastUpdator
Size                                    11438795
Md5sum                                  8bcf6aabf****56c0

View a resource list

Lists all resources in a project, including each resource's name, owner, creation time, last modification time, type, and size.

Syntax:

list resources;

Example:

list resources;

Expected output:

Resource Name         Owner                 Creation Time         Last Modified Time    Type          Last Updator Resource Size  Source         comment
getaddr.jar           ALIYUN$****           2020-06-18 15:47:28   2020-06-18 15:47:28   jar           1353716                                    cloudopenapi
ip.dat                ALIYUN$****           2020-06-18 15:49:46   2020-06-18 15:49:46   file          8525962                                    cloudopenapi
2 resources

Download resources

Downloads a resource from a MaxCompute project to your on-premises machine.

Limitations: Only FILE, JAR, ARCHIVE, and PY resource types are supported. TABLE resources cannot be downloaded.

Syntax:

get resource <resource_name> <path>;

Parameters:

Parameter Required Description
resource_name Yes The name of the resource to download.
path Yes The local path where the downloaded resource is saved.

Example:

get resource getaddr.jar D:\;

Delete resources

Deletes a resource from a MaxCompute project. The operation prompts for confirmation before it takes effect.

Syntax:

drop resource <resource_name>;

Parameters:

Parameter Required Description
resource_name Yes The name of the resource to delete.

Example:

drop resource getaddr.jar;

Expected output:

Confirm to "drop resource getaddr.jar" (yes/no)? y
OK

What's next