Console

Last Updated: Sep 15, 2017

The latest ODPS service provides a new version of the client, compared with the old version, the new client has the following improvements:

  • You do not need to enter a command shell to execute a specified command. For example, you can enter the client and run SQL comamnds and security commands directly in new version. You do not need to enter SQL/Security shell at first and run corresponding commands.
  • The commands of new version is more closed to Hive commands. Most of comnands are compatible with Hive.

Besides, you must note:

  • This document is a part of User Manual for the client in ODPS. It describes how to use basic functions of ODPS by using the command lines of the client.
  • Do not perform the analysis operation based on the output format of the client. The output format of the client is not ensured for forward compatibility. Clients in different versions are different in their command formats and behaviors.
  • ODPS client is a java program and can run only in the JRE environment. Therefore, it is required to download and install JRE 1.6 version.
  • If you need to learn about the use method of the client, refer to Quick Start.

Download and Installation

To downloa ODPS client, please click on Here.

Depress the downloaded file and you can find the following four folders:

  1. bin/ conf/ lib/ plugins/

There is a file named odps_conf.ini in ‘conf’. Edit this file and fill in related information:

  1. project_name=
  2. access_id=<accessid>
  3. access_key=<accesskey>
  4. end_point=http://xxxx

Note:

  • Replace the access_id and access_key with the access_id and access_key applied from www.aliyun.com.
  • If you often use a project, you can add the name of this project behind of “project_name=”, which can avoid executing “use project_name;” command when entering the client.
  • end_point. The access URL differs for different regions. For details, refer to Access domains and data centers.

After the configuration file has been modified, run ‘odpscmd’ in bin directory. (If the OS is Linux, run ‘./bin/odpscmd’; if the OS is Windows, run ‘./bin/odpscmd.bat’.)Now you can run ODPS commands:

  1. odps@ test_project> whoami;
  2. Name: ALIYUN$test_user@aliyun.com
  3. End_Point: http://service.ap-southeast-1.maxcompute.aliyun.com
  4. Project: test_project

Get Help

View the information about help. Commnd Format:

  1. odps@ >./bin/odpscmd -h;

Or you can type “h” or “help” in an interactive mode. (Case insensitive)

Starting Parameters

When starting the client, you can specify a series of parameters:

  1. Usage: odpscmd [OPTION]...
  2. where options include:
  3. --help (-h)for help
  4. --project=<prj_name> use project
  5. --endpoint=<http://host:port> set endpoint
  6. -u <user_name> -p <password> user name and password
  7. -k <n> will skip begining queries and start from specified position
  8. -r <n> set retry times
  9. -f <"file_path;"> execute command in file
  10. -e <"command;[command;]..."> execute command, include sql command
  11. -C will display job counters

