TAJO-1062: Update TSQL documentation
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/0e63abc7 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/0e63abc7 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/0e63abc7 Branch: refs/heads/block_iteration Commit: 0e63abc71723c4c22f2c591ae60d892a9707973f Parents: 52a9421 Author: Jaehwa Jung <[email protected]> Authored: Wed Sep 24 10:48:09 2014 +0900 Committer: Jaehwa Jung <[email protected]> Committed: Wed Sep 24 10:48:09 2014 +0900 ---------------------------------------------------------------------- tajo-docs/src/main/sphinx/cli.rst | 165 +--------- .../src/main/sphinx/tsql/admin_command.rst | 60 ++++ tajo-docs/src/main/sphinx/tsql/back_command.rst | 28 ++ tajo-docs/src/main/sphinx/tsql/dfs_command.rst | 26 ++ tajo-docs/src/main/sphinx/tsql/execute_file.rst | 63 ++++ tajo-docs/src/main/sphinx/tsql/intro.rst | 41 +++ tajo-docs/src/main/sphinx/tsql/meta_command.rst | 313 +++++++++++++++++++ .../src/main/sphinx/tsql/single_command.rst | 25 ++ tajo-docs/src/main/sphinx/tsql/variables.rst | 66 ++++ 9 files changed, 634 insertions(+), 153 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/cli.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/cli.rst b/tajo-docs/src/main/sphinx/cli.rst index 95f8d5c..6684508 100644 --- a/tajo-docs/src/main/sphinx/cli.rst +++ b/tajo-docs/src/main/sphinx/cli.rst @@ -1,159 +1,18 @@ ***************************** -Tajo Shell (TSQL) +Command-line Interface ***************************** -========== -Synopsis -========== +Tajo provides a shell utility for users. It is the command-line interface (CLI). Using the CLI, users can create or drop tables, inspect schema and query tables, etc. For reference, we named its name to tsql. -.. code-block:: bash +.. toctree:: + :maxdepth: 1 - bin/tsql [options] [database name] + tsql/intro + tsql/single_command + tsql/execute_file + tsql/back_command + tsql/meta_command + tsql/dfs_command + tsql/variables + tsql/admin_command -If a *database_name* is given, tsql connects to the database at startup time. Otherwise, tsql connects to ``default`` database. - -Options - -* ``-c "quoted sql"`` : Execute quoted sql statements, and then the shell will exist. -* ``-f filename (--file filename)`` : Use the file named filename as the source of commands instead of interactive shell. -* ``-h hostname (--host hostname)`` : Specifies the host name of the machine on which the Tajo master is running. -* ``-p port (--port port)`` : Specifies the TCP port. If it is not set, the port will be 26002 in default. - -=================== -Entering tsql shell -=================== - -If the hostname and the port num are not given, tsql will try to connect the Tajo master specified in ${TAJO_HOME}/conf/tajo-site.xml. :: - - bin/tsql - - default> - -If you want to connect a specified TajoMaster, you should use '-h' and (or) 'p' options as follows: :: - - bin/tsql -h localhost -p 9004 - - default> - -The prompt indicates the current database. - -=================== - Meta Commands -=================== - -In tsql, anything command that begins with an unquoted backslash ('\') is a tsql meta-command that is processed by tsql itself. - -In the current implementation, there are meta commands as follows: :: - - default> \? - - General - \copyright show Apache License 2.0 - \version show Tajo version - \? show help - \q quit tsql - - - Informational - \l list databases - \c show current database - \c [DBNAME] connect to new database - \d list tables - \d [TBNAME] describe table - \df list functions - \df NAME describe function - - - Variables - \set [[NAME] [VALUE] set session variable or list session variables - \unset NAME unset session variable - - - Documentations - tsql guide http://tajo.apache.org/docs/0.8.0/cli.html - Query language http://tajo.apache.org/docs/0.8.0/sql_language.html - Functions http://tajo.apache.org/docs/0.8.0/functions.html - Backup & restore http://tajo.apache.org/docs/0.8.0/backup_and_restore.html - Configuration http://tajo.apache.org/docs/0.8.0/configuration.html - ------------------------------------------------ -Basic usages ------------------------------------------------ - -``\l`` command shows a list of all databases. - -.. code-block:: sql - - default> \l - default - tpch - work1 - default> - -``\d`` command shows a list of tables in the current database as follows: .. - - default> \d - customer - lineitem - nation - orders - part - partsupp - region - supplier - -``\d [table name]`` command also shows a table description. - - default> \d orders - - table name: orders - table path: hdfs:/xxx/xxx/tpch/orders - store type: CSV - number of rows: 0 - volume (bytes): 172.0 MB - schema: - o_orderkey INT8 - o_custkey INT8 - o_orderstatus TEXT - o_totalprice FLOAT8 - o_orderdate TEXT - o_orderpriority TEXT - o_clerk TEXT - o_shippriority INT4 - o_comment TEXT - -The prompt ``default>`` indicates the current database. Basically, all SQL statements and meta commands work in the current database. Also, you can change the current database with ``\c`` command. - -.. code-block:: sql - - default> \c work1 - You are now connected to database "test" as user "hyunsik". - work1> - ------------------------------------------------ -Session Variables ------------------------------------------------ - -Each client connection to TajoMaster creates a unique session, and the client and TajoMaster uses the session until disconnect. A session provides session variables which are used for various configs per session. - -``tsql`` provides the meta command ``\set`` to manipulate session variables. Just ``\set`` command shows all session variables. :: - - default> \set - 'name1'='val1' - 'name2'='val2' - 'name3'='val3' - ... - -``\set key val`` will set the session variable named *key* with the value *val*. :: - - default> \set - 'CURRENT_DATABASE'='default' - - default> \set key1 val1 - - default> \set - 'CURRENT_DATABASE'='default' - 'key1'='val1' - - -Also, ``\unset key`` will unset the session variable named *key*. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/admin_command.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/admin_command.rst b/tajo-docs/src/main/sphinx/tsql/admin_command.rst new file mode 100644 index 0000000..cffa9e6 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/admin_command.rst @@ -0,0 +1,60 @@ +********************************* +Administration Commands +********************************* + + +========== +Synopsis +========== + +Tsql provides commands for administrator as follows as follows: + +.. code-block:: sql + + default> \admin; + usage: admin [options] + -cluster Show Cluster Info + -desc Show Query Description + -h,--host <arg> Tajo server host + -kill <arg> Kill a running query + -list Show Tajo query list + -p,--port <arg> Tajo server port + -showmasters gets list of tajomasters in the cluster + + +----------------------------------------------- +Basic usages +----------------------------------------------- + +``-list`` options shows a list of all running queries as follows: :: + + default> \admin -list + QueryId State StartTime Query + -------------------- ------------------- ------------------- ----------------------------- + q_1411357607375_0006 QUERY_RUNNING 2014-09-23 07:19:40 select count(*) from lineitem + + +``-desc`` options shows a detailed description of a specified running query s as follows: :: + + default> \admin -desc q_1411357607375_0006 + Id: 1 + Query Id: q_1411357607375_0006 + Started Time: 2014-09-23 07:19:40 + Query State: QUERY_RUNNING + Execution Time: 20.0 sec + Query Progress: 0.249 + Query Statement: + select count(*) from lineitem + + +``-kill`` options kills a specified running queries as follows: :: + + default> \admin -kill q_1411357607375_0007 + q_1411357607375_0007 is killed successfully. + + + +``-showmasters`` options shows a list of all tajo masters as follows: :: + + default> \admin -showmasters + grtajo01 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/back_command.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/back_command.rst b/tajo-docs/src/main/sphinx/tsql/back_command.rst new file mode 100644 index 0000000..56bdd71 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/back_command.rst @@ -0,0 +1,28 @@ +********************************* +Executing as background process +********************************* + + +If you execute tsql as background process, tsql will exit before execute a query because of jconsole architecture as +follows: + + .. code-block:: sql + + $ bin/tsql -f aggregation.sql & + [1] 19303 + $ + [1]+ Stopped ./bin/tsql -f aggregation.sql + + +To avoid above problem, tajo provides the -B command as follows: + +.. code-block:: sql + + $ bin/tsql -B -f aggregation.sql & + [2] 19419 + Progress: 0%, response time: 0.218 sec + Progress: 0%, response time: 0.22 sec + Progress: 0%, response time: 0.421 sec + Progress: 0%, response time: 0.823 sec + Progress: 0%, response time: 1.425 sec + Progress: 1%, response time: 2.227 sec \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/dfs_command.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/dfs_command.rst b/tajo-docs/src/main/sphinx/tsql/dfs_command.rst new file mode 100644 index 0000000..b6cb463 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/dfs_command.rst @@ -0,0 +1,26 @@ +********************************* +Executing HDFS commands +********************************* + +You can run the hadoop dfs commands(FsShell) within tsql. ``\dfs`` command allows the hadoop dfs commands. If you want to use this command, you just specify FsShell arguments and add the semicolon at the end as follows: + +.. code-block:: sql + + default> \dfs -ls /; + Found 3 items + drwxr-xr-x - tajo supergroup 0 2014-08-14 04:04 /tajo + drwxr-xr-x - tajo supergroup 0 2014-09-04 02:20 /tmp + drwxr-xr-x - tajo supergroup 0 2014-09-16 13:41 /user + + default> \dfs -ls /tajo; + Found 2 items + drwxr-xr-x - tajo supergroup 0 2014-08-14 04:04 /tajo/system + drwxr-xr-x - tajo supergroup 0 2014-08-14 04:15 /tajo/warehouse + + default> \dfs -mkdir /tajo/temp; + + default> \dfs -ls /tajo; + Found 3 items + drwxr-xr-x - tajo supergroup 0 2014-08-14 04:04 /tajo/system + drwxr-xr-x - tajo supergroup 0 2014-09-23 06:48 /tajo/temp + drwxr-xr-x - tajo supergroup 0 2014-08-14 04:15 /tajo/warehouse \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/execute_file.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/execute_file.rst b/tajo-docs/src/main/sphinx/tsql/execute_file.rst new file mode 100644 index 0000000..014f513 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/execute_file.rst @@ -0,0 +1,63 @@ +********************************* +Executing Queries from Files +********************************* + + +----------------------------------------------- +Basic usages +----------------------------------------------- + + +Tajo can execute more queries that were saved to a file using the -f file argument as follows: + +.. code-block:: sql + + $ cat aggregation.sql + select count(*) from table1; + select sum(score) from table1; + + $ bin/tsql -f aggregation.sql + Progress: 0%, response time: 0.216 sec + Progress: 0%, response time: 0.217 sec + Progress: 100%, response time: 0.331 sec + ?count + ------------------------------- + 5 + (1 rows, 0.331 sec, 2 B selected) + Progress: 0%, response time: 0.203 sec + Progress: 0%, response time: 0.204 sec + Progress: 50%, response time: 0.406 sec + Progress: 100%, response time: 0.769 sec + ?sum + ------------------------------- + 15.0 + (1 rows, 0.769 sec, 5 B selected) + + + +----------------------------------------------- +Setting parameter value in SQL file +----------------------------------------------- + +If you wish to set a parameter value in the SQL file, you can set with the -param key=value option.When you use this feature, you have to use the parameter in the file as follows: + +.. code-block:: sql + + ${paramter name} + + +You have to put the parameter name in braces and you must use the $ symbol for the prefix as follows: + +.. code-block:: sql + + $ cat aggregation.sql + select count(*) from table1 where id = ${p_id}; + + $ bin/tsql -param p_id=1 -f aggregation.sql + Progress: 0%, response time: 0.216 sec + Progress: 0%, response time: 0.217 sec + Progress: 100%, response time: 0.331 sec + ?count + ------------------------------- + 1 + (1 rows, 0.331 sec, 2 B selected) http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/intro.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/intro.rst b/tajo-docs/src/main/sphinx/tsql/intro.rst new file mode 100644 index 0000000..badaead --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/intro.rst @@ -0,0 +1,41 @@ +***************************** +Introducing to TSQL +***************************** + +========== +Synopsis +========== + +.. code-block:: bash + + bin/tsql [options] [database name] + +If a *database_name* is given, tsql connects to the database at startup time. Otherwise, tsql connects to ``default`` database. + +Options + +* ``-c "quoted sql"`` : Execute quoted sql statements, and then the shell will exist. +* ``-f filename (--file filename)`` : Use the file named filename as the source of commands instead of interactive shell. +* ``-h hostname (--host hostname)`` : Specifies the host name of the machine on which the Tajo master is running. +* ``-p port (--port port)`` : Specifies the TCP port. If it is not set, the port will be 26002 in default. +* ``-conf configuration (--conf configuration)`` : Setting tajo configuration value. +* ``-param parameter (--param parameter)`` : Use a parameter value in SQL file. +* ``-B (--background)`` : Execute as background process. + +=================== +Entering tsql shell +=================== + +If the hostname and the port num are not given, tsql will try to connect the Tajo master specified in ${TAJO_HOME}/conf/tajo-site.xml. :: + + bin/tsql + + default> + +If you want to connect a specified TajoMaster, you should use '-h' and (or) 'p' options as follows: :: + + bin/tsql -h localhost -p 9004 + + default> + +The prompt indicates the current database. http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/meta_command.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/meta_command.rst b/tajo-docs/src/main/sphinx/tsql/meta_command.rst new file mode 100644 index 0000000..b183cf5 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/meta_command.rst @@ -0,0 +1,313 @@ +********************************* +Meta Commands +********************************* + + +In tsql, anything command that begins with an unquoted backslash ('\') is a tsql meta-command that is processed by tsql itself. + +In the current implementation, there are meta commands as follows: :: + + default> \? + + + General + \copyright show Apache License 2.0 + \version show Tajo version + \? show help + \? [COMMAND] show help of a given command + \help alias of \? + \q quit tsql + + + Informational + \l list databases + \c show current database + \c [DBNAME] connect to new database + \d list tables + \d [TBNAME] describe table + \df list functions + \df NAME describe function + + + Tool + \! execute a linux shell command + \dfs execute a dfs command + \admin execute tajo admin command + + + Variables + \set [[NAME] [VALUE] set session variable or list session variables + \unset NAME unset session variable + + + Documentations + tsql guide http://tajo.apache.org/docs/current/cli.html + Query language http://tajo.apache.org/docs/current/sql_language.html + Functions http://tajo.apache.org/docs/current/functions.html + Backup & restore http://tajo.apache.org/docs/current/backup_and_restore.html + Configuration http://tajo.apache.org/docs/current/configuration.html + +----------------------------------------------- +Basic usages +----------------------------------------------- + +``\l`` command shows a list of all databases as follows: :: + + default> \l + default + tpch + work1 + default> + + + +``\d`` command shows a list of tables in the current database as follows: :: + + default> \d + customer + lineitem + nation + orders + part + partsupp + region + supplier + + +``\d [table name]`` command also shows a table description as follows: :: + + default> \d orders + + table name: orders + table path: hdfs:/xxx/xxx/tpch/orders + store type: CSV + number of rows: 0 + volume (bytes): 172.0 MB + schema: + o_orderkey INT8 + o_custkey INT8 + o_orderstatus TEXT + o_totalprice FLOAT8 + o_orderdate TEXT + o_orderpriority TEXT + o_clerk TEXT + o_shippriority INT4 + o_comment TEXT + + + +The prompt ``default>`` indicates the current database. Basically, all SQL statements and meta commands work in the current database. Also, you can change the current database with ``\c`` command. + +.. code-block:: sql + + default> \c work1 + You are now connected to database "test" as user "hyunsik". + work1> + + +``\df`` command shows a list of all buit-in function as follows: :: + + default> \df + Name | Result type | Argument types | Description | Type + -----------------+-----------------+-----------------------+-----------------------------------------------+----------- + abs | INT4 | INT4 | Absolute value | GENERAL + abs | INT8 | INT8 | Absolute value | GENERAL + abs | FLOAT4 | FLOAT4 | Absolute value | GENERAL + abs | FLOAT8 | FLOAT8 | Absolute value | GENERAL + acos | FLOAT8 | FLOAT4 | Inverse cosine. | GENERAL + acos | FLOAT8 | FLOAT8 | Inverse cosine. | GENERAL + add_days | TIMESTAMP | DATE,INT2 | Return date value which is added with given pa| GENERAL + add_days | TIMESTAMP | DATE,INT4 | Return date value which is added with given pa| GENERAL + add_days | TIMESTAMP | DATE,INT8 | Return date value which is added with given pa| GENERAL + add_days | TIMESTAMP | TIMESTAMP,INT2 | Return date value which is added with given pa| GENERAL + add_days | TIMESTAMP | TIMESTAMP,INT4 | Return date value which is added with given pa| GENERAL + add_days | TIMESTAMP | TIMESTAMP,INT8 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | DATE,INT2 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | DATE,INT4 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | DATE,INT8 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | TIMESTAMP,INT2 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | TIMESTAMP,INT4 | Return date value which is added with given pa| GENERAL + add_months | TIMESTAMP | TIMESTAMP,INT8 | Return date value which is added with given pa| GENERAL + ascii | INT4 | TEXT | ASCII code of the first character of the argum| GENERAL + asin | FLOAT8 | FLOAT4 | Inverse sine. | GENERAL + asin | FLOAT8 | FLOAT8 | Inverse sine. | GENERAL + atan | FLOAT8 | FLOAT4 | Inverse tangent. | GENERAL + atan | FLOAT8 | FLOAT8 | Inverse tangent. | GENERAL + atan2 | FLOAT8 | FLOAT4,FLOAT4 | Inverse tangent of y/x. | GENERAL + atan2 | FLOAT8 | FLOAT8,FLOAT8 | Inverse tangent of y/x. | GENERAL + avg | FLOAT8 | INT8 | the mean of a set of numbers | AGGREGATIO + avg | FLOAT8 | FLOAT4 | The mean of a set of numbers. | AGGREGATIO + avg | FLOAT8 | INT4 | the mean of a set of numbers. | AGGREGATIO + avg | FLOAT8 | FLOAT8 | The mean of a set of numbers. | AGGREGATIO + bit_length | INT4 | TEXT | Number of bits in string | GENERAL + btrim | TEXT | TEXT | Remove the longest string consisting only of | GENERAL + btrim | TEXT | TEXT,TEXT | Remove the longest string consisting only of | GENERAL + cbrt | FLOAT8 | FLOAT4 | Cube root | GENERAL + cbrt | FLOAT8 | FLOAT8 | Cube root | GENERAL + ceil | INT8 | FLOAT4 | Smallest integer not less than argument. | GENERAL + ceil | INT8 | FLOAT8 | Smallest integer not less than argument. | GENERAL + ceiling | INT8 | FLOAT4 | Smallest integer not less than argument. | GENERAL + ceiling | INT8 | FLOAT8 | Smallest integer not less than argument. | GENERAL + char_length | INT4 | TEXT | Number of characters in string | GENERAL + character_length| INT4 | TEXT | Number of characters in string | GENERAL + chr | CHAR | INT4 | Character with the given code. | GENERAL + coalesce | BOOLEAN | BOOLEAN,BOOLEAN_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | INT8 | INT8_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | FLOAT8 | FLOAT8_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | TEXT | TEXT_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | DATE | DATE_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | TIME | TIME_ARRAY | Returns the first of its arguments that is not| GENERAL + coalesce | TIMESTAMP | TIMESTAMP_ARRAY | Returns the first of its arguments that is not| GENERAL + concat | TEXT | TEXT,TEXT_ARRAY | Concatenate all arguments. | GENERAL + concat_ws | TEXT | TEXT,TEXT,TEXT_ARRAY | Concatenate all but first arguments with separ| GENERAL + cos | FLOAT8 | FLOAT4 | Cosine. | GENERAL + cos | FLOAT8 | FLOAT8 | Cosine. | GENERAL + count | INT8 | ANY | The number of rows for which the supplied exp| DISTINCT_A + count | INT8 | | the total number of retrieved rows | AGGREGATIO + count | INT8 | ANY | The number of retrieved rows for which the sup| AGGREGATIO + current_date | DATE | | Get current date. Result is DATE type. | GENERAL + current_time | TIME | | Get current time. Result is TIME type. | GENERAL + date | INT8 | INT4 | Extracts the date part of the date or datetime| GENERAL + date_part | FLOAT8 | TEXT,TIME | Extract field from time | GENERAL + date_part | FLOAT8 | TEXT,TIMESTAMP | Extract field from timestamp | GENERAL + date_part | FLOAT8 | TEXT,DATE | Extract field from date | GENERAL + decode | TEXT | TEXT,TEXT | Decode binary data from textual representation| GENERAL + degrees | FLOAT8 | FLOAT4 | Radians to degrees | GENERAL + degrees | FLOAT8 | FLOAT8 | Radians to degrees | GENERAL + digest | TEXT | TEXT,TEXT | Calculates the Digest hash of string | GENERAL + div | INT8 | INT8,INT8 | Division(integer division truncates results) | GENERAL + div | INT8 | INT8,INT4 | Division(integer division truncates results) | GENERAL + div | INT8 | INT4,INT8 | Division(integer division truncates results) | GENERAL + div | INT8 | INT4,INT4 | Division(integer division truncates results) | GENERAL + encode | TEXT | TEXT,TEXT | Encode binary data into a textual representati| GENERAL + exp | FLOAT8 | FLOAT4 | Exponential | GENERAL + exp | FLOAT8 | FLOAT8 | Exponential | GENERAL + find_in_set | INT4 | TEXT,TEXT | Returns the first occurrence of str in str_arr| GENERAL + floor | INT8 | FLOAT4 | Largest integer not greater than argument. | GENERAL + floor | INT8 | FLOAT8 | Largest integer not greater than argument. | GENERAL + geoip_country_co| TEXT | TEXT | Convert an ipv4 address string to a geoip coun| GENERAL + geoip_country_co| TEXT | INET4 | Convert an ipv4 address to a geoip country cod| GENERAL + geoip_in_country| BOOLEAN | TEXT,TEXT | If the given country code is same with the cou| GENERAL + geoip_in_country| BOOLEAN | INET4,TEXT | If the given country code is same with the cou| GENERAL + initcap | TEXT | TEXT | Convert the first letter of each word to upper| GENERAL + left | TEXT | TEXT,INT4 | First n characters in the string. | GENERAL + length | INT4 | TEXT | Number of characters in string. | GENERAL + locate | INT4 | TEXT,TEXT | Location of specified substring | GENERAL + locate | INT4 | TEXT,TEXT,INT4 | Location of specified substring | GENERAL + lower | TEXT | TEXT | Convert string to lower case | GENERAL + lpad | TEXT | TEXT,INT4 | Fill up the string to length length by prepend| GENERAL + lpad | TEXT | TEXT,INT4,TEXT | Fill up the string to length length by prepend| GENERAL + ltrim | TEXT | TEXT | Remove the longest string containing only char| GENERAL + ltrim | TEXT | TEXT,TEXT | Remove the longest string containing only char| GENERAL + max | INT4 | INT4 | the maximum value of expr | AGGREGATIO + max | INT8 | INT8 | the maximum value of expr | AGGREGATIO + max | FLOAT4 | FLOAT4 | the maximum value of expr | AGGREGATIO + max | FLOAT8 | FLOAT8 | the maximum value of expr | AGGREGATIO + max | TEXT | TEXT | the maximum value of expr | AGGREGATIO + md5 | TEXT | TEXT | Calculates the MD5 hash of string | GENERAL + min | INT4 | INT4 | the minimum value of expr | AGGREGATIO + min | INT8 | INT8 | the minimum value of expr | AGGREGATIO + min | FLOAT4 | FLOAT4 | the minimum value of expr | AGGREGATIO + min | FLOAT8 | FLOAT8 | the minimum value of expr | AGGREGATIO + min | TEXT | TEXT | the minimum value of expr | AGGREGATIO + mod | INT8 | INT8,INT8 | Remainder of y/x | GENERAL + mod | INT8 | INT8,INT4 | Remainder of y/x | GENERAL + mod | INT8 | INT4,INT8 | Remainder of y/x | GENERAL + mod | INT8 | INT4,INT4 | Remainder of y/x | GENERAL + now | TIMESTAMP | | Get current time. Result is TIMESTAMP type. | GENERAL + octet_length | INT4 | TEXT | Number of bytes in string. | GENERAL + pi | FLOAT8 | | "??" constant | GENERAL + pow | FLOAT8 | FLOAT4,FLOAT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT4,FLOAT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT8,FLOAT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT8,FLOAT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT4,INT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT4,INT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT8,INT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT8,INT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT4,FLOAT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT4,FLOAT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT8,FLOAT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | INT8,FLOAT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT4,INT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT4,INT8 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT8,INT4 | x raised to the power of y | GENERAL + pow | FLOAT8 | FLOAT8,INT8 | x raised to the power of y | GENERAL + quote_ident | TEXT | TEXT | Return the given string suitably quoted to be | GENERAL + radians | FLOAT8 | FLOAT8 | Degrees to radians | GENERAL + radians | FLOAT8 | FLOAT4 | Degrees to radians | GENERAL + random | INT4 | INT4 | A pseudorandom number | GENERAL + rank | INT8 | | The number of rows for which the supplied exp| WINDOW + regexp_replace | TEXT | TEXT,TEXT,TEXT | Replace substring(s) matching a POSIX regular| GENERAL + repeat | TEXT | TEXT,INT4 | Repeat string the specified number of times. | GENERAL + reverse | TEXT | TEXT | Reverse str | GENERAL + right | TEXT | TEXT,INT4 | Last n characters in the string | GENERAL + round | INT8 | FLOAT4 | Round to nearest integer. | GENERAL + round | INT8 | FLOAT8 | Round to nearest integer. | GENERAL + round | INT8 | INT4 | Round to nearest integer. | GENERAL + round | INT8 | INT8 | Round to nearest integer. | GENERAL + round | FLOAT8 | FLOAT8,INT4 | Round to s decimalN places. | GENERAL + round | FLOAT8 | INT8,INT4 | Round to s decimalN places. | GENERAL + row_number | INT8 | | the total number of retrieved rows | WINDOW + rpad | TEXT | TEXT,INT4 | Fill up the string to length length by appendi| GENERAL + rpad | TEXT | TEXT,INT4,TEXT | Fill up the string to length length by appendi| GENERAL + rtrim | TEXT | TEXT | Remove the longest string containing only cha| GENERAL + rtrim | TEXT | TEXT,TEXT | Remove the longest string containing only cha| GENERAL + sign | FLOAT8 | FLOAT8 | sign of the argument (-1, 0, +1) | GENERAL + sign | FLOAT8 | FLOAT4 | sign of the argument (-1, 0, +1) | GENERAL + sign | FLOAT8 | INT8 | sign of the argument (-1, 0, +1) | GENERAL + sign | FLOAT8 | INT4 | sign of the argument (-1, 0, +1) | GENERAL + sin | FLOAT8 | FLOAT4 | Sine. | GENERAL + sin | FLOAT8 | FLOAT8 | Sine. | GENERAL + sleep | INT4 | INT4 | sleep for seconds | GENERAL + split_part | TEXT | TEXT,TEXT,INT4 | Split string on delimiter and return the given| GENERAL + sqrt | FLOAT8 | FLOAT8 | Square root | GENERAL + sqrt | FLOAT8 | FLOAT4 | Square root | GENERAL + strpos | INT4 | TEXT,TEXT | Location of specified substring. | GENERAL + strposb | INT4 | TEXT,TEXT | Binary location of specified substring. | GENERAL + substr | TEXT | TEXT,INT4 | Extract substring. | GENERAL + substr | TEXT | TEXT,INT4,INT4 | Extract substring. | GENERAL + sum | INT8 | INT8 | the sum of a distinct and non-null values | DISTINCT_A + sum | INT8 | INT8 | the sum of a set of numbers | AGGREGATIO + sum | INT8 | INT4 | the sum of a set of numbers | AGGREGATIO + sum | INT8 | INT4 | the sum of a distinct and non-null values | DISTINCT_A + sum | FLOAT8 | FLOAT8 | the sum of a set of numbers | AGGREGATIO + sum | FLOAT8 | FLOAT4 | the sum of a set of numbers | AGGREGATIO + sum | FLOAT8 | FLOAT4 | the sum of a distinct and non-null values | DISTINCT_A + sum | FLOAT8 | FLOAT8 | the sum of a distinct and non-null values | DISTINCT_A + tan | FLOAT8 | FLOAT4 | Tangent. | GENERAL + tan | FLOAT8 | FLOAT8 | Tangent. | GENERAL + to_bin | TEXT | INT8 | Returns n in binary. | GENERAL + to_bin | TEXT | INT4 | Returns n in binary. | GENERAL + to_char | TEXT | TIMESTAMP,TEXT | Convert time stamp to string. Format should be| GENERAL + to_date | DATE | TEXT,TEXT | Convert string to date. Format should be a SQL| GENERAL + to_hex | TEXT | INT4 | Convert the argument to hexadecimal | GENERAL + to_hex | TEXT | INT8 | Convert the argument to hexadecimal | GENERAL + to_timestamp | TIMESTAMP | TEXT,TEXT | Convert string to time stamp | GENERAL + to_timestamp | TIMESTAMP | INT4 | Convert UNIX epoch to time stamp | GENERAL + to_timestamp | TIMESTAMP | INT8 | Convert UNIX epoch to time stamp | GENERAL + trim | TEXT | TEXT | Remove the longest string consisting only of | GENERAL + trim | TEXT | TEXT,TEXT | Remove the longest string consisting only of | GENERAL + upper | TEXT | TEXT | Convert string to upper case. | GENERAL + utc_usec_to | INT8 | TEXT,INT8 | Extract field from time | GENERAL + utc_usec_to | INT8 | TEXT,INT8,INT4 | Extract field from time | GENERAL + + (181) rows + + +``\df [function name]`` command also shows a function description as follows: :: + + default> \df trim + Name | Result type | Argument types | Description | Type + -----------------+-----------------+-----------------------+-----------------------------------------------+----------- + trim | TEXT | TEXT | Remove the longest string consisting only of | GENERAL + trim | TEXT | TEXT,TEXT | Remove the longest string consisting only of | GENERAL + + (2) rows + + Function: TEXT trim(text) + Description: Remove the longest string consisting only of characters in characters (a space by default) from the start and end of string. + Example: + > SELECT trim('xyxtrimyyx', 'xy'); + trim + http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/single_command.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/single_command.rst b/tajo-docs/src/main/sphinx/tsql/single_command.rst new file mode 100644 index 0000000..93b00c5 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/single_command.rst @@ -0,0 +1,25 @@ +********************************* +Executing a single command +********************************* + + +You may want to run more queries without entering tsql prompt. Tsql provides the -c argument for above +requirement. And tajo assumes that queries separated by semicolon as follows: + +.. code-block:: sql + + $ bin/tsql -c "select count(*) from table1; select sum(score) from table1;" + Progress: 0%, response time: 0.217 sec + Progress: 0%, response time: 0.218 sec + Progress: 100%, response time: 0.317 sec + ?count + ------------------------------- + 5 + (1 rows, 0.317 sec, 2 B selected) + Progress: 0%, response time: 0.202 sec + Progress: 0%, response time: 0.204 sec + Progress: 100%, response time: 0.345 sec + ?sum + ------------------------------- + 15.0 + (1 rows, 0.345 sec, 5 B selected) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/0e63abc7/tajo-docs/src/main/sphinx/tsql/variables.rst ---------------------------------------------------------------------- diff --git a/tajo-docs/src/main/sphinx/tsql/variables.rst b/tajo-docs/src/main/sphinx/tsql/variables.rst new file mode 100644 index 0000000..e859451 --- /dev/null +++ b/tajo-docs/src/main/sphinx/tsql/variables.rst @@ -0,0 +1,66 @@ +********************************* +Session Variables +********************************* + + +Each client connection to TajoMaster creates a unique session, and the client and TajoMaster uses the session until disconnect. A session provides session variables which are used for various configs per session. + +``tsql`` provides the meta command ``\set`` to manipulate session variables. Just ``\set`` command shows all session variables. :: + + default> \set + 'name1'='val1' + 'name2'='val2' + 'name3'='val3' + ... + +``\set key val`` will set the session variable named *key* with the value *val*. :: + + default> \set + 'CURRENT_DATABASE'='default' + + default> \set key1 val1 + + default> \set + 'CURRENT_DATABASE'='default' + 'key1'='val1' + + +Also, ``\unset key`` will unset the session variable named *key*. + + +Now, tajo provides the following session variables. + +* ``DIST_QUERY_BROADCAST_JOIN_THRESHOLD`` +* ``DIST_QUERY_JOIN_TASK_VOLUME`` +* ``DIST_QUERY_SORT_TASK_VOLUME`` +* ``DIST_QUERY_GROUPBY_TASK_VOLUME`` +* ``DIST_QUERY_JOIN_PARTITION_VOLUME`` +* ``DIST_QUERY_GROUPBY_PARTITION_VOLUME`` +* ``DIST_QUERY_TABLE_PARTITION_VOLUME`` +* ``EXECUTOR_EXTERNAL_SORT_BUFFER_SIZE`` +* ``EXECUTOR_HASH_JOIN_SIZE_THRESHOLD`` +* ``EXECUTOR_INNER_HASH_JOIN_SIZE_THRESHOLD`` +* ``EXECUTOR_OUTER_HASH_JOIN_SIZE_THRESHOLD`` +* ``EXECUTOR_GROUPBY_INMEMORY_HASH_THRESHOLD`` +* ``MAX_OUTPUT_FILE_SIZE`` +* ``CODEGEN`` +* ``CLIENT_SESSION_EXPIRY_TIME`` +* ``CLI_MAX_COLUMN`` +* ``CLI_NULL_CHAR`` +* ``CLI_PRINT_PAUSE_NUM_RECORDS`` +* ``CLI_PRINT_PAUSE`` +* ``CLI_PRINT_ERROR_TRACE`` +* ``CLI_OUTPUT_FORMATTER_CLASS`` +* ``CLI_ERROR_STOP`` +* ``TIMEZONE`` +* ``DATE_ORDER`` +* ``CSVFILE_NULL`` +* ``DEBUG_ENABLED`` +* ``TEST_BROADCAST_JOIN_ENABLED`` +* ``TEST_JOIN_OPT_ENABLED`` +* ``TEST_FILTER_PUSHDOWN_ENABLED`` +* ``TEST_MIN_TASK_NUM`` +* ``BEHAVIOR_ARITHMETIC_ABORT`` +* ``RESULT_SET_FETCH_ROWNUM`` + +
