All Products
Search
Document Center

MaxCompute:Connect to MaxCompute with odpscmd

Last Updated:Jun 12, 2026

The MaxCompute client (odpscmd) is a command-line interface that lets you run commands and manage projects from your local machine. This topic explains how to download, install, configure, and use odpscmd.

Prerequisites

  • The MaxCompute client requires Java 8 or later.

  • Version compatibility

    • MaxCompute client v0.28.0 and later supports JDK 1.9 and later. Versions earlier than v0.28.0 support only JDK 1.8. After you start the MaxCompute client, you can view the client version in the command-line interface.

    • The output format of the MaxCompute client is not backward-compatible. Command formats and behavior may differ between client versions. Do not rely on the client output format for parsing.

    • For other client versions, see aliyun-odps-console.

  • Character encoding

    The client uses UTF-8 by default. If your local environment's character encoding is not UTF-8, garbled characters may appear when you query data containing Chinese characters from a MaxCompute table or use a Tunnel command to upload local files containing them.

Billing

Using the MaxCompute client to connect to a project is free of charge, but operations performed through the client are subject to MaxCompute billing. For example, submitting an SQL query consumes compute resources, and writing data uses storage space. This results in compute and storage costs. For more information about MaxCompute billing, see Billable items and billing methods.

Install and configure odpscmd

odpscmd v0.27.0 and later support the MaxCompute 2.0 data types. We recommend that you use these data types. For a list of supported data types, see Data Types (V2.0).

