All Products
Search
Document Center

MaxCompute:Connect using the local client (odpscmd)

Last Updated:Dec 27, 2025

The MaxCompute local client (odpscmd) is designed for command-line operations. You can run it on your local machine to efficiently execute commands and manage projects. This topic describes how to download, install, configure, run, and use the client.

Scope

  • Java 8 or a later version is installed on the device where you want to install the MaxCompute client.

  • Version compatibility

    • MaxCompute client V0.28.0 and later support Java Development Kit (JDK) 1.9. Versions earlier than V0.28.0 support only JDK 1.8. After you start the MaxCompute client, you can view the client version number in the command-line interface.

    • The output format of the MaxCompute client is not forward-compatible. The command format and behavior may vary between different versions. Do not rely on the client's output format for any parsing tasks.

    • For more information about client versions, see aliyun-odps-console.

  • Encoding format

    The client uses UTF-8 encoding by default. If your local environment does not use UTF-8 encoding, garbled characters may appear when you query a MaxCompute table and the returned values contain Chinese characters. Garbled characters may also appear when you use the client to run a Tunnel command to upload a local data file to MaxCompute.

Billing

You are not charged for connecting to a project using the MaxCompute client. However, operations that you perform through the client may incur MaxCompute fees. For example, if you use the client to submit an SQL query and a write command, the SQL command consumes computing resources when it runs on MaxCompute, and the written data occupies storage space. This generates computing and storage fees. For more information about MaxCompute billing, see Billable items and billing methods.

Install and configure the MaxCompute client

The client supports the MaxCompute V2.0 data type edition starting from V0.27.0. We recommend that you use the new data types. For a list of supported data types, see Data type editions.