Example: (take ‘-f’ as an example)

  • Prepare the local script file ‘script.txt’. Suppose that the file is located in the disk D and the content is shown as follows:
  1. DROP TABLE IF EXISTS test_table_mj;
  2. CREATE TABLE test_table_mj (id string, name string);
  3. DROP TABLE test_table_mj;
  • Running Command:
  1. odpscmd\bin>odpscmd -f d:/script.txt;
  • Display the execution result:
  1. ID = 20150528122432906gux77io3
  2. Log view:
  3. http://webconsole.odps.aliyun-inc.com:8080/logview/?h=http://service-corp.odps.aliyun-inc.com/api&p=odps_public_dev&i=2015052
  4. 8122432906gux77io3&token=RnlrSzJoL242YW43dFFIc1dmb1ZWZzFxQ1RFPSxPRFBTX09CTzoxMDcwMDI1NjI3ODA1NjI5LDE0MzM0MjA2NzMseyJTdGF0ZW1l
  5. bnQiOlt7IkFjdGlvbiI6WyJvZHBzOlJlYWQiXSwiRWZmZWN0IjoiQWxsb3ciLCJSZXNvdXJjZSI6WyJhY3M6b2RwczoqOnByb2plY3RzL29kcHNfcHVibGljX2Rld
  6. i9pbnN0YW5jZXMvMjAxNTA1MjgxMjI0MzI5MDZndXg3N2lvMyJdfV0sIlZlcnNpb24iOiIxIn0=
  7. OK
  8. ID = 20150528122439318gcmkk6u1
  9. Log view:
  10. http://webconsole.odps.aliyun-inc.com:8080/logview/?h=http://service-corp.odps.aliyun-inc.com/api&p=odps_public_dev&i=2015052
  11. 8122439318gcmkk6u1&token=dSt0RXdlV0M5YjZET2I1MnJuUFkzWDN1aWpzPSxPRFBTX09CTzoxMDcwMDI1NjI3ODA1NjI5LDE0MzM0MjA2ODAseyJTdGF0ZW1l
  12. bnQiOlt7IkFjdGlvbiI6WyJvZHBzOlJlYWQiXSwiRWZmZWN0IjoiQWxsb3ciLCJSZXNvdXJjZSI6WyJhY3M6b2RwczoqOnByb2plY3RzL29kcHNfcHVibGljX2Rld
  13. i9pbnN0YW5jZXMvMjAxNTA1MjgxMjI0MzkzMThnY21razZ1MSJdfV0sIlZlcnNpb24iOiIxIn0=
  14. OK
  15. ID = 20150528122440389g98cmlmf
  16. Log view:
  17. http://webconsole.odps.aliyun-inc.com:8080/logview/?h=http://service-corp.odps.aliyun-inc.com/api&p=odps_public_dev&i=2015052
  18. 8122440389g98cmlmf&token=NWlwL0EvQThxUXhzcTRERDc5NFg0b2IxZ3QwPSxPRFBTX09CTzoxMDcwMDI1NjI3ODA1NjI5LDE0MzM0MjA2ODAseyJTdGF0ZW1l
  19. bnQiOlt7IkFjdGlvbiI6WyJvZHBzOlJlYWQiXSwiRWZmZWN0IjoiQWxsb3ciLCJSZXNvdXJjZSI6WyJhY3M6b2RwczoqOnByb2plY3RzL29kcHNfcHVibGljX2Rld
  20. i9pbnN0YW5jZXMvMjAxNTA1MjgxMjI0NDAzODlnOThjbWxtZiJdfV0sIlZlcnNpb24iOiIxIn0=
  21. OK

Interactive Mode

Directly running the client will enter the interactive mode.

  1. [admin: ~]$odpscmd
  2. Aliyun ODPS Command Line Tool
  3. Version 1.0
  4. @Copyright 2012 Alibaba Cloud Computing Co., Ltd. All rights reserved.
  5. odps@ odps> INSERT OVERWRITE TABLE DUAL SELECT * FROM DUAL;

Input the command at the cursor position (take a semicolon as a statement end mark) and press Enter to run.

Continuous Running

  • When you use ‘-e’ or ‘-f’ option to run command, you can specify the parameter ‘-k’ if there are multiple statements and you want to start running from a middle statement, which indicates ignoring the previous statements and running from the specified position. If the specified parameter <= 0, start running from the first statement.
  • Each statement seperated by a semicolon is considered as a valid statement. The statements which runs successfully or fail to run will be printed at running time.
  • For example, there are three SQL statements in the file ‘/tmp/dual.sql’:
  1. drop table dual;
  2. create table dual (dummy string);
  3. insert overwrite table dual select count(*) from dual;

To ignore the first two statements:

  1. odpscmd k 3 f dual.sql

Get Current Login User

Command Format:

  1. whoami;

Use Example:

  1. odps@ hiveut>whoami;
  2. Name: odpstest@aliyun.com
  3. ID: 1090142773636588
  4. End_Point: http://10.249.215.1/odps_debug1
  5. Project: lijunsecuritytest

Use: get the aliyun account and end point configuration of current log user.

Quit

Command:

  1. odps@ > quit;
  2. or q;
Thank you! We've received your feedback.