You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by ji...@apache.org on 2015/08/18 03:53:01 UTC

tajo git commit: TAJO-1755: Add documentation for missing built-in functions.

Repository: tajo
Updated Branches:
  refs/heads/master 175f3f016 -> ca7e3fde0


TAJO-1755: Add documentation for missing built-in functions.

Closes #688


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/ca7e3fde
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/ca7e3fde
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/ca7e3fde

Branch: refs/heads/master
Commit: ca7e3fde0f272add2e1db621bc4160804f3d089e
Parents: 175f3f0
Author: Jihoon Son <ji...@apache.org>
Authored: Tue Aug 18 10:53:12 2015 +0900
Committer: Jihoon Son <ji...@apache.org>
Committed: Tue Aug 18 10:53:12 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |   2 +
 tajo-docs/src/main/sphinx/functions.rst         |  25 +-
 .../src/main/sphinx/functions/agg_func.rst      |  91 +++++
 .../functions/data_type_func_and_operators.rst  |  43 +++
 .../functions/datetime_func_and_operators.rst   |  18 +-
 .../src/main/sphinx/functions/json_func.rst     |   8 +-
 .../functions/math_func_and_operators.rst       |  14 +
 .../functions/network_func_and_operators.rst    |   8 +-
 .../functions/string_func_and_operators.rst     | 347 +++++++++++++++++--
 .../src/main/sphinx/functions/window_func.rst   |  47 +++
 .../src/main/sphinx/sql_language/joins.rst      |   2 +-
 .../main/sphinx/sql_language/sql_expression.rst |  14 +-
 12 files changed, 565 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 382787d..f6a489c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -425,6 +425,8 @@ Release 0.11.0 - unreleased
   
   TASKS
 
+    TAJO-1755: Add documentation for missing built-in functions. (jihoon)
+
     TAJO-1750: Upgrade hadoop dependency to 2.7.1. (jinho)
 
     TAJO-1590: Moving to JDK 7. (jinho)

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions.rst b/tajo-docs/src/main/sphinx/functions.rst
index 7e885da..ff753a3 100644
--- a/tajo-docs/src/main/sphinx/functions.rst
+++ b/tajo-docs/src/main/sphinx/functions.rst
@@ -4,19 +4,38 @@ Functions
 
 Tajo provides extensive supports for functions. It includes a lot of built-in functions and user-defined functions which is implemented in Python.
 
-===================
-Built-in Functions
-===================
+==========================
+Built-in Scalar Functions
+==========================
 
 .. toctree::
     :maxdepth: 1
 
+    functions/data_type_func_and_operators
     functions/math_func_and_operators
     functions/string_func_and_operators
     functions/datetime_func_and_operators
     functions/network_func_and_operators
     functions/json_func
 
