Apache Tajo - Shell Commands



In this chapter, we will understand the Tajo Shell commands in detail.

To execute the Tajo shell commands, you need to start the Tajo server and the Tajo shell using the following commands −

Start server

$ bin/start-tajo.sh 

Start Shell

$ bin/tsql 

The above commands are now ready for execution.

Meta Commands

Let us now discuss the Meta Commands. Tsql meta commands start with a backslash (‘\’).

Help Command

“\?” Command is used to show the help option.

Query

default> \? 

Result

The above \? Command list out all the basic usage options in Tajo. You will receive the following output −

Command

List Database

To list out all the databases in Tajo, use the following command −

Query

default> \l 

Result

You will receive the following output −

information_schema 
default

At present, we have not created any database so it shows two built in Tajo databases.

Current Database

\c option is used to display the current database name.

Query

default> \c

Result

You are now connected to database "default" as user “username”.

List out Built-in Functions

To list out all the built-in function, type the query as follows −

Query

default> \df 

Result

You will receive the following output −

List out Builtin Functions

Describe Function

\df function name − This query returns the complete description of the given function.

Query

default> \df sqrt 

Result

You will receive the following output −

Describe Function

Quit Terminal

To quit the terminal, type the following query −

Query

default> \q 

Result

You will receive the following output −

bye! 

Admin Commands

Tajo shell provides \admin option to list out all the admin features.

Query

default> \admin 

Result

You will receive the following output −

Admin Commands

Cluster Info

To display the cluster information in Tajo, use the following query

Query

default> \admin -cluster 

Result

You will receive the following output −

Cluster Info

Show master

The following query displays the current master information.

Query

default> \admin -showmasters 

Result

localhost 

Similarly, you can try other admin commands.

Session Variables

The Tajo client connects to the Master via a unique session id. The session is live until the client is disconnected or expires.

The following command is used to list out all session variables.

Query

default> \set 

Result

'SESSION_LAST_ACCESS_TIME' = '1470206387146' 
'CURRENT_DATABASE' = 'default' 
‘USERNAME’ = 'user' 
'SESSION_ID' = 'c60c9b20-dfba-404a-822f-182bc95d6c7c' 
'TIMEZONE' = 'Asia/Kolkata' 
'FETCH_ROWNUM' = '200' 
‘COMPRESSED_RESULT_TRANSFER' = 'false' 

The \set key val will set the session variable named key with the value val. For example,

Query

default> \set ‘current_database’='default' 

Result

usage: \set [[NAME] VALUE] 

Here, you can assign the key and value in the \set command. If you need to revert the changes then use the \unset command.

Advertisements