All Products
Search
Document Center

MaxCompute:ADD FILE

Last Updated:Mar 26, 2026

Adds a file as a resource to a MaxCompute project.

How it works

ADD FILE registers a local file in the current MaxCompute project so that SQL or MapReduce jobs can reference it by resource name at runtime. Use this command for general file types such as data files or transform scripts. To add a compressed archive, JAR package, or table instead, see Related statements.

Syntax

add file <local_file> [as <alias>] [comment '<comment>'] [-f];

Parameters

Parameter Required Description
file (resource type) Yes The resource type. For more information about resource types, see Resource.
local_file Yes Path of the local file to add. The file name is used as the resource name, which uniquely identifies the resource in the project.
alias No Custom resource name. If not specified, the file name is used as the resource name. JAR packages and Python script files used as resources do not support this parameter.
comment No Comment for the resource.
-f No If a resource with the same name already exists, replace it. If omitted and a duplicate name exists, the command fails.

Limitations

  • External tables cannot be added as resources.

  • Each resource file cannot exceed 2048 MB.

  • The MaxCompute client (odpscmd) must be version 0.37.5 or later.

  • The size of resources referenced by a single SQL or MapReduce job cannot exceed 2,048 MB.

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

Examples

Add a file named banking.txt as a resource:

add file banking.txt;

Expected output:

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

To confirm the resource was added, run list resources;.

Related statements