+================================
+Built-in Aggregation Functions
+================================
+
+.. toctree::
+    :maxdepth: 1
+
+    functions/agg_func
+
+================================
+Built-in Window Functions
+================================
+
+.. toctree::
+    :maxdepth: 1
+
+    functions/window_func
+
 ==============================
 User-defined Functions
 ==============================

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/agg_func.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/agg_func.rst b/tajo-docs/src/main/sphinx/functions/agg_func.rst
new file mode 100644
index 0000000..4a50c32
--- /dev/null
+++ b/tajo-docs/src/main/sphinx/functions/agg_func.rst
@@ -0,0 +1,91 @@
+************************************
+Aggregation Functions
+************************************
+
+.. function:: avg (expression)
+
+  Returns the average of all input values.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: float8
+
+.. function:: corr (expression1, expression2)
+
+  Returns the coefficient of correlation between a set of number pairs.
+
+  :param expression1:
+  :param expression2:
+  :type expression1: int | float
+  :type expression2: int | float
+  :rtype: float8
+
+.. function:: count()
+
+  Returns the number of input rows.
+
+  :rtype: int8
+
+.. function:: last_value(expression)
+
+  Returns the last value of expression.
+
+  :param expression:
+  :type expression: int | float | date | time | timestamp | text
+  :rtype: same as parameter data type
+
+.. function:: max(expression)
+
+  Returns the maximum value of expression.
+
+  :param expression:
+  :type expression: int | float | date | time | timestamp | text
+  :rtype: same as parameter data type
+
+.. function:: min(expression)
+
+  Returns the minimum value of expression.
+
+  :param expression:
+  :type expression: int | float | date | time | timestamp | text
+  :rtype: same as parameter data type
+
+.. function:: stddev_pop(expression)
+
+  Returns the population standard deviation of a set of numbers.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: float8
+
+.. function:: stddev_samp(expression)
+
+  Returns the sample standard deviation of a set of numbers.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: float8
+
+.. function:: sum(expression)
+
+  Returns the sum of a set of numbers.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: same as parameter data type
+
+.. function:: var_pop(expression)
+
+  Returns the variance of a set of numbers.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: float8
+
+.. function:: var_samp(expression)
+
+  Returns the unbiased sample variance of a set of numbers.
+
+  :param expression:
+  :type expression: int | float
+  :rtype: float8
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/data_type_func_and_operators.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/data_type_func_and_operators.rst b/tajo-docs/src/main/sphinx/functions/data_type_func_and_operators.rst
new file mode 100644
index 0000000..c9e09d3
--- /dev/null
+++ b/tajo-docs/src/main/sphinx/functions/data_type_func_and_operators.rst
@@ -0,0 +1,43 @@
+************************************
+Data Type Functions and Operators
+************************************
+
+.. function:: to_bin(source int4)
+
+  Returns the binary representation of integer.
+
+  :param source: source value
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select to_bin(22);
+    > 10110
+
+.. function:: to_char(source int8, format text)
+
+  Convert integer to string.
+
+  :param source: source value
+  :param format: format
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select to_char(125, '00999');
+    > 00125
+
+.. function:: to_hex(source int4)
+
+  Convert the argument to hexadecimal.
+
+  :param source: source value
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select to_hex(15);
+    > F

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/datetime_func_and_operators.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/datetime_func_and_operators.rst b/tajo-docs/src/main/sphinx/functions/datetime_func_and_operators.rst
index e51623e..27238af 100644
--- a/tajo-docs/src/main/sphinx/functions/datetime_func_and_operators.rst
+++ b/tajo-docs/src/main/sphinx/functions/datetime_func_and_operators.rst
@@ -37,7 +37,7 @@ DateTime Functions and Operators
 
 .. function:: current_date ()
 
-  Returns current date
+  Returns current date.
 
   :rtype: date
           
@@ -48,7 +48,7 @@ DateTime Functions and Operators
 
 .. function:: current_time ()
 
-  Returns current time
+  Returns current time.
 
   :rtype: time
           
@@ -57,10 +57,14 @@ DateTime Functions and Operators
     select current_time();
     > 05:18:27.651999
 
-.. function:: extract(field FROM source)
+.. function:: extract(field FROM source date|timestamp|time)
 
   The extract function retrieves subfields such as year or hour from date/time values. *source* must be a value expression of type *timestamp*, or *time*. (Expressions of type *date* are cast to *timestamp* and can therefore be used as well.) *field* is an identifier that selects what field to extract from the source value. The extract function returns values of type double precision. The following are valid field names:
 
+  :param field: extract field
+  :param source: source value
+  :rtype: float8
+
   **century**
 
   The century
@@ -230,10 +234,14 @@ DateTime Functions and Operators
 
   The date_part function is also supported. It is equivalent to the SQL-standard function extract:
 
-.. function:: date_part('field', source)
+.. function:: date_part(field text, source date|timestamp|time)
 
   Note that here the field parameter needs to be a string value, not a name. The valid field names for date_part are the same as for extract.
 
+  :param field: extract field
+  :param source: source value
+  :rtype: float8
+
   .. code-block:: sql
 
     select date_part('day', timestamp '2001-02-16 20:38:40');
@@ -302,7 +310,7 @@ DateTime Functions and Operators
     select to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS');
     > 0097-02-15 23:14:30
 
-.. function:: utc_usec_to (string text , long timestamp , int dayOfWeek)
+.. function:: utc_usec_to (string text , timestamp long , dayOfWeek int)
 
   * If the **first parameter** is 'day'.
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/json_func.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/json_func.rst b/tajo-docs/src/main/sphinx/functions/json_func.rst
index 904be5b..9aadcfd 100644
--- a/tajo-docs/src/main/sphinx/functions/json_func.rst
+++ b/tajo-docs/src/main/sphinx/functions/json_func.rst
@@ -2,7 +2,7 @@
 JSON Functions
 *******************************
 
-.. function:: json_extract_path_text (string json, string json_path)
+.. function:: json_extract_path_text (json text, json_path text)
 
   Extracts JSON string from a JSON string based on json path specified and returns JSON string pointed to by JSONPath.
   Returns null if either argument is null.