Follow these steps:

  1. Download the MaxCompute client installation package (GitHub).

    Note
    • Click the link to go to the client release page and download the latest version of the MaxCompute client installation package (odpscmd_public.zip).

    • If you cannot download the package from the preceding link, try to click MaxCompute client installation package (OSS) to download it. If the GitHub link fails, we recommend that you search for a solution on a search engine.

  2. Decompress the downloaded installation package to get the bin, conf, lib, and plugins folders.

  3. Go to the conf folder and configure the odps_config.ini file.

    In the odps_config.ini file, lines that start with a number sign (#) are comments. The following table describes the parameters.

    Parameter

    Required

    Description

    Example

    project_name

    Yes

    The name of the target MaxCompute project that you want to access.

    If you create a workspace in standard mode, note the difference between the project names for the production environment and the development environment (_dev) when you configure the project_name parameter. For more information, see Differences between workspace modes.

    1. Log on to the MaxCompute console and select a region in the top-left corner.

    2. In the navigation pane on the left, choose Manage Configurations > Projects.

    3. On the Projects page, you can find the name of your MaxCompute project.

    doc_test_dev

    access_id

    Yes

    The AccessKey ID of your Alibaba Cloud account or RAM user. You can go to the AccessKey Management page to obtain the AccessKey ID.

    None

    access_key

    Yes

    The AccessKey secret that corresponds to the AccessKey ID.

    None

    end_point

    Yes

    The endpoint of the MaxCompute service.

    Configure the endpoint based on the region and network connection type that you selected when you created the MaxCompute project. For information about the endpoints for different regions and networks, see Endpoints.

    Important
    • The endpoint is for the MaxCompute service, and the Tunnel endpoint is for the MaxCompute Tunnel service. Enter the endpoint for the MaxCompute service here.

    • If the endpoint is configured incorrectly, an access error occurs. Make sure that the endpoint is correct.

    http://service.cn-hangzhou.maxcompute.aliyun.com/api

    log_view_host

    No

    The Logview address. We recommend that you configure this parameter. If you do not configure this parameter, you cannot quickly locate the problem when a job fails.

    You can use this address to view the detailed runtime information of a job, which provides a basis for troubleshooting. The value is fixed at http://logview.odps.aliyun.com.

    http://logview.odps.aliyun.com

    https_check

    No

    Specifies whether to enable HTTPS access to encrypt requests to access MaxCompute projects. Valid values:

    • True: HTTPS is used.

    • False: HTTP is used.

    Default value: False.

    True

    data_size_confirm

    No

    The maximum size of input data in GB. This parameter has no value range limit. We recommend that you set this parameter to 100 GB.

    100

    update_url

    No

    A reserved parameter that you can ignore.

    None

    use_instance_tunnel

    No

    Specifies whether to use InstanceTunnel to download the execution results of SQL statements. Valid values:

    • True: Use InstanceTunnel to download the execution results of SQL statements.

    • False: Do not use InstanceTunnel to download the execution results of SQL statements.

    Default value: False.

    True

    instance_tunnel_max_record

    No

    The maximum number of records that the client can return for an SQL execution result. If you set use_instance_tunnel to True, you must configure this parameter. The maximum value is 10000.

    10000

    tunnel_endpoint

    No

    The public endpoint of the Tunnel service.

    • If you do not configure a Tunnel endpoint, Tunnel automatically routes traffic to the Tunnel endpoint that corresponds to the network where the MaxCompute service resides.

    • If you configure a Tunnel endpoint, the configured endpoint is used, and automatic routing is not performed.

    For information about the Tunnel endpoints for different regions and networks, see Endpoints.

    http://dt.cn-hangzhou.maxcompute.aliyun.com

    set.<key>

    No

    Sets the properties of the MaxCompute project.

    For more information about properties, see Properties.

    set.odps.sql.decimal.odps2=true

    Make sure that the preceding information is correctly configured. Incorrect configuration will cause the project connection to fail.

Run the MaxCompute client

  1. Create a MaxCompute project.

  2. If you use a RAM user to run the MaxCompute client, use your Alibaba Cloud account to add the RAM user to the target MaxCompute project. For more information about adding workspace members, see Grant permissions to other users.

  3. Start the MaxCompute client using one of the following methods:

    Method 1: Use the script file in the installation package

    In the bin folder of the MaxCompute client installation directory, double-click the odpscmd.bat file for Windows or the odpscmd file for macOS to start the MaxCompute client. If the following information is returned, you have successfully connected to the MaxCompute project.image.png

    Method 2: Use the command-line window of your operating system

    In the command-line window of your operating system, go to the bin directory of the MaxCompute client installation path. Run the odpscmd command for Windows or sh odpscmd for Linux or macOS to start the MaxCompute client. If the following information is returned, you have successfully connected to the MaxCompute project.

    Note

    If you run sh odpscmd in Ubuntu, an error is reported. Try to run the ./odpscmd command to start the client.

    image.png

    If you start the MaxCompute client from the command-line window of your operating system, you can specify parameters to run commands. For more information about the parameters, see Startup parameters.

Related operations on the MaxCompute client

Get help for all commands

You can quickly get help for MaxCompute client commands using one of the following methods:

View command help information in the MaxCompute client

  • View help information for all commands.

    odps@project_name>help;
    -- This command is equivalent to the following command.
    odps@project_name>h;
  • Specify a keyword to view help information for related commands.

    For example, get help for commands related to table operations.

    odps@project_name>help table;
    -- The following result is returned.
    Usage: alter table <tablename> merge smallfiles
    Usage: export table <tablename>
    Usage: show tables [in <project_name>] [like '<prefix>']
           list|ls tables [-p,-project <project_name>]
    Usage: describe|desc [<projectname>.]<tablename> [partition(<spec>)]
    Usage: read [<project_name>.]<table_name> [(<col_name>[,..])] [PARTITION (<partition_spec>)] [line_num]
    Important

    The read command uses SQL syntax. For more information about billing, see SQL billing.

View command help information in the command-line window of your operating system

In the command-line window of your operating system, switch to the bin directory of the MaxCompute client installation path. Run the following command to view help information for all commands. When you start the MaxCompute client in a command-line window, you can specify a series of parameters. For more information about the parameters, see Startup parameters.

...\odpscmd\bin>odpscmd -h

Get information about the current logon user

After you run the MaxCompute client, run the following command to get information about the current logon user.

odps@project_name>whoami;

The following describes the response.

  • Name: The account information of the current logon user.

  • Source IP: The IP address of the device where the MaxCompute client is located.

  • End_Point: The endpoint of the MaxCompute service.

  • Project: The name of the MaxCompute project.

  • Schema: The schema in the MaxCompute project.

Exit the MaxCompute client

Run the following command to exit the running MaxCompute client.

odps@project_name>quit;
-- This command is equivalent to the following command.
odps@project_name>q;

Run the tunnel download command

  • When you run the tunnel download command for the first time, the MaxCompute client creates a session folder in the plugins/dship directory of the client installation to store logs.

  • If multiple users run the tunnel download command on the same device, use one of the following methods to ensure data security:

    • Use the folder permission management feature of the device to manage the permissions on the session folder.

    • Add the -sd <new session folder name> or -session-dir <new session folder name> parameter to the tunnel download command to download data to a different session folder. For more information about the tunnel download command, see Download.

References

After you log on to the MaxCompute client, you can run SQL commands in the MaxCompute project. For more information, see Use the MaxCompute client.

For more information about the command syntax that the MaxCompute client supports, see Common commands or SQL commands and functions.

FAQ

After you configure the odps_config.ini file, the following common errors may occur when you start the MaxCompute client:

Error: no java found

  • Cause

    Java is not installed on the machine where you run the MaxCompute client.

  • Solution

    Install Java on the machine where you run the MaxCompute client and configure environment variables. MaxCompute client V0.28.0 and later support JDK 1.9. Earlier versions support only JDK 1.8.

Error: Cannot find or load the main class com.aliyun.openservices.odps.console.ODPSConsole

  • Cause

    You may have downloaded the client installation package twice. The second time, the directory was automatically renamed to odpscmd_public (1). The directory name contains characters such as spaces, which causes a path recognition error.

  • Solution

    Remove characters such as spaces from the directory name.

Error: Accessing project '<projectname>' failed: ODPS-0420111: Project not found - '<projectname>'.

  • Cause

    The project name in the odps_config.ini configuration file is incorrect.

  • Solution

    1. Log on to the MaxCompute console and select a region in the top-left corner.

    2. In the navigation pane on the left, choose Manage Configurations > Projects.

    3. On the Projects page, get the correct name of the created MaxCompute project and modify the odps_config.ini configuration file.

Error: Accessing project '<projectname>' failed: ODPS-0420095: Access Denied - Authorization Failed [4002], You don't exist in project <projectname>.

Error: Accessing project '<projectname>' failed: { "Code": "InvalidProjectTable", "Message": "The specified project or table name is not valid or missing."} or Accessing project '<projectname>' failed: connect timed out

  • Cause

    The value of the end_point parameter is incorrect. For example, you use the MaxCompute client on your local computer to connect to a project, but you use the endpoint for the Alibaba Cloud classic network (an internal network endpoint in a public network environment) or enter a Tunnel endpoint.

  • Solution

    See the Endpoints document and select the endpoint that matches the region and network environment of the project you want to connect to.

    The endpoint is for the MaxCompute service, and the Tunnel endpoint is for the MaxCompute Tunnel service. The end_point parameter should be set to the endpoint for the MaxCompute service, not the Tunnel endpoint.

Error: Accessing project '<projectname>' failed: <endpoint>

  • Cause

    The value of the end_point parameter is incorrect. For example, you entered http://service.ch-hangzhou.maxcompute.aliyun.com/api instead of the public endpoint for the China (Hangzhou) region, which is http://service.cn-hangzhou.maxcompute.aliyun.com/api.

  • Solution

    See the Endpoints document and copy the endpoint that matches the region and network environment of the project you want to connect to. We recommend that you do not enter the endpoint manually.

Startup parameters

In the command-line window of your operating system, you can specify a series of parameters to quickly run commands. The usage is as follows.

Usage: odpscmd [OPTION]...
where options include the following:
    --help                                  (-h)for help
    --config=<config_file>                  specify another config file
    --project=<prj_name>                    use project
    --endpoint=<http://host:port>           set endpoint
    -k <n>                                  will skip begining queries and start from specified position
    -r <n>                                  set retry times
    -f <"file_path;">                       execute command in file
    -e <"command;[command;]...">            execute command, include sql command

The following table describes the startup parameters.

Command

Description

Sample command

--help or -h

Gets help information for all commands of the MaxCompute client.

odpscmd --help

--config

Specifies the path of the odps_config.ini configuration file. The default path is odpscmd_public/conf/odps_config.ini.

odpscmd --config=D:/odpscmd/conf/odps_config.ini

--project

Specifies the name of the MaxCompute project to access.

odpscmd --project=doc_test

--endpoint

Specifies the endpoint of the MaxCompute service. For more information about endpoints, see Endpoints.

odpscmd --endpoint=http://service.cn-shanghai.maxcompute.aliyun.com/api

-k

Runs statements starting from a specified position. If n≤0, the execution starts from the first statement. Statements are separated by semicolons (;).

Ignore the first two statements and start from the third statement. odpscmd -k 3 -e "drop table table_name;create table table_name (dummy string);insert overwrite table table_name select count(*) from table_name;"

-r

Sets the number of retries if a job fails.

odpscmd -r 2 -e "select * from sale_detail;select * from table_test;"

-f

Specifies the file to read.

  1. Prepare a local script file named script.txt. Assume that the file is stored on drive D and contains the following content.

    drop table if exists test_table_mj;
    create table test_table_mj (id string, name string);
    drop table test_table_mj;
  2. In the command-line window of your operating system, switch to the bin directory of the MaxCompute client installation path and run the following command.

    ..\odpscmd\bin>odpscmd -f D:/script.txt;

-e

Specifies the command to run.

odpscmd -e "select * from sale_detail;"

In a Shell window or Windows Command Prompt, you may need to use the dynamic return value from an odpscmd -e <SQL_statement> command. A Shell variable gets this dynamic return value and then uses it in subsequent jobs in the Shell. In this scenario, the return value must not contain extra information such as runtime information or table headers. To facilitate Shell calls, set the use_instance_tunnel parameter in the odps_config.ini file to false to disable the Instance Tunnel service. Then, run the set odps.sql.select.output.format={"needHeader":false,"fieldDelim":" "}; command to hide the table header.

For example, a table named noheader has one column and three rows of data: 1, 2, and 3. Run the following command to redirect the calculation result to stdout to the target handle. The result contains only the specific data, without any other extra information:

--Run the following command in the Windows Command Prompt.
...\odpscmd\bin>odpscmd -e "set odps.sql.select.output.format={""needHeader"":false,""fieldDelim"":"" ""};select * from noheader;" >D:\test.txt
--The result is saved in D:\test.txt.

--Run the following command in a Shell window.
/Users/.../odpscmd/bin/odpscmd -e "set odps.sql.select.output.format={\"needHeader\":false,\"fieldDelim\":\"\"};select * from noheader;" >/Users/A/temp/test.txt 
--The result is saved in /Users/A/temp/test.txt.
--The following result is returned.
1
2
3

Version update history

The following table describes the recent version updates of the MaxCompute client. For more information, click the link for the corresponding version.

For more information about MaxCompute client versions and related feature updates, see GitHub.

Version

Change type

Description

v0.52.3-public

New feature

Supports using Security Token Service (STS) tokens as temporary security credentials.

Bug fix

Upgraded the Apache Arrow library version to fix compatibility issues with Arrow library dependencies.

v0.52.2-public

New feature

Added an option to skip progress reports. You can add the skip_progress configuration parameter to control progress reports for MCQA 2.0 jobs.

Feature enhancement

  • Improved support for MCQA V2: Enhanced commands to better handle the MCQA V2 mode.

  • Enhanced the compact command to support the use of specific compact IDs.

v0.51.2-public

Bug fix

Upgraded dependencies to clear Common Vulnerabilities and Exposures (CVE) vulnerabilities.

v0.51.1-public

New feature

Enhanced acceleration for external volume creation: Added an acceleration option for external volume downloads.

Feature enhancement

Refactored the DescribeTableCommand, ShowPartitionsCommand, and ShowTablesCommand commands to better handle external project V2.

v0.51.0-public

New feature

  • Quota caching mechanism: Implemented a local file system cache for quota information to improve performance.

  • Enhanced compact command: Added a local threshold option, a forced mode, and optimized parameter validation for compact operations.

  • SQL optimization and tuning command: Introduced the new TUNE command to analyze and optimize SQL query plans. Implemented a tuning algorithm to evaluate multiple candidate execution plans. Added tuning history and reporting features.

Feature enhancement

  • Enhanced session management and quota loading for MCQA 2.0.

  • Network timeout configuration: Re-implemented the network_read_timeout and network_connect_timeout parameters and integrated timeout settings with the REST client configuration.

v0.50.0-public

New feature

  • Supports submitting MCQA 2.0 jobs.

  • Use the UseQuotaCommand to specify an interactive quota group.

v0.48.0-public

New feature

  • Upgraded the odps-sdk version from 0.47.0-public to 0.48.6-public. For more information about the enhancements and fixes, see the odps-sdk changelog.

  • The DESC EXTENDED command now displays data masking information.

Bug fix

The MCQA mode can more accurately identify fallback behavior to prevent the Logview from being repeatedly displayed.

v0.47.0-public

New feature

  • Added the http command to quickly initiate HTTP requests as the current user.

  • Keep session variables: Added the --keep-session-variables startup parameter. When this parameter is specified, the use [project] command does not clear set flags, such as SET a=b. These settings are retained when you switch between projects.

Feature enhancement

  • The read command supports new data types: The read command supports the TIMESTAMP_NTZ and JSON data types.

  • Upgraded Tunnel commands:

    • The TUNNEL UPLOAD/DOWNLOAD command supports the -qn flag to specify the Tunnel QuotaName.

    • The TUNNEL UPLOAD command supports the -dfp flag to set the format for uploading text of the DATETIME type.

  • HistoryCommand supports Grep: The HistoryCommand supports grep queries to improve search capabilities.

  • Project deletion syntax: To align with the syntax of the console, the DROP project command is supported and can be used in parallel with DELETE project.

  • Optimized Setproject command: Supports longer value strings and setting complex type values such as JSON.

v0.46.5-public

New feature

Tunnel-related operations support the JSON data type.

v0.46.4-public

New feature

  • UPSERT feature for data operations: Implemented the UPSERT operation through Tunnel. Added the DshipUpdate class and the RESUME_UPSERT_ID constant to support data updates and operation recovery.

  • Improved time zone management for SQL execution. You can run SET odps.sql.timezone=UTC; to set the time zone for SQL execution.

  • Enhanced security configuration commands: Improved the handling of security configurations.

  • Improved command parsing and validation: Refactored the SetCommand for better parsing capabilities and command matching.

Feature enhancement

Enhanced table description storage tier information: Extended the DescribeTableCommand to display more detailed storage tier information.

v0.45.1-public

New feature

  • Storage tier information display: Enhanced the DescribeTableCommand to display storage tier information for partitioned and non-partitioned tables.

  • Added the display of storage tier names and the last modification time of partitions. Displays the storage size of each storage tier in a partitioned table.

v0.45.0-public

New feature

  • MCQA attach session timeout configuration: Added the attach_session_timeout configuration parameter to control the MCQA session attach timeout.

  • Enhanced schema validation in SetCommand: Improved schema existence validation and error handling for invalid schema names when setting the default schema.

Feature enhancement

  • SessionUtils with attach timeout support: Added the attachTimeout parameter to the session builder configuration to enhance session management with configurable timeout values.

  • Improved dship command functionality: Enhanced the command to better parse and execute date and time processing.

  • Improved TopInstanceCommand: Enhanced command parsing and option handling.

v0.43.2-public

New feature

  • Supports creating external volumes.

  • The Show command supports querying information about all built-in functions or built-in functions that meet specific rules in the current MaxCompute project.

v0.40.10-public

Bug fix

Removed the Log4j dependency.

v0.40.8-public

New feature

Supports storing project data by schema. For more information, see Schema operations.

v0.37.5-public

New feature

Supports uploading and downloading complex data types through Tunnel.

v0.37.4-public

Feature enhancement

  • Help for the optimization command.

  • The desc extended partition command supports returning more partition property information.

v0.36.0-public

New feature

Supports creating an External Project to connect to Data Lake Formation (DLF) and implement the data lakehouse feature.

Bug fix

Fixed an issue where the nanosecond part of TIMESTAMP data was processed incorrectly during download.