MaxCompute uses Tunnel to upload and download data. This topic describes how to use Tunnel to perform these operations.
MaxCompute allows you to run Tunnel commands to upload and download data. For a full list of Tunnel commands, see Tunnel commands.
| Operation | Description | Required permission | Tool |
|---|---|---|---|
| Upload data | Uploads local data to a MaxCompute table in append mode | Alter on the destination table | MaxCompute client (odpscmd) |
| Download data | Downloads table data or instance execution results to your local machine | Select on the source table | MaxCompute client (odpscmd) |
Upload data
Uploads local data to a MaxCompute table in append mode. Uploading data to MaxCompute is free of charge.
Limits
Upload files or level-1 directories to only one table or one partition per operation.
For a partitioned table, specify the target partition. If the table has multiple partition levels, specify a lowest-level partition.
Syntax
Tunnel upload <path> [<project_name>.]<table_name>[/<pt_spc>];Parameters
| Parameter | Required | Description |
|---|---|---|
path | Yes | Path to the local data file. Default file format: TXT. |
project_name | No | Name of the project that owns the destination table. Required for cross-project access. |
table_name | Yes | Name of the destination table. |
pt_spc | No | Partition specification for partitioned tables. Format: partition_col1=col1_value1, partition_col2=col2_value1.... Must point to a lowest-level partition. |
Path formats by OS
| OS | Path format |
|---|---|
Windows (file in bin directory) | File name.extension |
| Windows (file in another directory) | D:\test\File name.extension |
| macOS | Absolute path required. Example: /Users/username/MaxCompute/bin/file name.extension |
Examples
Example 1: Upload to a non-partitioned table
Upload log.txt (in the MaxCompute client bin directory) to test_table in the current project:
Tunnel upload log.txt test_table;Example 2: Upload to a partitioned table across projects (Windows)
Upload log.txt from D:\test\ to the p1="b1",p2="b2" partitions of test_table in test_project:
Tunnel upload D:\test\log.txt test_project.test_table/p1="b1",p2="b2";Download data
Downloads MaxCompute table data or the execution results of a specified instance to a directory on your local machine.
Downloads are charged based on the amount of data transferred. Fee = data downloaded (GB) x USD 0.1166/GB. Data can only be downloaded over the Internet.
Limits
Download data from only one table or one partition to a single local file per operation.
For a partitioned table, specify the source partition. If the table has multiple partition levels, specify a lowest-level partition.
Syntax
Tunnel download [<project_name>.]<table_name>[/<pt_spc>] <path>;Parameters
| Parameter | Required | Description |
|---|---|---|
project_name | No | Name of the project that owns the source table. Required for cross-project access. |
table_name | Yes | Name of the source table. |
pt_spc | No | Partition specification for partitioned tables. Format: partition_col1=col1_value1, partition_col2=col2_value1.... Must point to a lowest-level partition. |
path | Yes | Path for the downloaded file on your local machine. Default file format: TXT. |
Examples
Example 1: Download to the MaxCompute client directory
Download data from the p1="b1",p2="b2" partitions of test_project.test_table to test_table.txt in the MaxCompute client bin directory:
Tunnel download test_project.test_table/p1="b1",p2="b2" test_table.txt;Example 2: Download to a custom directory (Windows)
Download the same partitioned data to D:\test\test_table.txt:
Tunnel download test_project.test_table/p1="b1",p2="b2" D:\test\test_table.txt;