@@ -17,7 +17,7 @@ JSON Functions
     select json_extract_path_text('{"test" : {"key" : "tajo"}}','$.test.key');
     > tajo
 
-.. function:: json_array_get (string json_array, int index)
+.. function:: json_array_get (json_array text, index int4)
 
   Returns the element at the specified index into the JSON array. This function returns an element indexed from the end of an array with a negative index, and null if the element at the specified index doesn’t exist.
 
@@ -34,7 +34,7 @@ JSON Functions
     select json_array_get('[100, 200, 300]', -2);
     > 200
 
-.. function:: json_array_contains (string json_array, any value)
+.. function:: json_array_contains (json_array text, value any)
 
   Determine if the given value exists in the JSON array.
 
@@ -48,7 +48,7 @@ JSON Functions
     select json_array_contains('[100, 200, 300]', 100);
     > t
 
-.. function:: json_array_length(string json_array)
+.. function:: json_array_length(json_array text)
 
   Returns the length of json array.
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/math_func_and_operators.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/math_func_and_operators.rst b/tajo-docs/src/main/sphinx/functions/math_func_and_operators.rst
index 9206056..0b75c70 100644
--- a/tajo-docs/src/main/sphinx/functions/math_func_and_operators.rst
+++ b/tajo-docs/src/main/sphinx/functions/math_func_and_operators.rst
@@ -87,6 +87,7 @@ Math Functions and Operators
 
   :param number: target real number
   :rtype: int8
+  :alias: ceiling
   :example:
 
   .. code-block:: sql
@@ -213,6 +214,19 @@ Math Functions and Operators
     select radians(45.0);
     > 0.7853981633974483
 
+.. function:: random(number int4)
+
+  Returns a pseudorandom number.
+
+  :param number: range restriction
+  :rtype: int4
+  :example:
+
+  .. code-block:: sql
+
+    select random(10);
+    > 4
+
 .. function:: round (number int|float)
 
   Rounds to nearest integer

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/network_func_and_operators.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/network_func_and_operators.rst b/tajo-docs/src/main/sphinx/functions/network_func_and_operators.rst
index d549244..0c3c717 100644
--- a/tajo-docs/src/main/sphinx/functions/network_func_and_operators.rst
+++ b/tajo-docs/src/main/sphinx/functions/network_func_and_operators.rst
@@ -23,7 +23,7 @@ as follows. ::
 Supported Functions
 ===================
 
-.. function:: geoip_country_code (string addr)
+.. function:: geoip_country_code (addr text)
 
   Convert an ipv4 address string to a geoip country code.
 
@@ -36,7 +36,7 @@ Supported Functions
     select geoip_country_code('163.152.71.31')
     > 'KR'
 
-.. function:: geoip_country_code (inet4 addr)
+.. function:: geoip_country_code (addr inet4)
 
   Convert an ipv4 address to a geoip country code.
 
@@ -49,7 +49,7 @@ Supported Functions
     select geoip_country_code(163.152.71.31)
     > 'KR'
 
-.. function:: geoip_in_country (string addr, string code)
+.. function:: geoip_in_country (addr text, code text)
 
   If the given country code is same with the country code of the given address, it returns true. Otherwise, returns false.
 
@@ -63,7 +63,7 @@ Supported Functions
     select geoip_in_country('163.152.71.31', 'KR')
     > true
 
-.. function:: geoip_in_country (inet4 addr, string code)
+.. function:: geoip_in_country (addr inet4, code text)
 
   If the given country code is same with the country code of the given address, it returns true. Otherwise, returns false.
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/string_func_and_operators.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/string_func_and_operators.rst b/tajo-docs/src/main/sphinx/functions/string_func_and_operators.rst
index 0ca27f1..f9912c1 100644
--- a/tajo-docs/src/main/sphinx/functions/string_func_and_operators.rst
+++ b/tajo-docs/src/main/sphinx/functions/string_func_and_operators.rst
@@ -13,77 +13,284 @@ String Functions and Operators
 
   .. code-block:: sql
 
-    select ‘Ta’ || ‘jo’; 
+    select 'Ta' || 'jo';
     > 'Tajo'
   
