You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by bu...@apache.org on 2016/10/03 06:37:46 UTC

[5/5] asterixdb git commit: Revise builtin function documents.

Revise builtin function documents.

- splitted the original function document,
- shared all function documents between SQL++ and AQL,
  except the aggregation function document.

Change-Id: I4b05108b1bc741585717192b0b721ad00959bd83
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1221
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <bu...@gmail.com>


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

Branch: refs/heads/master
Commit: f7f3a7f2bd7a1743783ff5c1c1e4ede69381bcf5
Parents: ccb1408
Author: Yingyi Bu <yi...@couchbase.com>
Authored: Sun Oct 2 21:18:30 2016 -0700
Committer: Yingyi Bu <bu...@gmail.com>
Committed: Sun Oct 2 23:37:11 2016 -0700

----------------------------------------------------------------------
 asterixdb/asterix-doc/pom.xml                   |   10 +-
 .../src/main/markdown/builtins/0_toc.md         |   37 +
 .../src/main/markdown/builtins/10_comparison.md |   76 +
 .../src/main/markdown/builtins/11_others.md     |  249 ++
 .../src/main/markdown/builtins/1_numeric.md     |  518 ++++
 .../src/main/markdown/builtins/2_string.md      |  690 +++++
 .../src/main/markdown/builtins/3_binary.md      |  143 +
 .../src/main/markdown/builtins/4_spatial.md     |  326 +++
 .../src/main/markdown/builtins/5_similarity.md  |  146 +
 .../src/main/markdown/builtins/6_tokenizing.md  |   45 +
 .../src/main/markdown/builtins/7_allens.md      |  277 ++
 .../src/main/markdown/builtins/7_temporal.md    |  803 ++++++
 .../src/main/markdown/builtins/8_record.md      |  235 ++
 .../main/markdown/builtins/9_aggregate_aql.md   |  297 ++
 .../main/markdown/builtins/9_aggregate_sql.md   |  303 ++
 .../src/main/markdown/sqlpp/0_toc.md            |   19 +
 .../src/main/markdown/sqlpp/1_intro.md          |   19 +
 .../src/main/markdown/sqlpp/2_expr.md           |   19 +
 .../src/main/markdown/sqlpp/3_query.md          |   40 +-
 .../src/main/markdown/sqlpp/4_ddl.md            |   19 +
 .../asterix-doc/src/site/markdown/aql/allens.md |  274 --
 .../src/site/markdown/aql/functions.md          | 2676 ------------------
 asterixdb/asterix-doc/src/site/site.xml         |    7 +-
 23 files changed, 4261 insertions(+), 2967 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/pom.xml
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/pom.xml b/asterixdb/asterix-doc/pom.xml
index ab28e81..27a6095 100644
--- a/asterixdb/asterix-doc/pom.xml
+++ b/asterixdb/asterix-doc/pom.xml
@@ -48,7 +48,7 @@
         <version>1.8</version>
         <executions>
           <execution>
-            <id>concat</id>
+            <id>manual</id>
             <phase>pre-site</phase>
             <configuration>
               <target>
@@ -56,6 +56,14 @@
                   <filelist dir="${project.basedir}/src/main/markdown/sqlpp"
                          files="0_toc.md,1_intro.md,2_expr.md,3_query.md,4_ddl.md"/>
                 </concat>