Procedure

  1. Download the odpscmd installation package (GitHub).

    Note
    • Follow the link to the release page and download the latest version of the odpscmd installation package (odpscmd_public.zip).

    • If you cannot download the package from the GitHub link, try downloading the odpscmd installation package (OSS). If you have issues accessing GitHub, we recommend that you search for solutions online.

  2. Unzip the downloaded package. The extracted directory contains 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, the number sign (#) indicates a comment. The following table describes the parameters.

    Parameter

    Required

    Description

    Example

    project_name

    Yes

    The name of the destination MaxCompute project.

    If you created a workspace in standard mode, distinguish 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 in to the MaxCompute console and select a region in the upper-left corner.

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

    3. On the Projects page, view your MaxCompute project name.

    doc_test_dev

    access_id

    Yes

    The AccessKey ID of your Alibaba Cloud account or RAM user. Obtain the AccessKey ID from the AccessKey Management page.

    N/A

    access_key

    Yes

    The AccessKey Secret that corresponds to the AccessKey ID.

    N/A

    end_point

    Yes

    The endpoint of the MaxCompute service.

    You must configure the endpoint based on the region where your MaxCompute project is located and the network connection type. For a list of endpoints for different regions and network types, see Endpoints.

    Important
    • An endpoint connects to the MaxCompute service, while a tunnel endpoint connects to the MaxCompute Tunnel service. Specify the endpoint for the MaxCompute service here.

    • An incorrect endpoint configuration causes an access error.

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

    log_view_host

    No

    The LogView URL. We recommend that you configure this parameter. If you do not configure this parameter, you cannot quickly identify the cause of a job failure.

    Use this URL to view detailed job runtime information and troubleshoot errors. The fixed value is http://logview.odps.aliyun.com.

    http://logview.odps.aliyun.com

    https_check

    No

    Specifies whether to enable HTTPS to encrypt requests for accessing the MaxCompute project. Valid values:

    • True: Enables HTTPS.

    • False: Uses HTTP.

    The default value is False.

    True

    data_size_confirm

    No

    The maximum input data size in GB. This value has no upper limit. Recommended value: 100.

    100

    update_url

    No

    This parameter is reserved for future use.

    N/A

    use_instance_tunnel

    No

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

    • True: Use InstanceTunnel to download SQL execution results.

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

    The default value is False.

    True

    instance_tunnel_max_record

    No

    The maximum number of records in an SQL execution result. If use_instance_tunnel is set to True, you must configure this parameter. The maximum value is 10,000.

    10000

    tunnel_endpoint

    No

    The public endpoint for the Tunnel service.

    • If you do not configure this parameter, Tunnel automatically routes requests to the tunnel endpoint that corresponds to the network of the MaxCompute service.

    • If you configure a tunnel endpoint, Tunnel uses that value and does not perform automatic routing.

    For a list of tunnel endpoints for different regions and network types, see Endpoints.

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

    set.<key>

    No

    Sets a property for the MaxCompute project.

    For more information about properties, see property list.

    set.odps.sql.decimal.odps2=true

    Ensure the preceding information is configured correctly. Misconfigurations can cause project connection failures.

Start the MaxCompute client

  1. Create a MaxCompute project.

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

  3. Use one of the following methods to start the MaxCompute client:

    Script file

    In the bin directory of your MaxCompute client installation, double-click odpscmd.bat (on Windows) or odpscmd (on macOS) to start the MaxCompute client. The following output indicates a successful connection to the MaxCompute project.

    odpscmd
    Aliyun ODPS Command Line Tool
    Version 0.4xxx
    @Copyright 2020 Alibaba Cloud Computing Co., Ltd. All rights reserved.
    Connecting to http://service.xxx.maxcompute.aliyun.com/api, project: xxx
    Executing predefined SET command: SET odps.sql.hive.compatible=true
    OK
    Endpoint: http://service.xxx.maxcompute.aliyun.com/api
    Project: xxx
    Schema: default
    Quota: default in region N/A
    Timezone: Asia/Shanghai
    Connected!

    Command-line window

    In a command-line window, navigate to the bin directory of your MaxCompute client installation. Run odpscmd on Windows or sh odpscmd on Linux or macOS to start the MaxCompute client. A success message indicates that the client has connected to the MaxCompute project.

    Note

    On Ubuntu, sh odpscmd returns an error. Use ./odpscmd instead.

    When you start the MaxCompute client from a command-line window, you can specify startup parameters to run commands. For more information, see Startup parameters.

MaxCompute client operations

Command help

You can get help with MaxCompute client commands in one of the following ways:

In the MaxCompute client

  • View help for all commands.

    odps@project_name>help;
    -- The following command is equivalent.
    odps@project_name>h;
  • View help for commands related to a specific keyword.

    For example, to get help with table-related commands, run the following command.

    odps@project_name>help table;
    -- The following output 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 and is subject to SQL pricing.

From the system CLI

In your system's command-line window, navigate to the bin directory of your MaxCompute client installation. Then, run the following command to view help for all commands. You can specify a series of parameters when you start the MaxCompute client from a command-line window. For more information about the parameters, see Parameters.

...\odpscmd\bin>odpscmd -h

Current user information

Run the following command to get current user information.

odps@project_name>whoami;

The output contains the following fields:

  • Name: The current account.

  • Source IP: The IP address of the device running the MaxCompute client.

  • End_Point: The endpoint of the MaxCompute service.

  • Project: The project name.

  • Schema: The schema in the project.

Exiting the MaxCompute client

Run the following command to exit the MaxCompute client.

odps@project_name>quit;
-- The following command is equivalent.
odps@project_name>q;

The tunnel download command

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

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

    • Use your operating system's permission settings to control access to 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.

Related documents

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

For details about the command syntax of the MaxCompute client, see Command reference or SQL commands and functions.

FAQ

After configuring the odps_config.ini file and starting the MaxCompute client, you may encounter the following common errors:

Error: no java found

  • Cause

    Java is not installed on the machine running the MaxCompute client.

  • Solution

    Install Java on the machine and configure the environment variable. The MaxCompute client v0.28.0 and later supports JDK 1.9 or higher. Earlier versions support only JDK 1.8.

Error: Could not find or load main class com.aliyun.openservices.odps.console.ODPSConsole

  • Cause

    You may have downloaded the client package twice, causing the directory to be automatically renamed to odpscmd_public (1). A directory name that contains special characters, such as spaces, can cause path resolution to fail.

  • Solution

    Remove spaces and other special characters from the directory name.

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

  • Cause

    The project name in the odps_config.ini file may be incorrect.

  • Solution

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

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

    3. On the Projects page, find the correct name of your MaxCompute project, and then modify the odps_config.ini 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 are trying to connect from your local computer but have configured an endpoint for an internal network (such as the classic network) or a tunnel endpoint.

  • Solution

    Refer to the Endpoints documentation and select the correct endpoint for your project's region and network environment.

    Ensure you use the MaxCompute service endpoint, not the tunnel endpoint, for the end_point parameter. Tunnel endpoints are for the MaxCompute Tunnel service.

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

  • Cause

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

  • Solution

    Refer to the Endpoints documentation and copy the correct endpoint for your project's region and network environment. We recommend copying the endpoint instead of typing it manually.

Startup parameters

You can run commands quickly from the system command line by specifying startup parameters.

Usage: odpscmd [OPTION]...
where options include:
    --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.

Parameter

Description

Example

--help or -h

Displays help information for all MaxCompute client commands.

odpscmd --help

--config

Specifies the path to the odps_config.ini 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 for connecting to the MaxCompute service. For more information, see Endpoints.

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

-k

Skips the first n-1 statements and starts execution from the nth statement. If n≤0, execution starts from the first statement. Statements are separated by semicolons (;).

Skips the first two statements and starts execution 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 times to retry a failed job.

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

-f

Specifies a file that contains commands to execute.

  1. Create a local script file named script.txt. For example, save it to the D: drive with 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. From the command line, navigate to the bin directory of the MaxCompute client and run the following command.

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

-e

Specifies a command to execute.

odpscmd -e "select * from sale_detail;"

On the shell or Windows command line, use odpscmd -e <SQL_statement> to capture dynamic return values in a shell variable for subsequent jobs. In this scenario, the return value must not contain extra information, such as runtime details or a header. To facilitate shell scripting, set the use_instance_tunnel parameter in the odps_config.ini file to false to disable Instance Tunnel. Then, run the set odps.sql.select.output.format={"needHeader":false,"fieldDelim":" "}; command to suppress the header.

For example, consider a table named noheader with one column and three rows of data: 1, 2, and 3. Run the following command to redirect the standard output to a file. The output contains only the data and no extra information:

--Windows command line:
...\odpscmd\bin>odpscmd -e "set odps.sql.select.output.format={""needHeader"":false,""fieldDelim"":"" ""};select * from noheader;" >D:\test.txt
--The result is saved to D:\test.txt.
--Shell:
/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 to /Users/A/temp/test.txt.
--Output:
1
2
3

Version history

The following table describes recent updates to odpscmd. For more details, click the link for a specific version.

For a complete list of odpscmd versions and release notes, see GitHub.

Version

Type

Description

v0.52.3-public

new feature

Added support for using an STS token as temporary security credentials.

bug fix

Updated the Apache Arrow library to resolve dependency compatibility issues.

v0.52.2-public

new feature

Added the skip_progress parameter to disable progress reporting for MaxCompute Query Acceleration (MCQA) 2.0 jobs.

enhancement

  • Enhanced commands to better support the MCQA V2 mode.

  • Enhanced the compact command to accept specific compact IDs.

v0.51.2-public

bug fix

Upgraded dependencies to resolve CVE vulnerabilities.

v0.51.1-public

new feature

Added an acceleration option for downloading an external volume.

enhancement

Refactored theDescribeTableCommand,ShowPartitionsCommand, andShowTablesCommand commands to improve support for external project V2.

v0.51.0-public

new feature

  • Implemented a local file system cache for quota information to improve performance.

  • Enhanced the compact command with a local threshold option, a force mode, and improved parameter validation.

  • Introduced the TUNE command to analyze and optimize SQL query plans. This command evaluates multiple candidate execution plans and provides tuning history and reports.

enhancement

  • Enhanced session management and quota loading for MCQA 2.0.

  • Re-implemented the network timeout parameters (network_read_timeout andnetwork_connect_timeout) and integrated them with the REST client configuration.

v0.50.0-public

new feature

  • Added support for submitting MCQA 2.0 jobs.

  • Added the UseQuotaCommand to specify an interactive quota group.

v0.48.0-public

new feature

  • Upgradedodps-sdk from0.47.0-public to0.48.6-public. For a list of enhancements and fixes, see the odps-sdk changelog.

  • Enhanced theDESC EXTENDED command to display data masking information.

bug fix

Improved the MCQA mode to more accurately detect fallback behavior and prevent duplicate logview displays.

v0.47.0-public

new feature

  • Added the http command, which lets you send HTTP requests with your current credentials.

  • Added the --keep-session-variables startup parameter. When enabled, the use [project] command no longer clears existing session variables (such as those set with SET a=b), allowing them to persist when you switch between projects.

enhancement

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

  • Tunnel command upgrades:

    • The TUNNEL UPLOAD/DOWNLOAD commands support the -qn flag to specify a Tunnel QuotaName.

    • The TUNNEL UPLOAD command supports the -dfp flag to set the format for DATETIME values in text files.

  • Added grep support to HistoryCommand to improve search capabilities.

  • Added support for the DROP project syntax to align with the console. The DELETE project syntax remains available.

  • Enhanced the setproject command to support longer value strings and complex data types such as JSON.

v0.46.5-public

new feature

Added support for the JSON data type in Tunnel operations.

v0.46.4-public

new feature

  • UPSERT functionality for data operations: This feature allows you to perform UPSERT operations through Tunnel. It adds the DshipUpdate class and the RESUME_UPSERT_ID constant to support data updates and operation recovery.

  • Improved timezone management for SQL execution. You can use SET odps.sql.timezone=UTC; to set a session-level timezone.

  • Improved the handling of security configurations.

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

enhancement

Extended the DescribeTableCommand to display more detailed information about the storage layer.

v0.45.1-public

new feature

  • Enhanced the DescribeTableCommand to display storage layer information for both partitioned and non-partitioned tables.

  • The command displays the storage layer name, the last modified time of partitions, and the storage size for each storage layer within a partitioned table.

v0.45.0-public

new feature

  • Added the attach_session_timeout parameter to control the timeout for attaching to an MCQA session.

    Note

    This parameter applies to MCQA (Query Acceleration 1.0). For MaxQA (Query Acceleration 2.0) configuration, see Query Acceleration MaxQA.

  • Improved schema validation for the SetCommand. When you set a default schema, the client validates schema existence more accurately and handles invalid schema names more effectively.

enhancement

  • Enhanced session management by adding the attachTimeout parameter to the session builder configuration.

  • Enhanced the dship command to improve parsing and handling of datetime values.

  • Improved parsing and option handling for the TopInstanceCommand.

v0.43.2-public

new feature

  • Added support for creating an external volume.

  • Enhanced the show command to query all built-in functions in the current MaxCompute project, or filter them by a specific pattern.

v0.40.10-public

bug fix

Removed the Log4j dependency.

v0.40.8-public

new feature

Added support for schema-based data organization within a project. For more information, see Schema operations.

v0.37.5-public

new feature

Added support for uploading and downloading complex data types through Tunnel.

v0.37.4-public

enhancement

  • Improved the help messages for commands.

  • Enhanced the desc extended partition command to return more partition properties.

v0.36.0-public

new feature

Added support for creating an external project to connect to Data Lake Formation (DLF), which enables lakehouse capabilities.

bug fix

Fixed an issue where the nanosecond part of TIMESTAMP data was handled incorrectly during downloads.