+.. function:: ascii (string text)
+
+  Returns the ASCII code of the first character of the text.
+  For UTF-8, this function returns the Unicode code point of the character.
+  For other multibyte encodings, the argument must be an ASCII character.
+
+  :param string: input string
+  :rtype: int4
+  :example:
+
+  .. code-block:: sql
+
+    select ascii('x');
+    > 120
+
+.. function:: bit_length (string text)
+
+  Returns the number of bits in string.
+
+  :param string: input string
+  :rtype: int4
+  :example:
+
+  .. code-block:: sql
+
+    select bit_length('jose');
+    > 32
 
 .. function:: char_length (string text)
 
-  Returns Number of characters in string
+  Returns the number of characters in string.
 
   :param string: to be counted
   :rtype: int4
-  :alias: character_length
+  :alias: character_length, length
+  :example:
+
+  .. code-block:: sql
+
+    select char_length('Tajo');
+    > 4
+
+.. function:: octet_length (string text)
+
+  Returns the number of bytes in string.
+
+  :param string: input string
+  :rtype: int4
   :example:
 
   .. code-block:: sql
 
-    select char_length(‘Tajo’);
+    select octet_length('jose');
     > 4
 
+.. function:: chr (code int4)
+
+  Returns a character with the given code.
+
+  :param code: input character code
+  :rtype: char
+  :example:
+
+  .. code-block:: sql
+
+    select chr(65);
+    > A
+
+.. function:: decode (binary text, format text)
+
+  Decode binary data from textual representation in string.
+
+  :param binary: encoded value
+  :param format: decode format. base64, hex, escape. escape converts zero bytes and high-bit-set bytes to octal sequences (\nnn) and doubles backslashes.
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select decode('MTIzXDAwMFwwMDE=', 'base64');
+    > 123\\000\\001
+
+.. function:: digest (input text, method text)
+
+  Calculates the Digest hash of string.
+
+  :param input: input string
+  :param method: hash method
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select digest('tajo', 'sha1');
+    > 02b0e20540b89f0b735092bbac8093eb2e3804cf
+
+.. function:: encode (binary text, format text)
+
+  Encode binary data into a textual representation.
+
+  :param binary: decoded value
+  :param format: encode format. base64, hex, escape. escape converts zero bytes and high-bit-set bytes to octal sequences (\nnn) and doubles backslashes.
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select encode('123\\000\\001', 'base64');
+    > MTIzXDAwMFwwMDE=
+
+.. function:: initcap (string text)
+
+  Convert the first letter of each word to upper case  and the rest to lower case.
+
+  :param string: input string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select initcap('hi THOMAS');
+    > Hi Thomas
+
+.. function:: md5 (string text)
+
+  Calculates the MD5 hash of string.
+
+  :param string: input string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select md5('abc');
+    > 900150983cd24fb0d6963f7d28e17f72
+
+.. function:: left (string text, number int4)
+
+  Returns the first n characters in the string.
+
+  :param string: input string
+  :param number: number of characters retrieved
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select left('ABC', 2);
+    > AB
+
+.. function:: right(string text, number int4)
 
-.. function:: trim([leading | trailing | both] [characters] from string)
+  Returns the last n characters in the string.
 
-  Removes the characters (a space by default) from the start/end/both ends of the string
+  :param string: input string
+  :param number: number of characters retrieved
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select right('ABC', 2);
+    > BC
+
+.. function:: locate(source text, target text, [start_index int4])
+
+  Returns the location of specified substring.
+
+  :param source: source string
+  :param target: target substring
+  :param start_index: the index where the search is started
+  :rtype: int4
+  :alias: strpos
+  :example:
+
+  .. code-block:: sql
+
+    select locate('high', 'ig', 1);
+    > 2
+
+.. function:: strposb(source text, target text)
+
+  Returns the binary location of specified substring.
+
+  :param source: source string
+  :param target: target substring
+  :rtype: int4
+  :example:
+
+  .. code-block:: sql
 
-  :param string: 
-  :param characters: 
+    select strpos('tajo', 'aj');
+    > 2
+
+.. function:: substr(source text, start int4, length int4)
+
+  Extract substring.
+
+  :param source: source string
+  :param start: start index
+  :param length: length of substring
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select substr('alphabet', 3, 2);
+    > ph
+
+.. function:: trim(string text, [characters text])
+
+  Removes the characters (a space by default) from the start/end/both ends of the string.
+
+  :param string: input string
+  :param characters: characters which will be removed
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select trim('xTajoxx', 'x');
+    > Tajo
+
+.. function:: trim([leading | trailing | both] [characters text] FROM string text)
+
+  Removes the characters (a space by default) from the start/end/both ends of the string.
+
+  :param string: input string
+  :param characters: characters which will be removed
   :rtype: text
   :example:
 
   .. code-block:: sql
 