+                <concat destfile="${project.build.directory}/generated-site/markdown/sqlpp/builtins.md">
+                  <filelist dir="${project.basedir}/src/main/markdown/builtins"
+                            files="0_toc.md,1_numeric.md,2_string.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_sql.md,10_comparison.md,11_others.md"/>
+                </concat>
+                <concat destfile="${project.build.directory}/generated-site/markdown/aql/builtins.md">
+                  <filelist dir="${project.basedir}/src/main/markdown/builtins"
+                            files="0_toc.md,1_numeric.md,2_string.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_aql.md,10_comparison.md,11_others.md"/>
+                </concat>
               </target>
             </configuration>
             <goals>

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/0_toc.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/0_toc.md b/asterixdb/asterix-doc/src/main/markdown/builtins/0_toc.md
new file mode 100644
index 0000000..2c8dedf
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/0_toc.md
@@ -0,0 +1,37 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+# Builtin Functions #
+
+## <a id="toc">Table of Contents</a> ##
+
+* [Numeric Functions](#NumericFunctions)
+* [String Functions](#StringFunctions)
+* [Binary Functions](#BinaryFunctions)
+* [Spatial Functions](#SpatialFunctions)
+* [Similarity Functions](#SimilarityFunctions)
+* [Tokenizing Functions](#TokenizingFunctions)
+* [Temporal Functions](#TemporalFunctions)
+* [Record Functions](#RecordFunctions)
+* [Aggregate Functions (Array Functions)](#AggregateFunctions)
+* [Comparison Functions](#ComparisonFunctions)
+* [Other Functions](#OtherFunctions)
+
+The system provides various classes of functions to support operations on numeric, string, spatial, and temporal data.
+This document explains how to use these functions.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/10_comparison.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/10_comparison.md b/asterixdb/asterix-doc/src/main/markdown/builtins/10_comparison.md
new file mode 100644
index 0000000..9a19566
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/10_comparison.md
@@ -0,0 +1,76 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="ComparisonFunctions">Comparison Functions</a> ##
+
+### greatest ###
+ * Syntax:
+
+        greatest(numeric_value1, numeric_value2, ...)
+
+ * Computes the greatest value among arguments.
+ * Arguments:
+    * `numeric_value1`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * `numeric_value2`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * ....
+ * Return Value:
+    * the greatest values among arguments.
+      The returning type is decided by the item type with the highest
+      order in the numeric type promotion order (`tinyint`-> `smallint`->`integer`->`bigint`->`float`->`double`)
+      among items.
+    * `null` if any argument is a `missing` value or `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": greatest(1, 2, 3), "v2": greatest(float("0.5"), double("-0.5"), 5000) };
+
+
+ * The expected result is:
+
+        { "v1": 3, "v2": 5000.0 }
+
+
+### least ###
+ * Syntax:
+
+        least(numeric_value1, numeric_value2, ...)
+
+ * Computes the least value among arguments.
+ * Arguments:
+    * `numeric_value1`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * `numeric_value2`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * ....
+ * Return Value:
+    * the least values among arguments.
+      The returning type is decided by the item type with the highest
+      order in the numeric type promotion order (`tinyint`-> `smallint`->`integer`->`bigint`->`float`->`double`)
+      among items.
+    * `null` if any argument is a `missing` value or `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": least(1, 2, 3), "v2": least(float("0.5"), double("-0.5"), 5000) };
+
+
+ * The expected result is:
+
+        { "v1": 1, "v2": -0.5 }
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/11_others.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/11_others.md b/asterixdb/asterix-doc/src/main/markdown/builtins/11_others.md
new file mode 100644
index 0000000..a20b8b3
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/11_others.md
@@ -0,0 +1,249 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="OtherFunctions">Other Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font> ##
+
+### uuid ###
+ * Syntax:
+
+        uuid()
+
+* Generates a `uuid`.
+* Arguments:
+    * none
+* Return Value:
+    * a generated, random `uuid`.
+
+
+### is_null ###
+ * Syntax:
+
+        is_null(expr)
+
+ * Checks whether the given expression is evaluated to be a `null` value.
+ * Arguments:
+    * `expr` : an expression (any type is allowed).
+ * Return Value:
+    * a `boolean` on whether the variable is a `null` or not,
+    * a `missing` if the input is `missing`.
+
+ * Example:
+
+        { "v1": is_null(null), "v2": is_null(1), "v3": is_null(missing) };
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### is_missing ###
+ * Syntax:
+
+        is_missing(expr)
+
+ * Checks whether the given expression is evaluated to be a `missing` value.
+ * Arguments:
+    * `expr` : an expression (any type is allowed).
+ * Return Value:
+    * a `boolean` on whether the variable is a `missing` or not.
+
+ * Example:
+
+        { "v1": is_missing(null), "v2": is_missing(1), "v3": is_missing(missing) };
+
+
+ * The expected result is:
+
+        { "v1": false, "v2": false, "v3": true }
+
+
+### is_unknown ###
+ * Syntax:
+
+        is_unknown(expr)
+
+ * Checks whether the given variable is a `null` value or a `missing` value.
+ * Arguments:
+    * `expr` : an expression (any type is allowed).
+ * Return Value:
+    * a `boolean` on whether the variable is a `null`/``missing` value (`true`) or not (`false`).
+
+ * Example:
+
+        { "v1": is_unknown(null), "v2": is_unknown(1), "v3": is_unknown(missing) };
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false, "v3": true }
+
+
+### len ###
+ * Syntax:
+
+    len(array)
+
+ * Returns the length of the array array.
+ * Arguments:
+    * `array` : an `array`, `multiset`, `null`, or `missing`, represents the collection that needs to be checked.
+ * Return Value:
+    * an `integer` that represents the length of input array or the size of the input multiset,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value.
+
+ * Example:
+
+        len(["Hello", "World"])
+
+
+ * The expected result is:
+
+        2
+
+
+### not ###
+ * Syntax:
+
+        not(expr)
+
+ * Inverts a `boolean` value
+ * Arguments:
+    * `expr` : an expression
+ * Return Value:
+    * a `boolean`, the inverse of `expr`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * other non-boolean argument value will cause a type error.
+ * Example:
+
+        { "v1": `not`(true), "v2": `not`(false), "v3": `not`(null), "v4": `not`(missing) };
+
+ * The expected result is:
+
+        { "v1": false, "v2": true, "v3": null }
+
+
+### range ###
+ * Syntax:
+
+        range(start_numeric_value, end_numeric_value)
+
+* Generates a series of `bigint` values based start the `start_numeric_value` until the `end_numeric_value`.
+* Arguments:
+   * `start_numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint` value representing the start value.
+   * `end_numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint` value representing the max final value.
+* Return Value:
+    * an array that starts with the integer value of `start_numeric_value` and ends with
+      the integer value of `end_numeric_value`, where the value of each entry in the array is
+      the integer successor of the value in the preceding entry.
+* Example:
+
+        range(0, 3);
+
+ * The expected result is:
+
+        [ 0, 1, 2, 3 ]
+
+
+### switch_case ###
+ * Syntax:
+
+        switch_case(
+            condition,
+            case1, case1_result,
+            case2, case2_result,
+            ...,
+            default, default_result
+        )
+
+ * Switches amongst a sequence of cases and returns the result of the first matching case. If no match is found, the result of the default case is returned.
+ * Arguments:
+    * `condition`: a variable (any type is allowed).
+    * `caseI/default`: a variable (any type is allowed).
+    * `caseI/default_result`: a variable (any type is allowed).
+ * Return Value:
+    * `caseI_result` if `condition` matches `caseI`, otherwise `default_result`.
+ * Example 1:
+
+        switch_case(
+            "a",
+            "a", 0,
+            "x", 1,
+            "y", 2,
+            "z", 3
+        );
+
+
+ * The expected result is:
+
+        0
+
+ * Example 2:
+
+        switch_case(
+            "a",
+            "x", 1,
+            "y", 2,
+            "z", 3
+        );
+
+ * The expected result is:
+
+        3
+
+
+### deep_equal ###
+* Syntax:
+
+        deep_equal(expr1, expr2)
+
+
+ * Assess the equality between two expressions of any type (e.g., record, arrays, or multiset).
+ Two objects are deeply equal iff both their types and values are equal.
+ * Arguments:
+    * `expr1` : an expression,
+    * `expr2` : an expression.
+ * Return Value:
+    * `true` or `false` depending on the data equality,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value.
+
+
+ * Example:
+
+        deep_equal(
+                   {
+                     "id":1,
+                     "project":"AsterixDB",
+                     "address":{"city":"Irvine", "state":"CA"},
+                     "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+                   },
+                   {
+                     "id":1,
+                     "project":"AsterixDB",
+                     "address":{"city":"San Diego", "state":"CA"},
+                     "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+                   }
+        );
+
+ * The expected result is:
+
+        false
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric.md b/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric.md
new file mode 100644
index 0000000..7cdc63f
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/1_numeric.md
@@ -0,0 +1,518 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="NumericFunctions">Numeric Functions</a> ##
+### abs ###
+ * Syntax:
+
+        abs(numeric_value)
+
+ * Computes the absolute value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * The absolute value of the argument with the same type as the input argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": abs(2013), "v2": abs(-4036), "v3": abs(0), "v4": abs(float("-2013.5")), "v5": abs(double("-2013.593823748327284")) };
+
+
+ * The expected result is:
+
+        { "v1": 2013, "v2": 4036, "v3": 0, "v4": 2013.5, "v5": 2013.5938237483274 }
+
+
+### acos ###
+ * Syntax:
+
+        acos(numeric_value)
+
+ * Computes the arc cosine value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` arc cosine in radians for the argument,
+       if the argument is in the range of -1 (inclusive) to 1 (inclusive),
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error,
+    * NaN for other legitimate numeric values.
+
+ * Example:
+
+        { "v1": acos(1), "v2": acos(2), "v3": abs(0), "v4": acos(float("0.5")), "v5": acos(double("-0.5")) };
+
+
+ * The expected result is:
+
+        { "v1": 0.0, "v2": NaN, "v3": 0, "v4": 1.0471975511965979, "v5": 2.0943951023931957 }
+
+
+### asin ###
+ * Syntax:
+
+        asin(numeric_value)
+
+ * Computes the arc sine value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` arc sin in radians for the argument,
+       if the argument is in the range of -1 (inclusive) to 1 (inclusive),
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error,
+    * NaN for other legitimate numeric values.
+
+ * Example:
+
+        { "v1": asin(1), "v2": asin(2), "v3": asin(0), "v4": asin(float("0.5")), "v5": asin(double("-0.5")) };
+
+
+ * The expected result is:
+
+        { "v1": 1.5707963267948966, "v2": NaN, "v3": 0.0, "v4": 0.5235987755982989, "v5": -0.5235987755982989 }
+
+
+### atan ###
+ * Syntax:
+
+        atan(numeric_value)
+
+ * Computes the arc tangent value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` arc tangent in radians for the argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": atan(1), "v2": atan(2), "v3": atan(0), "v4": atan(float("0.5")), "v5": atan(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 0.7853981633974483, "v2": 1.1071487177940904, "v3": 0.0, "v4": 0.4636476090008061, "v5": 1.5697963271282298 }
+
+
+### atan2 ###
+ * Syntax:
+
+        atan2(numeric_value1, numeric_value2)
+
+ * Computes the arc tangent value of arguments.
+ * Arguments:
+    * `numeric_value1`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * `numeric_value2`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` arc tangent in radians for `numeric_value1` and `numeric_value2`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": atan2(1, 2), "v2": atan2(0, 4), "v3": atan2(float("0.5"), double("-0.5")) };
+
+
+ * The expected result is:
+
+        { "v1": 0.4636476090008061, "v2": 0.0, "v3": 2.356194490192345 }
+
+
+### ceil ###
+ * Syntax:
+
+        ceil(numeric_value)
+
+ * Computes the smallest (closest to negative infinity) number with no fractional part that is not less than the value of the argument. If the argument is already equal to mathematical integer, then the result is the same as the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * The ceiling value for the given number in the same type as the input argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        {
+          "v1": ceil(2013),
+          "v2": ceil(-4036),
+          "v3": ceil(0.3),
+          "v4": ceil(float("-2013.2")),
+          "v5": ceil(double("-2013.893823748327284"))
+        };
+
+
+ * The expected result is:
+
+        { "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2013.0 }
+
+
+### cos ###
+ * Syntax:
+
+        cos(numeric_value)
+
+ * Computes the cosine value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` cosine value for the argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": cos(1), "v2": cos(2), "v3": cos(0), "v4": cos(float("0.5")), "v5": cos(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 0.5403023058681398, "v2": -0.4161468365471424, "v3": 1.0, "v4": 0.8775825618903728, "v5": 0.562379076290703 }
+
+
+### exp ###
+ * Syntax:
+
+        exp(numeric_value)
+
+ * Computes e<sup>numeric_value</sup>.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * e<sup>numeric_value</sup>,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": exp(1), "v2": exp(2), "v3": exp(0), "v4": exp(float("0.5")), "v5": exp(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 2.718281828459045, "v2": 7.38905609893065, "v3": 1.0, "v4": 1.6487212707001282, "v5": Infinity }
+
+
+### floor ###
+ * Syntax:
+
+        floor(numeric_value)
+
+ * Computes the largest (closest to positive infinity) number with no fractional part that is not greater than the value.
+   If the argument is already equal to mathematical integer, then the result is the same as the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * The floor value for the given number in the same type as the input argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        {
+          "v1": floor(2013),
+          "v2": floor(-4036),
+          "v3": floor(0.8),
+          "v4": floor(float("-2013.2")),
+          "v5": floor(double("-2013.893823748327284"))
+        };
+
+
+ * The expected result is:
+
+        { "v1": 2013, "v2": -4036, "v3": 0.0, "v4": -2014.0, "v5": -2014.0 }
+
+
+### ln ###
+ * Syntax:
+
+        ln(numeric_value)
+
+ * Computes log<sub>e</sub>numeric_value.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * log<sub>e</sub>numeric_value,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": exp(1), "v2": exp(2), "v3": exp(0), "v4": exp(float("0.5")), "v5": exp(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 2.718281828459045, "v2": 7.38905609893065, "v3": 1.0, "v4": 1.6487212707001282, "v5": Infinity }
+
+
+### log ###
+ * Syntax:
+
+        log(numeric_value)
+
+ * Computes log<sub>10</sub>numeric_value.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * log<sub>10</sub>numeric_value,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": exp(1), "v2": exp(2), "v3": exp(0), "v4": exp(float("0.5")), "v5": exp(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 2.718281828459045, "v2": 7.38905609893065, "v3": 1.0, "v4": 1.6487212707001282, "v5": Infinity }
+
+
+### atan2 ###
+ * Syntax:
+
+        power(numeric_value1, numeric_value2)
+
+ * Computes numeric_value1<sup>numeric_value2</sup>.
+ * Arguments:
+    * `numeric_value1`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * `numeric_value2`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * numeric_value1<sup>numeric_value2</sup>,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": power(1, 2), "v3": power(0, 4), "v4": power(float("0.5"), double("-0.5")) };
+
+
+ * The expected result is:
+
+        { "v1": 1, "v3": 0, "v4": 1.4142135623730951 }
+
+
+### round ###
+ * Syntax:
+
+        round(numeric_value)
+
+ * Computes the number with no fractional part that is closest (and also closest to positive infinity) to the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * The rounded value for the given number in the same type as the input argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        {
+          "v1": round(2013),
+          "v2": round(-4036),
+          "v3": round(0.8),
+          "v4": round(float("-2013.256")),
+          "v5": round(double("-2013.893823748327284"))
+        };
+
+
+ * The expected result is:
+
+        { "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0 }
+
+
+### round_half_to_even ###
+ * Syntax:
+
+        round_half_to_even(numeric_value, [precision])
+
+ * Computes the closest numeric value to `numeric_value` that is a multiple of ten to the power of minus `precision`.
+   `precision` is optional and by default value `0` is used.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+    * `precision`: an optional `tinyint`/`smallint`/`integer`/`bigint` field representing the
+       number of digits in the fraction of the the result
+ * Return Value:
+    * The rounded value for the given number in the same type as the input argument,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first argument is any other non-numeric value,
+        * or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.
+
+ * Example:
+
+        {
+          "v1": round_half_to_even(2013),
+          "v2": round_half_to_even(-4036),
+          "v3": round_half_to_even(0.8),
+          "v4": round_half_to_even(float("-2013.256")),
+          "v5": round_half_to_even(double("-2013.893823748327284")),
+          "v6": round_half_to_even(double("-2013.893823748327284"), 2),
+          "v7": round_half_to_even(2013, 4),
+          "v8": round_half_to_even(float("-2013.256"), 5)
+        };
+
+
+ * The expected result is:
+
+        { "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0, "v6": -2013.89, "v7": 2013, "v8": -2013.256 }
+
+
+### sign ###
+ * Syntax:
+
+        sign(numeric_value)
+
+ * Computes the sign of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the sign (a `tinyint`) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": sign(1), "v2": sign(2), "v3": sign(0), "v4": sign(float("0.5")), "v5": sign(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 1, "v2": 1, "v3": 0, "v4": 1, "v5": -1 }
+
+
+### sin ###
+ * Syntax:
+
+        sin(numeric_value)
+
+ * Computes the sine value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` sine value for the argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": sin(1), "v2": sin(2), "v3": sin(0), "v4": sin(float("0.5")), "v5": sin(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 0.8414709848078965, "v2": 0.9092974268256817, "v3": 0.0, "v4": 0.479425538604203, "v5": 0.8268795405320025 }
+
+
+### sqrt ###
+ * Syntax:
+
+        sqrt(numeric_value)
+
+ * Computes the square root of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` square root value for the argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": sqrt(1), "v2": sqrt(2), "v3": sqrt(0), "v4": sqrt(float("0.5")), "v5": sqrt(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 1.0, "v2": 1.4142135623730951, "v3": 0.0, "v4": 0.7071067811865476, "v5": 31.622776601683793 }
+
+
+### tan ###
+ * Syntax:
+
+        tan(numeric_value)
+
+ * Computes the tangent value of the argument.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value.
+ * Return Value:
+    * the `double` tangent value for the argument,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-numeric input value will cause a type error.
+
+ * Example:
+
+        { "v1": tan(1), "v2": tan(2), "v3": tan(0), "v4": tan(float("0.5")), "v5": tan(double("1000")) };
+
+
+ * The expected result is:
+
+        { "v1": 1.5574077246549023, "v2": -2.185039863261519, "v3": 0.0, "v4": 0.5463024898437905, "v5": 1.4703241557027185 }
+
+
+### trunc ###
+ * Syntax:
+
+        trunc(numeric_value, number_digits)
+
+ * Truncates the number to the given number of integer digits to the right of the decimal point (left if digits is negative).
+    Digits is 0 if not given.
+ * Arguments:
+    * `numeric_value`: a `tinyint`/`smallint`/`integer`/`bigint`/`float`/`double` value,
+    * `number_digits`: a `tinyint`/`smallint`/`integer`/`bigint` value.
+ * Return Value:
+    * the `double` tangent value for the argument,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is `missing`,
+    * a type error will be raised if:
+        * the first argument is any other non-numeric value,
+        * the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.
+
+ * Example:
+
+        { "v1": trunc(1, 1), "v2": trunc(2, -2), "v3": trunc(0.122, 2), "v4": trunc(float("11.52"), -1), "v5": trunc(double("1000.5252"), 3) };
+
+
+ * The expected result is:
+
+        { "v1": 1, "v2": 2, "v3": 0.12, "v4": 10.0, "v5": 1000.525 }
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/2_string.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/2_string.md b/asterixdb/asterix-doc/src/main/markdown/builtins/2_string.md
new file mode 100644
index 0000000..365b6f4
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/2_string.md
@@ -0,0 +1,690 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="StringFunctions">String Functions</a> ##
+### concat ###
+ * Syntax:
+
+        concat(string1, string2, ...)
+
+ * Returns a concatenated string from arguments.
+ * Arguments:
+    * `string1`: a string value,
+    * `string2`: a string value,
+    * ....
+ * Return Value:
+    * a concatenated string from arguments,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        concat("test ", "driven ", "development");
+
+
+ * The expected result is:
+
+        "test driven development"
+
+
+### contains ###
+ * Syntax:
+
+        contains(string, substring_to_contain)
+
+ * Checks whether the string `string` contains the string `substring_to_contain`
+ * Arguments:
+    * `string` : a `string` that might contain the given substring,
+    * `substring_to_contain` : a target `string` that might be contained.
+ * Return Value:
+    * a `boolean` value, `true` if `string` contains `substring_to_contain`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `false` otherwise.
+
+ * Note: an [n_gram index](similarity.html#UsingIndexesToSupportSimilarityQueries) can be utilized for this function.
+ * Example:
+
+        { "v1": contains("I like iphone", "phone"), "v2": contains("one", "phone") };
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### ends_with ###
+ * Syntax:
+
+        ends_with(string, substring_to_end_with)
+
+ * Checks whether the string `string` ends with the string `substring_to_end_with`.
+ * Arguments:
+    * `string` : a `string` that might end with the given string,
+    * `substring_to_end_with` : a `string` that might be contained as the ending substring.
+ * Return Value:
+    * a `boolean` value, `true` if `string` contains `substring_to_contain`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `false` otherwise.
+
+ * Example:
+
+        {
+          "v1": ends_with(" love sprint its shortcut_menu is awesome:)", ":)"),
+          "v2": ends_with(" awsome:)", ":-)")
+        };
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### initcap (title) ###
+ * Syntax:
+
+        initcap(string)
+
+ * Converts a given string `string` so that the first letter of each word is uppercase and
+   every other letter is lowercase.
+    The function has an alias called "title".
+ * Arguments:
+    * `string` : a `string` to be converted.
+ * Return Value:
+    * a `string` as the title form of the given `string`,
+    * `missing` if the argument is a `missing` value,
+     * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        { "v1": initcap("ASTERIXDB is here!"), "v2": title("ASTERIXDB is here!") };
+
+
+ * The expected result is:
+
+        { "v1": "Asterixdb Is Here!", "v2": "Asterixdb Is Here!" }
+
+
+### length ###
+ * Syntax:
+
+        length(string)
+
+ * Returns the length of the string `string`.
+ * Arguments:
+    * `string` : a `string` or `null` that represents the string to be checked.
+ * Return Value:
+    * an `bigint` that represents the length of `string`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        length("test string");
+
+
+ * The expected result is:
+
+        11
+
+
+### lower ###
+ * Syntax:
+
+        lower(string)
+
+ * Converts a given string `string` to its lowercase form.
+ * Arguments:
+    * `string` : a `string` to be converted.
+ * Return Value:
+    * a `string` as the lowercase form of the given `string`,
+    * `missing` if the argument is a `missing` value,
+     * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        lower("ASTERIXDB");
+
+
+ * The expected result is:
+
+        "asterixdb"
+
+
+### ltrim ###
+ * Syntax:
+
+        ltrim(string[, chars]);
+
+ * Returns a new string with all leading characters that appear in `chars` removed.
+   By default, white space is the character to trim.
+ * Arguments:
+    * `string` : a `string` to be trimmed,
+    * `chars` : a `string` that contains characters that are used to trim.
+ * Return Value:
+    * a trimmed, new `string`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+
+ * Example:
+
+        ltrim("i like iphone", "iphone");
+
+
+ * The expected result is:
+
+        " like iphone"
+
+
+### position ###
+ * Syntax:
+
+        position(string, string_pattern)
+
+ * Returns the first position of `string_pattern` within `string`.
+ * Arguments:
+    * `string` : a `string` that might contain the pattern,
+    * `string_pattern` : a pattern `string` to be matched.
+ * Return Value:
+    * the first position that `string_pattern` appears within `string`,
+      or -1 if it does not appear,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        {
+          "v1": position("pphonepp", "phone"),
+          "v2": position("hone", "phone")
+        };
+
+
+ * The expected result is:
+
+        { "v1": 1, "v2": -1 }
+
+
+### regexp_contains ###
+ * Syntax:
+
+        regexp_contains(string, string_pattern[, string_flags])
+
+ * Checks whether the strings `string` contains the regular expression
+    pattern `string_pattern` (a Java regular expression pattern).
+ * Arguments:
+    * `string` : a `string` that might contain the pattern,
+    * `string_pattern` : a pattern `string` to be matched,
+    * `string_flag` : (Optional) a `string` with flags to be used during regular expression matching.
+        * The following modes are enabled with these flags: dotall (s), multiline (m), case_insenitive (i), and comments and whitespace (x).
+ * Return Value:
+    * a `boolean`, returns `true` if `string` contains the pattern `string_pattern`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `false` otherwise.
+
+ * Example:
+
+        {
+          "v1": regexp_contains("pphonepp", "p*hone"),
+          "v2": regexp_contains("hone", "p+hone")
+        }
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### regexp_like ###
+ * Syntax:
+
+        regexp_like(string, string_pattern[, string_flags])
+
+ * Checks whether the string `string` exactly matches the regular expression pattern `string_pattern`
+   (a Java regular expression pattern).
+ * Arguments:
+    * `string` : a `string` that might contain the pattern,
+    * `string_pattern` : a pattern `string` that might be contained,
+    * `string_flag` : (Optional) a `string` with flags to be used during regular expression matching.
+        * The following modes are enabled with these flags: dotall (s), multiline (m), case_insenitive (i), and comments and whitespace (x).
+ * Return Value:
+    * a `boolean` value, `true` if `string` contains the pattern `string_pattern`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `false` otherwise.
+
+ * Example:
+
+        {
+          "v1": regexp_like(" can't stand at&t the network is horrible:(", ".*at&t.*"),
+          "v2": regexp_like("at&t", ".*att.*")
+        };
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### regexp_position ###
+ * Syntax:
+
+        regexp_position(string, string_pattern[, string_flags])
+
+ * Returns first position of the regular expression `string_pattern` (a Java regular expression pattern)
+   within `string`.
+ * Arguments:
+    * `string` : a `string` that might contain the pattern,
+    * `string_pattern` : a pattern `string` to be matched,
+    * `string_flag` : (Optional) a `string` with flags to be used during regular expression matching.
+        * The following modes are enabled with these flags: dotall (s), multiline (m), case_insenitive (i), and comments and whitespace (x).
+ * Return Value:
+    * the first position that the regular expression `string_pattern` appears in `string`,
+      or -1 if it does not appear.
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        {
+          "v1": regexp_position("pphonepp", "p*hone"),
+          "v2": regexp_position("hone", "p+hone")
+        };
+
+
+ * The expected result is:
+
+        { "v1": 0, "v2": -1 }
+
+
+### regexp_replace ###
+ * Syntax:
+
+        regexp_replace(string, string_pattern, string_replacement[, string_flags])
+
+ * Checks whether the string `string` matches the given
+   regular expression pattern `string_pattern` (a Java regular expression pattern),
+   and replace the matched pattern `string_pattern` with the new pattern `string_replacement`.
+ * Arguments:
+    * `string` : a `string` that might contain the pattern,
+    * `string_pattern` : a pattern `string` to be matched,
+    * `string_replacement` : a pattern `string` to be used as the replacement,
+    * `string_flag` : (Optional) a `string` with flags to be used during replace.
+        * The following modes are enabled with these flags: dotall (s), multiline (m), case_insenitive (i), and comments and whitespace (x).
+ * Return Value:
+    * Returns a `string` that is obtained after the replacements,
+    * `missing` if any argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `null` if any argument is a `null` value but no argument is a `missing` value.
+
+ * Example:
+
+        regexp_replace(" like iphone the voicemail_service is awesome", " like iphone", "like android")
+
+
+ * The expected result is:
+
+        "like android the voicemail_service is awesome"
+
+
+### repeat ###
+ * Syntax:
+
+        repeat(string, n)
+
+ * Returns a string formed by repeating the input `string` `n` times.
+ * Arguments:
+    * `string` : a `string` to be extracted,
+    * `offset` : an `tinyint`/`smallint`/`integer`/`bigint` value as the starting offset of the substring in `string`.
+ * Return Value:
+    * a string that repeats the input `string` `n` times,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first argument is any other non-string value,
+        * or, the second argument is not a `tinyint`, `smallint`, `integer`, or `bigint`.
+
+ * Example:
+
+        repeat("test", 3);
+
+
+ * The expected result is:
+
+        "testtesttest"
+
+
+### rtrim ###
+ * Syntax:
+
+        rtrim(string[, chars]);
+
+ * Returns a new string with all trailing characters that appear in `chars` removed.
+   By default, white space is the character to trim.
+ * Arguments:
+    * `string` : a `string` to be trimmed,
+    * `chars` : a `string` that contains characters that are used to trim.
+ * Return Value:
+    * a trimmed, new `string`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+
+ * Example:
+
+        rtrim("i like iphone", "iphone");
+
+
+ * The expected result is:
+
+        "i like "
+
+
+### split ###
+ * Syntax:
+
+        split(string, sep)
+
+ * Splits the input `string` into an array of substrings separated by the string `sep`.
+ * Arguments:
+    * `string` : a `string` to be split.
+ * Return Value:
+    * an array of substrings by splitting the input `string` by `sep`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        split("test driven development", " ");
+
+
+ * The expected result is:
+
+        [ "test", "driven", "development" ]
+
+
+### starts_with ###
+ * Syntax:
+
+        starts_with(string, substring_to_start_with)
+
+ * Checks whether the string `string` starts with the string `substring_to_start_with`.
+ * Arguments:
+    * `string` : a `string` that might start with the given string.
+    * `substring_to_start_with` : a `string` that might be contained as the starting substring.
+ * Return Value:
+    * a `boolean`, returns `true` if `string` starts with the string `substring_to_start_with`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error,
+    * `false` otherwise.
+
+ * Example:
+
+        {
+          "v1" : starts_with(" like the plan, amazing", " like"),
+          "v2" : starts_with("I like the plan, amazing", " like")
+        };
+
+
+ * The expected result is:
+
+        { "v1": true, "v2": false }
+
+
+### string_concat ###
+ * Syntax:
+
+        string_concat(array)
+
+ * Concatenates an array of strings `array` into a single string.
+ * Arguments:
+    * `array` : an `array` or `multiset` of `string`s (could be `null` or `missing`) to be concatenated.
+ * Return Value:
+    * the concatenated `string` value,
+    * `missing` if the argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * `missing` if any element in the input array is `missing`,
+    * `null` if any element in the input array is `null` but no element in the input array is `missing`,
+    * any other non-array input value or non-integer element in the input array will cause a type error.
+
+ * Example:
+
+        string_concat(["ASTERIX", " ", "ROCKS!"]);
+
+
+ * The expected result is:
+
+        "ASTERIX ROCKS!"
+
+
+### string_join ###
+ * Syntax:
+
+        string_join(array, string)
+
+ * Joins a array or multiset of strings `array` with the given separator `string` into a single string.
+ * Arguments:
+    * `array` : an `array` or `multiset` of strings (could be `null`) to be joined.
+    * `string` : a `string` as the separator.
+ * Return Value:
+    * the joined `string`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * `missing` if the first argument array contains a `missing`,
+    * `null` if the first argument array contains a `null` but does not contain a `missing`,
+    * a type error will be raised if:
+        * the first argument is any other non-array value, or contains any other non-string value,
+        * or, the second argument is any other non-string value.
+
+ * Example:
+
+        string_join(["ASTERIX", "ROCKS~"], "!! ");
+
+
+ * The expected result is:
+
+        "ASTERIX!! ROCKS~"
+
+
+### string_to_codepoint ###
+ * Syntax:
+
+        string_to_codepoint(string)
+
+ * Converts the string `string` to its code_based representation.
+ * Arguments:
+    * `string` : a `string` that will be converted.
+ * Return Value:
+    * an `array` of the code points for the string `string`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+
+
+### codepoint_to_string ###
+ * Syntax:
+
+        codepoint_to_string(array)
+
+ * Converts the ordered code_based representation `array` to the corresponding string.
+ * Arguments:
+    * `array` : an `array` of integer code_points.
+ * Return Value:
+    * a `string` representation of `array`.
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * `missing` if any element in the input array is `missing`,
+    * `null` if any element in the input array is `null` but no element in the input array is `missing`,
+    * any other non-array input value or non-integer element in the input array will cause a type error.
+
+ * Example:
+
+        { "codes": string_to_codepoint("Hello ASTERIX!"), "string": codepoint_to_string(string_to_codepoint("Hello ASTERIX!"))};
+
+
+ * The expected result is:
+
+        { "codes": [ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ], "string": "Hello ASTERIX!" }
+
+
+### substr ###
+ * Syntax:
+
+        substr(string, offset[, length])
+
+ * Returns the substring from the given string `string` based on the given start offset `offset` with the optional `length`.
+ * Arguments:
+    * `string` : a `string` to be extracted,
+    * `offset` : an `tinyint`/`smallint`/`integer`/`bigint` value as the starting offset of the substring in `string`,
+    * `length` : (Optional) an an `tinyint`/`smallint`/`integer`/`bigint` value as the length of the substring.
+ * Return Value:
+    * a `string` that represents the substring,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first argument is any other non-string value,
+        * or, the second argument is not a `tinyint`, `smallint`, `integer`, or `bigint`,
+        * or, the third argument is not a `tinyint`, `smallint`, `integer`, or `bigint` if the argument is present.
+
+ * Example:
+
+        substr("test string", 6, 3);
+
+
+ * The expected result is:
+
+        "str"
+
+
+### substring_before ###
+ * Syntax:
+
+        substring_before(string, string_pattern)
+
+ * Returns the substring from the given string `string` before the given pattern `string_pattern`.
+ * Arguments:
+    * `string` : a `string` to be extracted.
+    * `string_pattern` : a `string` pattern to be searched.
+ * Return Value:
+    * a `string` that represents the substring,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        substring_before(" like iphone", "iphone");
+
+
+* The expected result is:
+
+        " like "
+
+### substring_after ###
+ * Syntax:
+
+       substring_after(string, string_pattern);
+
+ * Returns the substring from the given string `string` after the given pattern `string_pattern`.
+ * Arguments:
+    * `string` : a `string` to be extracted.
+    * `string_pattern` : a `string` pattern to be searched.
+ * Return Value:
+    * a `string` that represents the substring,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+
+ * Example:
+
+        substring_after(" like iphone", "iphone");
+
+
+ * The expected result is:
+
+        ""
+
+
+### trim ###
+ * Syntax:
+
+        trim(string[, chars]);
+
+ * Returns a new string with all leading characters that appear in `chars` removed.
+   By default, white space is the character to trim.
+ * Arguments:
+    * `string` : a `string` to be trimmed,
+    * `chars` : a `string` that contains characters that are used to trim.
+ * Return Value:
+    * a trimmed, new `string`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+
+ * Example:
+
+        trim("i like iphone", "iphone");
+
+
+ * The expected result is:
+
+        " like "
+
+
+### upper ###
+ * Syntax:
+
+        upper(string)
+
+ * Converts a given string `string` to its uppercase form.
+ * Arguments:
+    * `string` : a `string` to be converted.
+ * Return Value:
+    * a `string` as the uppercase form of the given `string`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        upper("hello")
+
+
+ * The expected result is:
+
+        "HELLO"
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md b/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md
new file mode 100644
index 0000000..2902496
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md
@@ -0,0 +1,143 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="BinaryFunctions">Binary Functions</a> ##
+### parse_binary ###
+  * Syntax:
+
+      parse_binary(string, encoding)
+
+  * Creates a `binary` from an string encoded in `encoding` format.
+  * Arguments:
+    * `string` : an encoded `string`,
+    * `encoding` : a string notation specifies the encoding type of the given `string`.
+       Currently we support `hex` and `base64` format.
+  * Return Value:
+    * a `binary` that is decoded from the given `string`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+  * Example:
+
+      [ parse_binary("ABCDEF0123456789","hex"), parse_binary("abcdef0123456789","HEX"), parse_binary('QXN0ZXJpeAE=',"base64") ];
+
+  * The expected result is:
+
+      [ hex("ABCDEF0123456789"), hex("ABCDEF0123456789"), hex("4173746572697801") ]
+
+### print_binary ###
+  * Syntax:
+
+      print_binary(binary, encoding)
+
+  * Prints a `binary` to the required encoding `string` format.
+  * Arguments:
+    * `binary` : a `binary` data need to be printed.
+    * `encoding` : a string notation specifies the expected encoding type.
+    Currently we support `hex` and `base64` format.
+  * Return Value:
+    * a `string` that represents the encoded format of a `binary`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+
+  * Example:
+
+        [ print_binary(hex("ABCDEF0123456789"), "base64"), print_binary(base64("q83vASNFZ4k="), "hex") ]
+
+  * The expected result are:
+
+        [ "q83vASNFZ4k=", "ABCDEF0123456789" ]
+
+### binary_length ###
+  * Syntax:
+
+      binary_length(binary)
+
+  * Returns the number of bytes storing the binary data.
+  * Arguments:
+    * `binary` : a `binary` value to be checked.
+  * Return Value:
+    * an `bigint` that represents the number of bytes,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-binary input value will cause a type error.
+
+  * Example:
+
+        binary_length(hex("00AA"))
+
+  * The expected result is:
+
+       2
+
+### sub_binary ###
+  * Syntax:
+
+      sub_binary(binary, offset[, length])
+
+  * Returns the sub binary from the given `binary` based on the given start offset with the optional `length`.
+  * Arguments:
+    * `binary` : a `binary` to be extracted,
+    * `offset` : a `tinyint`, `smallint`, `integer`, or `bigint` value
+       as the starting offset of the sub binary in `binary`,
+    * `length` : (Optional) a `tinyint`, `smallint`, `integer`, or `bigint` value
+                  as the length of the sub binary.
+  * Return Value:
+    * a `binary` that represents the sub binary,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first argument is any other non-binary value,
+        * or, the second argument is any other non-integer value,
+        * or, the third argument is any other non-integer value, if it is present.
+
+  * Example:
+
+        sub_binary(hex("AABBCCDD"), 4);
+
+  * The expected result is
+
+        hex("DD")
+
+### binary_concat ###
+  * Syntax:
+
+      binary_concat(array)
+
+  * Concatenates a binary `array` or `multiset` into a single binary.
+  * Arguments:
+    * `array` : an `array` or `multiset` of binaries (could be `null` or `missing`) to be concatenated.
+  * Return Value  :
+    * the concatenated `binary` value,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * `missing` if any element in the input array is `missing`,
+    * `null` if any element in the input array is `null` but no element in the input array is `missing`,
+    * any other non-array input value or non-binary element in the input array will cause a type error.
+
+  * Example:
+
+      binary_concat([hex("42"), hex(""), hex('42')]);
+
+  * The expected result is
+
+      hex("4242")
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/4_spatial.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/4_spatial.md b/asterixdb/asterix-doc/src/main/markdown/builtins/4_spatial.md
new file mode 100644
index 0000000..c526844
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/4_spatial.md
@@ -0,0 +1,326 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="SpatialFunctions">Spatial Functions</a> ##
+### create_point ###
+ * Syntax:
+
+        create_point(x, y)
+
+ * Creates the primitive type `point` using an `x` and `y` value.
+ * Arguments:
+   * `x` : a `double` that represents the x-coordinate,
+   * `y` : a `double` that represents the y-coordinate.
+ * Return Value:
+   * a `point` representing the ordered pair (`x`, `y`),
+   * `missing` if any argument is a `missing` value,
+   * `null` if any argument is a `null` value but no argument is a `missing` value,
+   * any other non-double input value will cause a type error.
+
+ * Example:
+
+        { "point": create_point(30.0,70.0) };
+
+
+ * The expected result is:
+
+        { "point": point("30.0,70.0") }
+
+
+### create_line ###
+ * Syntax:
+
+        create_line(point1, point2)
+
+ * Creates the primitive type `line` using `point1` and `point2`.
+ * Arguments:
+    * `point1` : a `point` that represents the start point of the line.
+    * `point2` : a `point` that represents the end point of the line.
+ * Return Value:
+    * a spatial `line` created using the points provided in `point1` and `point2`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-point input value will cause a type error.
+
+ * Example:
+
+        { "line": create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
+
+
+ * The expected result is:
+
+        { "line": line("30.0,70.0 50.0,90.0") }
+
+
+### create_rectangle ###
+ * Syntax:
+
+        create_rectangle(point1, point2)
+
+ * Creates the primitive type `rectangle` using `point1` and `point2`.
+ * Arguments:
+    * `point1` : a `point` that represents the lower_left point of the rectangle.
+    * `point2` : a `point` that represents the upper_right point of the rectangle.
+ * Return Value:
+    * a spatial `rectangle` created using the points provided in `point1` and `point2`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-point input value will cause a type error.
+
+ * Example:
+
+        { "rectangle": create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
+
+
+ * The expected result is:
+
+        { "rectangle": rectangle("30.0,70.0 50.0,90.0") }
+
+
+### create_circle ###
+ * Syntax:
+
+        create_circle(point, radius)
+
+ * Creates the primitive type `circle` using `point` and `radius`.
+ * Arguments:
+    * `point` : a `point` that represents the center of the circle.
+    * `radius` : a `double` that represents the radius of the circle.
+ * Return Value:
+    * a spatial `circle` created using the center point and the radius provided in `point` and `radius`.
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first argument is any other non-point value,
+        * or, the second argument is any other non-double value.
+
+ * Example:
+
+        { "circle": create_circle(create_point(30.0,70.0), 5.0) }
+
+
+ * The expected result is:
+
+        { "circle": circle("30.0,70.0 5.0") }
+
+
+### create_polygon ###
+ * Syntax:
+
+        create_polygon(array)
+
+ * Creates the primitive type `polygon` using the double values provided in the argument `array`.
+   Each two consecutive double values represent a point starting from the first double value in the array.
+   Note that at least six double values should be specified, meaning a total of three points.
+ * Arguments:
+     * `array` : an array of doubles representing the points of the polygon.
+ * Return Value:
+     * a `polygon`, represents a spatial simple polygon created using the points provided in `array`.
+     * `missing` if the argument is a `missing` value,
+     * `null` if the argument is a `null` value,
+     * `missing` if any element in the input array is `missing`,
+     * `null` if any element in the input array is `null` but no element in the input array is `missing`,
+     * any other non-array input value or non-double element in the input array will cause a type error.
+
+
+ * Example:
+
+        { "polygon": create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
+
+
+ * The expected result is:
+
+        { "polygon": polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0") }
+
+
+### get_x/get_y ###
+ * Syntax:
+
+        get_x(point) or get_y(point)
+
+ * Returns the x or y coordinates of a point `point`.
+ * Arguments:
+    * `point` : a `point`.
+ * Return Value:
+    * a `double` representing the x or y coordinates of the point `point`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-point input value will cause a type error.
+
+ * Example:
+
+        { "x_coordinate": get_x(create_point(2.3,5.0)), "y_coordinate": get_y(create_point(2.3,5.0)) };
+
+
+ * The expected result is:
+
+        { "x_coordinate": 2.3, "y_coordinate": 5.0 }
+
+
+### get_points ###
+ * Syntax:
+
+        get_points(spatial_object)
+
+ * Returns an ordered array of the points forming the spatial object `spatial_object`.
+ * Arguments:
+    * `spatial_object` : a `point`, `line`, `rectangle`, `circle`, or `polygon`.
+ * Return Value:
+    * an `array` of the points forming the spatial object `spatial_object`,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-spatial-object input value will cause a type error.
+
+ * Example:
+
+        get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
+
+ * The expected result is:
+
+        [ point("1.0,1.0"), point("2.0,2.0"), point("3.0,3.0"), point("4.0,4.0") ]
+
+
+### get_center/get_radius ###
+ * Syntax:
+
+        get_center(circle_expression) or get_radius(circle_expression)
+
+ * Returns the center and the radius of a circle `circle_expression`, respectively.
+ * Arguments:
+    * `circle_expression` : a `circle`.
+ * Return Value:
+    * a `point` or `double`, represent the center or radius of the circle `circle_expression`.
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-circle input value will cause a type error.
+
+ * Example:
+
+        {
+          "circle_radius": get_radius(create_circle(create_point(6.0,3.0), 1.0)),
+          "circle_center": get_center(create_circle(create_point(6.0,3.0), 1.0))
+        };
+
+
+ * The expected result is:
+
+        { "circle_radius": 1.0, "circle_center": point("6.0,3.0") }
+
+
+
+### spatial_distance ###
+ * Syntax:
+
+        spatial_distance(point1, point2)
+
+ * Returns the Euclidean distance between `point1` and `point2`.
+ * Arguments:
+    * `point1` : a `point`.
+    * `point2` : a `point`.
+ * Return Value:
+    * a `double` as the Euclidean distance between `point1` and `point2`.
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-point input value will cause a type error.
+
+ * Example:
+
+        spatial_distance(point("47.44,80.65"), create_point(30.0,70.0));
+
+
+ * The expected result is:
+
+        20.434678857275934
+
+### spatial_area ###
+ * Syntax:
+
+        spatial_area(spatial_2d_expression)
+
+ * Returns the spatial area of `spatial_2d_expression`.
+ * Arguments:
+    * `spatial_2d_expression` : a `rectangle`, `circle`, or `polygon`.
+ * Return Value:
+    * a `double` representing the area of `spatial_2d_expression`.
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-2d-spatial-object will cause a type error.
+
+ * Example:
+
+        spatial_area(create_circle(create_point(0.0,0.0), 5.0));
+
+
+ * The expected result is:
+
+        78.53981625
+
+
+### spatial_intersect ###
+ * Syntax:
+
+        spatial_intersect(spatial_object1, spatial_object2)
+
+ * Checks whether `@arg1` and `@arg2` spatially intersect each other.
+ * Arguments:
+    * `spatial_object1` : a `point`, `line`, `rectangle`, `circle`, or `polygon`.
+    * `spatial_object2` : a `point`, `line`, `rectangle`, `circle`, or `polygon`.
+ * Return Value:
+    * a `boolean` representing whether `spatial_object1` and `spatial_object2` spatially overlap with each other,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-spatial-object input value will cause a type error.
+
+ * Example:
+
+        spatial_intersect(point("39.28,70.48"), create_rectangle(create_point(30.0,70.0), create_point(40.0,80.0)));
+
+
+ * The expected result is:
+
+        true
+
+### spatial_cell ###
+ * Syntax:
+
+        spatial_cell(point1, point2, x_increment, y_increment)
+
+ * Returns the grid cell that `point1` belongs to.
+ * Arguments:
+    * `point1` : a `point` representing the point of interest that its grid cell will be returned.
+    * `point2` : a `point` representing the origin of the grid.
+    * `x_increment` : a `double`, represents X increments.
+    * `y_increment` : a `double`, represents Y increments.
+ * Return Value:
+    * a `rectangle` representing the grid cell that `point1` belongs to,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first or second argument is any other non-point value,
+        * or, the second or third argument is any other non-double value.
+
+ * Example:
+
+        spatial_cell(point("39.28,70.48"), create_point(20.0,50.0), 5.5, 6.0);
+
+
+ * The expected result is:
+
+        rectangle("36.5,68.0 42.0,74.0");
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/5_similarity.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/5_similarity.md b/asterixdb/asterix-doc/src/main/markdown/builtins/5_similarity.md
new file mode 100644
index 0000000..89ef0f7
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/5_similarity.md
@@ -0,0 +1,146 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="SimilarityFunctions">Similarity Functions</a> ##
+
+AsterixDB supports queries with different similarity functions,
+including [edit distance](http://en.wikipedia.org/wiki/Levenshtein_distance) and
+[Jaccard](https://en.wikipedia.org/wiki/Jaccard_index).
+
+### edit_distance ###
+ * Syntax:
+
+        edit_distance(expression1, expression2)
+
+ * Returns the edit distance of `expression1` and `expression2`.
+ * Arguments:
+    * `expression1` : a `string` or a homogeneous `array` of a comparable item type.
+    * `expression2` : The same type as `expression1`.
+ * Return Value:
+    * an `bigint` that represents the edit distance between `expression1` and `expression2`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * any other non-string input value will cause a type error.
+ * Note: an [n_gram index](similarity.html#UsingIndexesToSupportSimilarityQueries) can be utilized for this function.
+ * Example:
+
+        edit_distance("SuzannaTillson", "Suzanna Tilson");
+
+
+ * The expected result is:
+
+        2
+
+
+### edit_distance_contains ###
+* Syntax:
+
+        edit_distance_contains(expression1, expression2, threshold)
+
+* Checks whether `expression1` contains `expression2` with an [edit distance](http://en.wikipedia.org/wiki/Levenshtein_distance) within a given threshold.
+
+* Arguments:
+    * `expression1` : a `string` or a homogeneous `array` of a comparable item type.
+    * `expression2` : The same type as `expression1`.
+    * `threshold` : a `bigint` that represents the distance threshold.
+* Return Value:
+    * an `array` with two items:
+        * The first item contains a `boolean` value representing whether `expression1` can contain `expression2`.
+        * The second item contains an `integer` that represents the required edit distance for `expression1` to contain
+         `expression2` if the first item is true.
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * a type error will be raised if:
+        * the first or second argument is any other non-string value,
+        * or, the third argument is any other non-bigint value.
+* Note: an [n_gram index](similarity.html#UsingIndexesToSupportSimilarityQueries) can be utilized for this function.
+* Example:
+
+        edit_distance_contains("happy","hapr",2);
+
+
+* The expected result is:
+
+        [ true, 1 ]
+
+
+
+### similarity_jaccard ###
+ * Syntax:
+
+        similarity_jaccard(array1, array2)
+
+ * Returns the [Jaccard similarity](http://en.wikipedia.org/wiki/Jaccard_index) of `array1` and `array2`.
+ * Arguments:
+    * `array1` : an `array` or `multiset`.
+    * `array2` : an `array` or `multiset`.
+ * Return Value:
+    * a `float` that represents the Jaccard similarity of `array1` and `array2`,
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * `missing` if any element in any input array is `missing`,
+    * `null` if any element in any input array is `null` but no element in the input array is `missing`,
+    * any other non-array input value or non-integer element in any input array will cause a type error.
+
+ * Note: a [keyword index](similarity.html#UsingIndexesToSupportSimilarityQueries) can be utilized for this function.
+ * Example:
+
+        similarity_jaccard([1,5,8,9], [1,5,9,10]);
+
+
+ * The expected result is:
+
+        0.6
+
+
+### similarity_jaccard_check ###
+ * Syntax:
+
+        similarity_jaccard_check(array1, array2, threshold)
+
+ * Checks whether `array1` and `array2` have a [Jaccard similarity](http://en.wikipedia.org/wiki/Jaccard_index) greater than or equal to threshold.  Again, the \u201ccheck\u201d version of Jaccard is faster than the "non_check" version.
+
+ * Arguments:
+    * `array1` : an `array` or `multiset`.
+    * `array2` : an `array` or `multiset`.
+    * `threshold` : a `double` that represents the similarity threshold.
+ * Return Value:
+    * an `array` with two items:
+        * The first item contains a `boolean` value representing whether `array1` and `array2` are similar.
+        * The second item contains a `float` that represents the Jaccard similarity of `array1` and `array2`
+         if it is greater than or equal to the threshold, or 0 otherwise.
+    * `missing` if any argument is a `missing` value,
+    * `null` if any argument is a `null` value but no argument is a `missing` value,
+    * `missing` if any element in any input array is `missing`,
+    * `null` if any element in any input array is `null` but no element in the input array is `missing`,
+    * a type error will be raised if:
+            * the first or second argument is any other non-array value,
+            * or, the third argument is any other non-double value.
+
+ * Note: a [keyword index](similarity.html#UsingIndexesToSupportSimilarityQueries) can be utilized for this function.
+ * Example:
+
+        similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
+
+
+ * The expected result is:
+
+        [ false, 0.0 ]
+
+

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/f7f3a7f2/asterixdb/asterix-doc/src/main/markdown/builtins/6_tokenizing.md
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/6_tokenizing.md b/asterixdb/asterix-doc/src/main/markdown/builtins/6_tokenizing.md
new file mode 100644
index 0000000..4783cc8
--- /dev/null
+++ b/asterixdb/asterix-doc/src/main/markdown/builtins/6_tokenizing.md
@@ -0,0 +1,45 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+
+## <a id="TokenizingFunctions">Tokenizing Functions</a> ##
+### word_tokens ###
+
+
+ * Syntax:
+
+        word_tokens(string)
+
+ * Returns an array of word tokens of `string` using non_alphanumeric characters as delimiters.
+ * Arguments:
+    * `string` : a `string` that will be tokenized.
+ * Return Value:
+    * an `array` of `string` word tokens,
+    * `missing` if the argument is a `missing` value,
+    * `null` if the argument is a `null` value,
+    * any other non-string input value will cause a type error.
+
+ * Example:
+
+        word_tokens("I like the phone, awesome!");
+
+
+ * The expected result is:
+
+        [ "i", "like", "the", "phone", "awesome" ]
+