### Install ODPS Console from Pre-built Package Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Download, extract, and configure credentials for the ODPS Console. Verify the installation by running a sample command. ```bash # Download and extract wget https://github.com/aliyun/aliyun-odps-console/releases/latest/download/odpscmd_public.zip unzip odpscmd_public.zip cd odpscmd_public # Create configuration file cat > conf/odps_config.ini << 'EOF' # Required project_name = my_project access_id = LTAI5tXXXXXXXXXX access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end_point = http://service.cn-hangzhou.maxcompute.aliyun.com/api # Optional log_view_host = https://logview.odps.aliyun.com instance_priority = 9 debug = false network_read_timeout = 30000 network_connect_timeout = 10000 EOF # Verify installation ./bin/odpscmd -e "show tables;" # Expected output: # ODPS Console # ... # OK ``` -------------------------------- ### SQL SELECT Query Examples Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Demonstrates executing SQL SELECT statements for data querying and aggregation. Supports standard SQL and MaxCompute extensions. ```sql -- Interactive: preview table data odps@my_project> select order_id, user_id, amount, from_unixtime(create_time, 'yyyy-MM-dd') as order_date from orders where dt = '2024-01-01' and amount > 100.0 limit 20; -- Batch: aggregate query ./bin/odpscmd -e " SELECT region, COUNT(*) AS order_cnt, SUM(amount) AS total_amount FROM orders WHERE dt BETWEEN '2024-01-01' AND '2024-01-31' GROUP BY region ORDER BY total_amount DESC; " -- Expected output: -- +----------+-----------+--------------+ -- | region | order_cnt | total_amount | -- +----------+-----------+--------------+ -- | east | 18423 | 9821043.50 | -- | north | 12001 | 4320110.00 | -- +----------+-----------+--------------+ -- OK ``` -------------------------------- ### Execute SQL Command in ODPS Console Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Verify your setup by executing a simple SQL command like `show tables;` in the ODPS Console. ```sql show tables; ``` -------------------------------- ### Download ODPS Console Package Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Download the latest pre-built ODPS Console package using wget. This is the recommended installation method. ```bash wget https://github.com/aliyun/aliyun-odps-console/releases/latest/download/odpscmd_public.zip ``` ```bash wget https://maxcompute-repo.oss-cn-hangzhou.aliyuncs.com/odpscmd/latest/odpscmd_public.zip ``` -------------------------------- ### Build ODPS Console from Source Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Clone the repository and build the ODPS Console using Maven. Ensure Java 8+ and Maven 3.0+ are installed. ```bash git clone https://github.com/aliyun/aliyun-odps-console.git cd aliyun-odps-console mvn clean package -DskipTests ``` -------------------------------- ### Build the ODPS Console Project Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Navigate to the project directory and execute this command to clean and package the project, skipping tests. Ensure Java 8+ and Maven 3.0+ are installed. ```bash cd aliyun-odps-console mvn clean package -DskipTests ``` -------------------------------- ### Launch Interactive ODPS Console Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Start the ODPS Console in interactive REPL mode for a persistent session with command history and tab completion. ```bash # Launch interactive mode ./bin/odpscmd # Expected prompt: # ODPS Console # Aliyun ODPS Command Line Tool # Version 0.56.0-public # # odps@my_project> # Run commands at the prompt odps@my_project> show tables; odps@my_project> select * from my_table limit 5; odps@my_project> quit; ``` -------------------------------- ### Verify ODPS Console Installation Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Check the directory structure after extraction to verify that the ODPS Console has been installed correctly. Key directories include bin/, conf/, lib/, and plugins/. ```bash bin/ # Executable scripts conf/ # Configuration files lib/ # Library dependencies plugins/ # Plugin modules ``` -------------------------------- ### Get Detailed Instance Status Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Fetches comprehensive status details for a specific MaxCompute instance. ```sql status instance_id; ``` -------------------------------- ### Manage Project Security Settings Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Reads and updates the security configuration of the current MaxCompute project using `SHOW SECURITY CONFIGURATION` and `SET` commands. Also includes `GET POLICY` to retrieve authorization policies. ```sql -- Show current project security settings odps@my_project> show security configuration; ``` ```sql -- Enable ACL-based access control odps@my_project> set CheckPermissionUsingACL=true; ``` ```sql -- Enable label-based security odps@my_project> set LabelSecurity=true; ``` ```sql -- Get the project-level authorization policy odps@my_project> get policy; ``` -------------------------------- ### Clone ODPS Console Repository Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Clone your forked repository of the ODPS Console locally to start contributing. Replace 'your-username' with your GitHub username. ```bash git clone https://github.com/your-username/aliyun-odps-console.git ``` -------------------------------- ### Run ODPS Console in Interactive Mode Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Start the ODPS Console in interactive mode by running the `odpscmd` script. This allows you to execute commands directly and see a prompt. ```bash ./bin/odpscmd ``` -------------------------------- ### Send Authenticated HTTP Requests with http Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Dispatches raw HTTP requests to MaxCompute REST APIs using current session credentials. Supports GET, POST, custom headers, and bearer tokens. ```sql -- GET request odps@my_project> http GET /projects/my_project; ``` ```sql -- POST request with body from file odps@my_project> http POST /projects/my_project/tables -content=/tmp/create_table.json; ``` ```sql -- Custom headers from file odps@my_project> http GET /projects/my_project/instances \ -header=/tmp/extra_headers.properties; ``` ```sql -- Using a LogView bearer token odps@my_project> http GET /projects/my_project \ -token=Bearer_xxxxxxxxxxxxxxxx; ``` -------------------------------- ### Show Table Partitions Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Lists all partitions for a given partitioned table. ```sql show partitions my_table; ``` -------------------------------- ### Switch Active Project with USE Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Changes the current working project context for all subsequent commands. Supports switching with or without preserving session settings. ```sql -- Switch to a different project odps@my_project> use analytics_prod; -- Prompt changes to: odps@analytics_prod > ``` ```sql -- Switch and preserve session variables (set flags, etc.) odps@my_project> use analytics_prod with-settings; ``` -------------------------------- ### List All Resources Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Displays all resources (e.g., JARs, Python files) that have been added to the current MaxCompute project. ```sql list resources; ``` -------------------------------- ### Show Running Instances Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Lists all currently running MaxCompute jobs or tasks. ```sql show instances; ``` -------------------------------- ### Enable Interactive Query Mode (MCQA) Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Configures the console to submit queries to an always-on interactive session for sub-second latency. Requires configuration in `conf/odps_config.ini`. ```ini # conf/odps_config.ini — enable interactive mode enable_interactive_mode = true interactive_service_name = public.default interactive_output_compatible = false interactive_auto_rerun = true attach_session_timeout = 60 fallback.resource = retry fallback.unsupported = offline fallback.timeout = retry ``` -------------------------------- ### View Current Configuration Flags Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Displays all currently active configuration parameters and their values for the MaxCompute session. ```sql show flags; ``` -------------------------------- ### ODPS Console Configuration File Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Create a configuration file at `conf/odps_config.ini` with your MaxCompute project details. Basic project name, access ID, access key, and endpoint are required. ```ini # Basic configuration (required) project_name = your_project_name access_id = your_access_id access_key = your_access_key end_point = your_endpoint # Optional configurations for enhanced functionality log_view_host = https://logview.odps.aliyun.com debug = false instance_priority = 9 ``` -------------------------------- ### List All Functions Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Displays all user-defined and built-in functions available in the current MaxCompute project. ```sql list functions; ``` -------------------------------- ### Show Current Project Information Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Displays information about the currently active MaxCompute project and user. ```sql whoami; ``` -------------------------------- ### Switch Project Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Changes the current MaxCompute project context to a different one. ```sql use another_project; ``` -------------------------------- ### List Tables with Prefix Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Lists tables in the current project that match a specific naming pattern using a wildcard. ```sql show tables like 'my_prefix%'; ``` -------------------------------- ### Build ODPS Console (With Tests) Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Builds the Aliyun ODPS Console project using Maven, including the execution of all unit tests. ```bash mvn clean package ``` -------------------------------- ### Manage MaxCompute job instances Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Provides commands to list, monitor, and control running MaxCompute job instances. Supports filtering by project and retrieving detailed status information. ```sql -- List recently submitted instances odps@my_project> show instances; ``` ```sql -- List instances in another project odps@my_project> show instances -p other_project; ``` ```sql -- Get status of a specific instance odps@my_project> status 20240101xxxxxxxxxxxxxxxxxxxxxxxx; ``` ```sql -- Stop (kill) a running instance odps@my_project> stop 20240101xxxxxxxxxxxxxxxxxxxxxxxx; ``` -------------------------------- ### DDL Commands for MaxCompute Tables Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Create, alter, and drop tables using DDL commands. Supports partitioning, lifecycle, and column comments. ```sql -- Create a partitioned table odps@my_project> CREATE TABLE IF NOT EXISTS orders ( order_id BIGINT COMMENT 'Unique order ID', user_id BIGINT COMMENT 'Customer ID', amount DOUBLE COMMENT 'Order total in CNY', status STRING COMMENT 'Order status', items ARRAY COMMENT 'SKU list' ) PARTITIONED BY (dt STRING COMMENT 'Date partition yyyy-MM-dd') LIFECYCLE 90 COMMENT 'Order fact table'; ``` ```sql -- Add a new column odps@my_project> ALTER TABLE orders ADD COLUMNS (discount DOUBLE COMMENT 'Applied discount'); ``` ```sql -- Drop a table odps@my_project> DROP TABLE IF EXISTS temp_staging; ``` -------------------------------- ### Run All Tests with Maven Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Execute all tests for the ODPS Console project using Maven. Ensure ODPS configuration files are set up in the specified locations before running. ```bash mvn clean test ``` -------------------------------- ### Show Table Partitions with Filter Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Lists partitions for a table that match a specific partition key value. ```sql show partitions my_table partition(region='us-west-1'); ``` -------------------------------- ### Build ODPS Console from Source Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Clone the repository and build the ODPS Console using Maven. Supports different build profiles for JDK versions and testing. ```bash git clone https://github.com/aliyun/aliyun-odps-console.git cd aliyun-odps-console # Build without tests (fast) mvn clean package -DskipTests # With JDK 21 support and parallel tests mvn clean package -Pjdk21 # Output package location ls odps-console-dist-public/target/odpscmd_public.zip ``` -------------------------------- ### Show Partitions in MaxCompute Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt List all or filtered partitions of a partitioned table. Use with a partition filter for specific partition retrieval. ```sql -- List all partitions odps@my_project> show partitions orders; ``` ```sql -- List partitions matching a filter odps@my_project> show partitions orders partition(dt='2024-01-01'); ``` -------------------------------- ### Run Simple Query in MaxCompute Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Execute a basic SQL query, such as selecting a limited number of rows from a table, using `select * from table_name limit 10;`. ```sql select * from table_name limit 10; ``` -------------------------------- ### List Accessible Projects Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Lists all MaxCompute projects that the current user has access to. ```sql list projects; ``` -------------------------------- ### Manage UDFs with CREATE, LIST, DROP FUNCTION Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Register, list, describe, and remove user-defined functions (UDFs) backed by uploaded resources. Supports Java and Python UDFs. ```sql -- Register a Java UDF odps@my_project> create function str_normalize as 'com.example.udfs.StringNormalize' using 'string_utils.jar'; ``` ```sql -- Register a Python UDF odps@my_project> create function json_extract as 'my_transform.extract_json' using 'transform_lib.py'; ``` ```sql -- List all registered functions odps@my_project> list functions; ``` ```sql -- Describe a specific function odps@my_project> desc function str_normalize; ``` ```sql -- Drop a function odps@my_project> drop function json_extract; ``` ```sql -- Use the UDF in a query odps@my_project> select str_normalize(product_name) from dim_product limit 10; ``` -------------------------------- ### Execute Command with Custom Configuration Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `--config` option to specify a custom configuration file when executing commands in batch mode. ```bash ./bin/odpscmd --config /path/to/custom_config.ini -e "select count(*) from my_table;" ``` -------------------------------- ### Describe Table Structure in MaxCompute Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `desc table_name;` command to view the schema and column details of a specific table. ```sql desc table_name; ``` -------------------------------- ### Show Tables in MaxCompute Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt List tables in the current or specified project/schema. Supports filtering by prefix and table type. ```sql -- List all tables in current project odps@my_project> show tables; ``` ```sql -- List tables with prefix filter odps@my_project> show tables like 'dwd_%'; ``` ```sql -- List only external tables odps@my_project> show external tables; ``` ```sql -- List tables in another project odps@my_project> show tables in another_project; ``` ```sql -- List tables in a specific schema (schema-mode projects) odps@my_project> show tables from my_project.analytics; ``` -------------------------------- ### Build ODPS Console (Skip Tests) Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Builds the Aliyun ODPS Console project using Maven, skipping the execution of unit tests. This is faster if tests are not required. ```bash mvn clean package -DskipTests ``` -------------------------------- ### Describe Resource Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Shows detailed information about a specific resource, including its type and path. ```sql desc resource my_resource; ``` -------------------------------- ### Run Interactive Queries and Manage Sessions Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Once MCQA is enabled, queries run interactively. Commands like `wait` retrieve LogView, and `use quota` switches quotas in V2 mode. ```sql -- Once enabled, queries run interactively automatically odps@my_project> select count(*) from orders where dt = '2024-01-01'; ``` ```sql -- Get the current session LogView odps@my_project> wait; ``` ```sql -- Switch quota in MCQA V2 mode odps@my_project> use quota my_reserved_quota; ``` -------------------------------- ### Create a New Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Defines and creates a new table with specified columns and data types. ```sql create table new_table ( id bigint, name string, age int ); ``` -------------------------------- ### Download Instance Data Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/odps-console-dship/src/main/resources/download.txt This command downloads data associated with a specific ODPS instance. Specify the project and instance ID for the download. ```bash tunnel download instance://test_project/test_instance log.txt ``` -------------------------------- ### Describe MaxCompute Table Schema Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Use DESC or DESC EXTENDED to view table schema, partition columns, and statistics. Extended description includes storage and masking metadata. ```sql -- Basic schema description odps@my_project> desc orders; ``` ```sql -- Extended description including storage size, record count, column masking odps@my_project> desc extended orders; ``` -------------------------------- ### Create Function from Resource Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Creates a MaxCompute function using code from a registered resource (e.g., a JAR file containing UDFs). ```sql create function my_func as 'com.example.MyUDF' using 'my_udf.jar'; ``` -------------------------------- ### Extract and Navigate ODPS Console Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Extract the downloaded ODPS Console package and navigate into the extracted directory. This prepares the console for use. ```bash unzip odpscmd_public.zip cd odpscmd_public ``` -------------------------------- ### Add JAR Resource Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Registers a JAR file as a resource in MaxCompute, typically for UDFs or other external libraries. ```sql add jar /path/to/my_udf.jar; ``` -------------------------------- ### Download Table Data with Partition Filters Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/odps-console-dship/src/main/resources/download.txt Use this command to download data from a specific ODPS table, filtering by partition values. Ensure the table and partitions exist. ```bash tunnel download test_project.test_table/p1="b1",p2="b2" log.txt ``` -------------------------------- ### Configure Session Parameters with SET Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Sets SQL or console properties for the current session, overriding values from `odps_config.ini`. Supports various parameters like timezone, instance priority, and result tunneling. ```sql -- Set SQL timezone odps@my_project> set odps.sql.timezone=Asia/Shanghai; ``` ```sql -- Adjust instance execution priority (0=highest, 9=lowest) odps@my_project> set odps.instance.priority=5; ``` ```sql -- Enable instance tunnel for large result sets odps@my_project> set console.sql.result.instancetunnel=true; ``` ```sql -- Enable namespace schema mode odps@my_project> set odps.namespace.schema=true; ``` ```sql -- View all current session flags odps@my_project> show flags; -- Expected output (show flags): -- odps.sql.timezone=Asia/Shanghai -- odps.instance.priority=5 -- ... -- OK ``` -------------------------------- ### Show Current Identity with WHOAMI Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Displays the currently authenticated user, active project, and endpoint. Useful for verifying session context. ```sql odps@my_project> whoami; -- Expected output: -- Name: ALIYUN$user@example.com -- End_Point: http://service.cn-hangzhou.maxcompute.aliyun.com/api -- Project: my_project ``` -------------------------------- ### Describe Function Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Shows detailed information about a specific MaxCompute function, including its implementation class and resources. ```sql desc function my_func; ``` -------------------------------- ### Download Data from MaxCompute Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `tunnel download` command to download data from a MaxCompute table to a local file. Specify the table name and the local file path. ```sql tunnel download table_name /path/to/local/file.txt; ``` -------------------------------- ### Add resources to MaxCompute Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Uploads resources like JARs, Python scripts, archives, or table data to MaxCompute. Supports aliasing and force updating existing resources. ```sql -- Add a JAR resource for a UDF odps@my_project> add jar /opt/udfs/string_utils.jar; ``` ```sql -- Add a Python resource with alias odps@my_project> add py /opt/scripts/my_transform.py AS transform_lib.py; ``` ```sql -- Add an archive (ZIP) resource odps@my_project> add archive /opt/models/xgb_model.tar.gz AS model.tar.gz; ``` ```sql -- Add a table as a resource odps@my_project> add table dim_region PARTITION (dt='2024-01-01') AS region_data; ``` ```sql -- Force update an existing resource odps@my_project> add jar /opt/udfs/string_utils_v2.jar -f; ``` -------------------------------- ### Download Data from Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Downloads data from a MaxCompute table to a local file using the Data Tunnel service. ```bash tunnel download my_table /path/to/local/data.csv; ``` -------------------------------- ### Clone ODPS Console Repository Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Clones the Aliyun ODPS Console project from GitHub to your local machine. ```bash git clone https://github.com/aliyun/aliyun-odps-console.git cd aliyun-odps-console ``` -------------------------------- ### Add Python Resource Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Registers a Python script file as a resource in MaxCompute, often used for Python UDFs. ```sql add py /path/to/my_script.py; ``` -------------------------------- ### Wait for Instance Completion Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Pauses execution until a specified MaxCompute instance has finished running. ```sql wait instance_id; ``` -------------------------------- ### Download Table Data as CSV Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/odps-console-basic/src/test/resources/html/index.html Attaches a click handler to a button to trigger the download of table data as a CSV file. Ensure the table has an ID 'tabledata' and the download link has an ID 'downloadFile'. ```javascript $(document).ready(function () { $(\'a#downloadFile\') .attr(\'id\', \'downloadFile\') .attr(\'href\', \'data:application/octet-stream;charset=utf8,\' + encodeURIComponent($(\'#tabledata\').table2CSV({delivery: \'value\'}))) .attr(\'download\', \'filename.csv\') .appendTo(\'body\'); $(\'#button\').click(function () { $(\'#downloadFile\').get(0).click(); }); }); ``` -------------------------------- ### Describe Table Structure Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Displays the schema (column names and data types) of a specified table. ```sql desc my_table; ``` -------------------------------- ### Switch Active Schema with USE SCHEMA Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Switches the current schema within schema-mode projects. This command is applicable only in projects configured with schema mode. ```sql -- Switch schema within the current project odps@analytics_prod> use schema reporting; -- Expected output: -- OK ``` -------------------------------- ### Execute ODPS Console Command Line Options Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Run ODPS Console commands directly from the command line using the `-e` option for a single command or `-f` for a script file. You can also specify a custom configuration file with `--config`. ```bash # Execute a single SQL command ./bin/odpscmd -e "show tables;" # Execute a SQL script file ./bin/odpscmd -f /path/to/script.sql ``` ```bash ./bin/odpscmd -e "select count(*) from my_table;" --config /path/to/custom_config.ini ``` -------------------------------- ### Preview MaxCompute Table Rows Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Read a limited number of rows directly from a table using the READ command. Supports specific columns, partitions, and cross-project tables. ```sql -- Read first 10 rows of a table odps@my_project> read orders 10; ``` ```sql -- Read specific columns odps@my_project> read orders (order_id, amount, status) 5; ``` ```sql -- Read from a specific partition odps@my_project> read orders PARTITION (dt='2024-01-01') 20; ``` ```sql -- Read from a cross-project table odps@my_project> read other_project.orders 5; ``` -------------------------------- ### Preview Table Data Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Selects and displays a limited number of rows from a table to preview its contents. ```sql select * from my_table limit 10; ``` -------------------------------- ### Execute SQL Script File in Batch Mode Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `-f` option to execute a SQL script file. This is useful for running a series of commands. ```bash ./bin/odpscmd -f /path/to/script.sql ``` -------------------------------- ### Execute SQL Script File with -f Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Use the -f flag to execute a sequence of SQL commands from a specified file. Useful for complex ETL jobs or batch processing. ```bash # Create a script cat > /tmp/etl_job.sql << 'EOF' set odps.sql.timezone=UTC; INSERT OVERWRITE TABLE dwd_orders PARTITION (dt='2024-01-01') SELECT order_id, user_id, amount, status FROM ods_orders WHERE dt='2024-01-01' AND status != 'cancelled'; EOF # Execute the script ./bin/odpscmd -f /tmp/etl_job.sql # Expected output: # ... # ID = 20240101xxxxxxxxxxxxxxxxxxxxxxxx # ... # OK ``` -------------------------------- ### Upload Data to Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Uploads data from a local file to a MaxCompute table using the Data Tunnel service. ```bash tunnel upload /path/to/local/data.csv my_table; ``` -------------------------------- ### Set Session Configuration Parameter Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Sets a specific MaxCompute configuration parameter for the current console session. Changes typically take effect immediately for subsequent operations. ```sql set odps.sql.timezone=UTC; ``` -------------------------------- ### Show Specific Instance Status Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Retrieves the status of a particular MaxCompute instance using its ID. ```sql show instance instance_id; ``` -------------------------------- ### Download data using tunnel command Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Downloads data from MaxCompute tables or query results to local files. Supports specifying columns, filtering partitions, setting row limits, custom character sets, and downloading instance query results. ```bash ./bin/odpscmd -e "tunnel download orders /tmp/orders_full.csv;" ``` ```bash ./bin/odpscmd -e "tunnel download -cn 'order_id,amount,status' \ orders/dt=2024-01-01 /tmp/orders_jan01.csv;" ``` ```bash ./bin/odpscmd -e "tunnel download --limit 50000 -c gbk \ orders/dt=2024-01-01 /tmp/sample.txt;" ``` ```bash ./bin/odpscmd -e "tunnel download instance://my_project/20240101xxxxxxxx /tmp/result.csv;" ``` -------------------------------- ### Upload Data to MaxCompute Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `tunnel upload` command to upload local data files to a MaxCompute table. Specify the local file path and the target table name. ```sql tunnel upload /path/to/local/file.txt table_name; ``` -------------------------------- ### Execute Single Command with -e Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Use the -e flag to execute a single command string and display its output. Ideal for CI/CD pipelines. Supports custom configuration files and output redirection. ```bash # Execute a SQL query and capture output ./bin/odpscmd -e "select count(*) from orders where dt='2024-01-01';" # With a custom config file ./bin/odpscmd --config=/etc/maxcompute/prod.ini -e "show tables;" # Execute and redirect output to file ./bin/odpscmd -e "select * from dim_product limit 1000;" > /tmp/product_sample.txt # Expected output: # +------------+ # | _c0 | # +------------+ # | 42381 | # +------------+ # OK ``` -------------------------------- ### Download Data with Specific Charset Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Downloads data from a MaxCompute table to a local file, specifying the character encoding for the output file. ```bash tunnel download -c utf-8 my_table /path/to/data.txt; ``` -------------------------------- ### Stop Running Instance Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Terminates a MaxCompute instance that is currently in a running state. ```sql stop instance_id; ``` -------------------------------- ### Upload data using tunnel command Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Uploads local files to MaxCompute tables. Supports auto-detection of delimiters, custom delimiters, character sets, thread counts, and handling of bad records. Can also upload CSV files with header rows and overwrite existing partitions. ```bash ./bin/odpscmd -e "tunnel upload /data/orders_20240101.csv orders/dt=2024-01-01;" ``` ```bash ./bin/odpscmd -e "tunnel upload -fd '|' -c utf-8 -t 4 -dbr true \ /data/orders_20240101.txt orders/dt=2024-01-01;" ``` ```bash ./bin/odpscmd -e "tunnel upload -cf true -h true /data/export.csv orders;" ``` ```bash ./bin/odpscmd -e "tunnel upload -ow true /data/full_reload.csv orders/dt=2024-01-01;" ``` -------------------------------- ### Insert Data into MaxCompute Tables Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Use INSERT to overwrite or append data to MaxCompute tables and partitions. Ensure the data schema matches the table structure. ```sql -- Overwrite a partition from a SELECT odps@my_project> INSERT OVERWRITE TABLE dwd_orders PARTITION (dt='2024-01-15') SELECT order_id, user_id, amount, status FROM ods_raw_orders WHERE dt = '2024-01-15'; ``` ```sql -- Append rows to a table odps@my_project> INSERT INTO TABLE audit_log VALUES ('user_001', 'login', '2024-01-15 09:00:00'), ('user_002', 'logout', '2024-01-15 09:05:12'); ``` -------------------------------- ### Describe Table with Extended Information Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Provides detailed information about a table, including its schema, storage information, and other properties. ```sql desc extended my_table; ``` -------------------------------- ### Upload Data with Custom Delimiter Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Uploads data from a local file to a MaxCompute table, specifying a custom field delimiter for the source file. ```bash tunnel upload -fd '|' /path/to/data.txt my_table; ``` -------------------------------- ### Remove Resource Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Deletes a previously added resource from the MaxCompute project. ```sql remove resource my_resource; ``` -------------------------------- ### Wait for MaxCompute job instance completion Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Blocks execution until a specified MaxCompute job instance completes. Can also wait for the current interactive query session or trigger post-execution hooks. ```sql odps@my_project> wait 20240101xxxxxxxxxxxxxxxxxxxxxxxx; ``` ```sql odps@my_project> wait; ``` ```sql odps@my_project> wait 20240101xxxxxxxxxxxxxxxxxxxxxxxx --hooks; ``` -------------------------------- ### Create a New Feature Branch Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Create a new branch for your feature or bug fix before making changes. This helps in organizing contributions. ```bash git checkout -b feature/AmazingFeature ``` -------------------------------- ### Execute SQL Commands in Interactive Mode Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md In interactive mode, you can execute SQL commands directly after the prompt. The console provides features like command history and tab completion. ```sql odps @ your_project_name > show tables; ``` ```sql odps@your_project_name > select * from my_table limit 10; ``` ```sql odps @ your_project_name > drop table my_table; ``` -------------------------------- ### Execute Single SQL Command in Batch Mode Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Use the `-e` option to execute a single SQL command directly from the command line without entering interactive mode. ```bash ./bin/odpscmd -e "show tables;" ``` -------------------------------- ### Drop a Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Deletes a table and all its associated data from the project. ```sql drop table my_table; ``` -------------------------------- ### Resume Interrupted Upload Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Resumes a previously interrupted data upload process using its session ID. ```bash tunnel resume session_id; ``` -------------------------------- ### List External Tables Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Filters the table listing to show only external tables. ```sql show external tables; ``` -------------------------------- ### Insert Data into a Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Inserts a single row of data into a table with specified values. ```sql insert into table new_table values (1, 'John', 25); ``` -------------------------------- ### Show tunnel session history and bad records Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Displays recent tunnel session history and lists bad records from the last session. Useful for debugging and monitoring upload/download operations. ```bash ./bin/odpscmd -e "tunnel show history -n 10;" ``` ```bash ./bin/odpscmd -e "tunnel show bad;" ``` -------------------------------- ### CSS for Table Styling Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/odps-console-basic/src/test/resources/html/index.html Defines styles for table elements, including borders, padding, fonts, and alternating row colors. Also includes styles for text colors. ```css .green { color: green; } .red { color: red; } table { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; width: 70%; border-collapse: collapse; } td, th { font-size: 1em; border: 1px solid #98bf21; padding: 3px 7px 2px 7px; } th { font-size: 1.1em; text-align: left; padding-top: 5px; padding-bottom: 4px; background-color: darkblue; color: #ffffff; } tr:nth-child(2n+1) td { color: #000000; background-color: lightblue; } dt, dd { font-family: sans-serif; } dt { float: left; clear: left; text-align: left; width: 20%; color: #444444; } dd { float: left; margin-left: 15em; color: #444444; } ``` -------------------------------- ### Resume interrupted tunnel uploads Source: https://context7.com/aliyun/aliyun-odps-console/llms.txt Resumes interrupted data upload sessions. Can automatically resume the last session or resume a specific session using its ID. Supports forcing resume to ignore lock checks. ```bash ./bin/odpscmd -e "tunnel resume;" ``` ```bash ./bin/odpscmd -e "tunnel resume 2024xxxxxxxxxxxxxxxxxxxxxxxx;" ``` ```bash ./bin/odpscmd -e "tunnel resume -force 2024xxxxxxxxxxxxxxxxxxxxxxxx;" ``` -------------------------------- ### Count Rows in a Table Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Calculates the total number of rows in a table. ```sql select count(*) from my_table; ``` -------------------------------- ### Drop Function Source: https://github.com/aliyun/aliyun-odps-console/blob/release/0.56.x/README.md Removes a user-defined function from the MaxCompute project. ```sql drop function my_func; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.