-    select trim(both ‘x’ from ‘xTajoxx’);
-    > Tajo   
+    select trim(both 'x' from 'xTajoxx');
+    > Tajo
 
 
 .. function:: btrim(string text, [characters text])
 
-  Removes the characters (a space by default) from the both ends of the string
+  Removes the characters (a space by default) from the both ends of the string.
   
-  :param string: 
-  :param characters: 
+  :param string: input string
+  :param characters: characters which will be removed
   :rtype: text
   :alias: trim
   :example:
 
   .. code-block:: sql
 
-    select btrim(‘xTajoxx’, ‘x’);
+    select btrim('xTajoxx', 'x');
     > Tajo 
 
 
 .. function:: ltrim(string text, [characters text])
 
-  Removes the characters (a space by default) from the start ends of the string
+  Removes the characters (a space by default) from the start ends of the string.
 
-  :param string: 
-  :param characters: 
+  :param string: input string
+  :param characters: characters which will be removed
   :rtype: text
   :example:
 
   .. code-block:: sql
 
-    select ltrim(‘xxTajo’, ‘x’);
+    select ltrim('xxTajo', 'x');
     > Tajo 
 
 
 .. function:: rtrim(string text, [characters text])
 
-  Removes the characters (a space by default) from the end ends of the string
+  Removes the characters (a space by default) from the end ends of the string.
 
-  :param string: 
-  :param characters: 
+  :param string: input string
+  :param characters: characters which will be removed
   :rtype: text
   :example:
 
@@ -95,42 +302,42 @@ String Functions and Operators
 
 .. function:: split_part(string text, delimiter text, field int)
 
-  Splits a string on delimiter and return the given field (counting from one)
+  Splits a string on delimiter and return the given field (counting from one).
 
-  :param string: 
-  :param delimiter: 
-  :param field: 
+  :param string: input string
+  :param delimiter: delimiter
+  :param field: index to field
   :rtype: text
   :example:
 
   .. code-block:: sql
 
-    select split_part(‘ab_bc_cd’,‘_’,2);   
+    select split_part('ab_bc_cd','_',2);   
     > bc 
 
 
 
 .. function:: regexp_replace(string text, pattern text, replacement text)
 
-  Replaces substrings matched to a given regular expression pattern
+  Replaces substrings matched to a given regular expression pattern.
 
-  :param string: 
-  :param pattern: 
-  :param replacement: 
+  :param string: input string
+  :param pattern: pattern
+  :param replacement: string substituted for the matching substring
   :rtype: text
   :example:
 
   .. code-block:: sql
 
-    select regexp_replace(‘abcdef’, ‘(ˆab|ef$)’, ‘–’); 
+    select regexp_replace('abcdef', '(ˆab|ef$)', '–'); 
     > –cd–
 
 
 .. function:: upper(string text)
 
-  makes an input text to be upper case
+  Makes an input text to be upper case.
 
-  :param string:
+  :param string: input string
   :rtype: text
   :example:
 
@@ -142,9 +349,9 @@ String Functions and Operators
 
 .. function:: lower(string text)
 
-  makes an input text to be lower case
+  Makes an input text to be lower case.
 
-  :param string:
+  :param string: input string
   :rtype: text
   :example:
 
@@ -152,3 +359,73 @@ String Functions and Operators
 
     select lower('TAJO');
     > tajo
+
+.. function:: lpad(source text, number int4, pad text)
+
+  Fill up the string to length by prepending the characters fill (a space by default). If the string is already longer than length then it is truncated (on the right).
+
+  :param source: source string
+  :param number: padding length
+  :param pad: padding string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select lpad('hi', 5, 'xy');
+    > xyxhi
+
+.. function:: rpad(source text, number int4, pad text)
+
+  Fill up the string to length length by appending the characters fill (a space by default). If the string is already longer than length then it is truncated.
+
+  :param source: source string
+  :param number: padding length
+  :param pad: padding string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select rpad('hi', 5, 'xy');
+    > hixyx
+
+.. function:: quote_ident(string text)
+
+  Return the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled.
+
+  :param string: input string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select quote_ident('Foo bar');
+    > "Foo bar"
+
+.. function:: repeat(string text, number int4)
+
+  Repeat string the specified number of times.
+
+  :param string: input string
+  :param number: repetition number
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select repeat('Pg', 4);
+    > PgPgPgPg
+
+.. function:: reverse(string text)
+
+  Reverse string.
+
+  :param string: input string
+  :rtype: text
+  :example:
+
+  .. code-block:: sql
+
+    select reverse('TAJO');
+    > OJAT
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/functions/window_func.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/functions/window_func.rst b/tajo-docs/src/main/sphinx/functions/window_func.rst
new file mode 100644
index 0000000..86d0ca7
--- /dev/null
+++ b/tajo-docs/src/main/sphinx/functions/window_func.rst
@@ -0,0 +1,47 @@
+************************************
+Window Functions
+************************************
+
+.. function:: first_value (value any)
+
+  Returns the first value of input rows.
+
+  :param value: input value
+  :rtype: same as parameter data type
+
+.. function:: last_value (value any)
+
+  Returns the last value of input rows.
+
+  :param value: input value
+  :rtype: same as parameter data type
+
+.. function:: lag (value any [, offset integer [, default any ]])
+
+  Returns value evaluated at the row that is offset rows before the current row within the partition. If there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.
+
+  :param value: input value
+  :param offset: offset
+  :param default: default value
+  :rtype: same as parameter data type
+
+.. function:: lead (value any [, offset integer [, default any ]])
+
+  Returns value evaluated at the row that is offset rows after the current row within the partition. If there is no such row, instead return default. Both offset and default are evaluated with respect to the current row. If omitted, offset defaults to 1 and default to null.
+
+  :param value: input value
+  :param offset: offset
+  :param default: default value
+  :rtype: same as parameter data type
+
+.. function:: rank ()
+
+  Returns rank of the current row with gaps.
+
+  :rtype: int8
+
+.. function:: row_number ()
+
+  Returns the current row within its partition, counting from 1.
+
+  :rtype: int8
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/sql_language/joins.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/sql_language/joins.rst b/tajo-docs/src/main/sphinx/sql_language/joins.rst
index 7e86dba..a47ff0d 100644
--- a/tajo-docs/src/main/sphinx/sql_language/joins.rst
+++ b/tajo-docs/src/main/sphinx/sql_language/joins.rst
@@ -114,7 +114,7 @@ Basically, joining multiple relations is left-associative. However, query perfor
 To find the best join order, Tajo's cost-based optimizer considers join conditions, join types, and the size of input relations.
 In addition, it considers the computation cost of consecutive joins so that the shape of query plan forms a bushy tree.
 
-For example, suppose that there are 4 relations ``a`` (10), ``b`` (20), ``c`` (30), and ``d``(40) where the numbers within brackets represent the relation size.
+For example, suppose that there are 4 relations ``a`` (10), ``b`` (20), ``c`` (30), and ``d`` (40) where the numbers within brackets represent the relation size.
 The following query
 
 .. code-block:: sql

http://git-wip-us.apache.org/repos/asf/tajo/blob/ca7e3fde/tajo-docs/src/main/sphinx/sql_language/sql_expression.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/sql_language/sql_expression.rst b/tajo-docs/src/main/sphinx/sql_language/sql_expression.rst
index e5f4d62..4358e3d 100644
--- a/tajo-docs/src/main/sphinx/sql_language/sql_expression.rst
+++ b/tajo-docs/src/main/sphinx/sql_language/sql_expression.rst
@@ -16,16 +16,26 @@ A type cast converts a specified-typed data to another-typed data. Tajo has two
   CAST ( expression AS type )
   expression::type
 
+In addition, several functions are provided for type conversion. Please refer to `:doc:data_type_func_and_operators` and `:doc:datetime_func_and_operators`.
 
 -------------------------
-String Expressions
+String Constants
 -------------------------
 
+A string constant is an arbitrary sequence of characters bounded by single quotes (``'``):
+
+.. code-block:: sql
+
+  'tajo'
 
 -------------------------
 Function Call
 -------------------------
 
+The syntax for a function call consists of the name of a function and its argument list enclosed in parentheses:
+
 .. code-block:: sql
 
-  function_name ([expression [, expression ... ]] )
\ No newline at end of file
+  function_name ([expression [, expression ... ]] )
+
+For more information about functions, please refer to `:doc:functions`.
\ No newline at end of file