Update site for release
Change-Id: I8aa5dce0b9a9c51df2fcafa91d2e4f47d9fb4cf4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/incubator-asterixdb-site/+/7505
Reviewed-by: Ian Maxon <imaxon@uci.edu>
diff --git a/docs/0.9.5/sqlpp/builtins.html b/docs/0.9.5/sqlpp/builtins.html
new file mode 100644
index 0000000..b88f434
--- /dev/null
+++ b/docs/0.9.5/sqlpp/builtins.html
@@ -0,0 +1,14847 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/sqlpp/builtins.md at 2020-08-07
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200807" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – Builtin Functions</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-08-07</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li class="active"><a href="#"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>Builtin Functions</h1><!--
+ ! 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.
+ !-->
+
+<div class="section">
+<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
+<ul>
+
+<li><a href="#NumericFunctions">Numeric Functions</a></li>
+<li><a href="#StringFunctions">String Functions</a></li>
+<li><a href="#BinaryFunctions">Binary Functions</a></li>
+<li><a href="#SpatialFunctions">Spatial Functions</a></li>
+<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
+<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
+<li><a href="#TemporalFunctions">Temporal Functions</a></li>
+<li><a href="#ObjectFunctions">Object Functions</a></li>
+<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
+<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
+<li><a href="#TypeFunctions">Type Functions</a></li>
+<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
+<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
+<li><a href="#BitwiseFunctions">Bitwise Functions</a></li>
+<li><a href="#WindowFunctions">Window Functions</a></li>
+</ul><!--
+ ! 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.
+ !-->
+
+<p>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.</p><!--
+ ! 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.
+ !-->
+</div>
+<div class="section">
+<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
+<div class="section">
+<h3><a name="abs"></a>abs</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">abs(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the absolute value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The absolute value of the argument with the same type as the input argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": abs(2013), "v2": abs(-4036), "v3": abs(0), "v4": abs(float("-2013.5")), "v5": abs(double("-2013.593823748327284")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2013, "v2": 4036, "v3": 0, "v4": 2013.5, "v5": 2013.5938237483274 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="acos"></a>acos</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">acos(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the arc cosine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> arc cosine in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error,</li>
+<li>“NaN” for other legitimate numeric values.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": acos(1), "v2": acos(2), "v3": acos(0), "v4": acos(float("0.5")), "v5": acos(double("-0.5")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.0, "v2": "NaN", "v3": 1.5707963267948966, "v4": 1.0471975511965979, "v5": 2.0943951023931957 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="asin"></a>asin</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">asin(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the arc sine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> arc sin in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error,</li>
+<li>“NaN” for other legitimate numeric values.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": asin(1), "v2": asin(2), "v3": asin(0), "v4": asin(float("0.5")), "v5": asin(double("-0.5")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1.5707963267948966, "v2": "NaN", "v3": 0.0, "v4": 0.5235987755982989, "v5": -0.5235987755982989 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="atan"></a>atan</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">atan(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the arc tangent value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": atan(1), "v2": atan(2), "v3": atan(0), "v4": atan(float("0.5")), "v5": atan(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.7853981633974483, "v2": 1.1071487177940904, "v3": 0.0, "v4": 0.4636476090008061, "v5": 1.5697963271282298 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="atan2"></a>atan2</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">atan2(numeric_value1, numeric_value2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": atan2(1, 2), "v2": atan2(0, 4), "v3": atan2(float("0.5"), double("-0.5")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.4636476090008061, "v2": 0.0, "v3": 2.356194490192345 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ceil"></a>ceil</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">ceil(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>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.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The ceiling value for the given number in the same type as the input argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": ceil(2013),
+ "v2": ceil(-4036),
+ "v3": ceil(0.3),
+ "v4": ceil(float("-2013.2")),
+ "v5": ceil(double("-2013.893823748327284"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2013.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="cos"></a>cos</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">cos(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the cosine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> cosine value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": cos(1), "v2": cos(2), "v3": cos(0), "v4": cos(float("0.5")), "v5": cos(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.5403023058681398, "v2": -0.4161468365471424, "v3": 1.0, "v4": 0.8775825618903728, "v5": 0.562379076290703 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="cosh"></a>cosh</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">cosh(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the hyperbolic cosine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": cosh(1), "v2": cosh(2), "v3": cosh(0), "v4": cosh(float("0.5")), "v5": cosh(double("8")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1.5430806348152437, "v2": 3.7621956910836314, "v3": 1.0, "v4": 1.1276259652063807, "v5": 1490.479161252178 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="degrees"></a>degrees</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">degrees(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts radians to degrees</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": degrees(pi()) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 180.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="e"></a>e</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">e()
+</pre></div></div>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>e (base of the natural logarithm)</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": e() };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2.718281828459045 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="exp"></a>exp</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">exp(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes e<sup>numeric_value</sup>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>e<sup>numeric_value</sup>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": exp(1), "v2": exp(2), "v3": exp(0), "v4": exp(float("0.5")), "v5": exp(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2.718281828459045, "v2": 7.38905609893065, "v3": 1.0, "v4": 1.6487212707001282, "v5": "Infinity" }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="floor"></a>floor</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">floor(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>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.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The floor value for the given number in the same type as the input argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": floor(2013),
+ "v2": floor(-4036),
+ "v3": floor(0.8),
+ "v4": floor(float("-2013.2")),
+ "v5": floor(double("-2013.893823748327284"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2013, "v2": -4036, "v3": 0.0, "v4": -2014.0, "v5": -2014.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ln"></a>ln</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">ln(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes log<sub>e</sub>numeric_value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>log<sub>e</sub>numeric_value,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": ln(1), "v2": ln(2), "v3": ln(0), "v4": ln(float("0.5")), "v5": ln(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.0, "v2": 0.6931471805599453, "v3": "-Infinity", "v4": -0.6931471805599453, "v5": 6.907755278982137 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="log"></a>log</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">log(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes log<sub>10</sub>numeric_value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>log<sub>10</sub>numeric_value,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": log(1), "v2": log(2), "v3": log(0), "v4": log(float("0.5")), "v5": log(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.0, "v2": 0.3010299956639812, "v3": "-Infinity", "v4": -0.3010299956639812, "v5": 3.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="pi"></a>pi</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">pi()
+</pre></div></div>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>Pi</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": pi() };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 3.141592653589793 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="power"></a>power</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">power(numeric_value1, numeric_value2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>numeric_value1<sup>numeric_value2</sup>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": power(1, 2), "v3": power(0, 4), "v4": power(float("0.5"), double("-0.5")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1, "v3": 0, "v4": 1.4142135623730951 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="radians"></a>radians</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">radians(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts degrees to radians</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": radians(180) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 3.141592653589793 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="round"></a>round</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">round(numeric_value[, round_digit])
+</pre></div></div>
+</li>
+<li>
+
+<p>Rounds the value to the given number of integer digits to the right of the decimal point, or to the left of the decimal point if the number of digits is negative.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value that represents the numeric value to be rounded.</li>
+<li><tt>round_digit</tt>: (Optional) a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value that specifies the digit to round to. This argument may be positive or negative; positive indicating that rounding needs to be to the right of the decimal point, and negative indicating that rounding needs to be to the left of the decimal point. Values such as 1.0 and 2.0 are acceptable, but values such as 1.3 and 1.5 result in a <tt>null</tt>. If omitted, the default is 0.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The rounded value for the given number. The returned value has the following type:
+<ul>
+
+<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
+<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
+<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
+</ul>
+</li>
+<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": round(2013),
+ "v2": round(-4036),
+ "v3": round(0.8),
+ "v4": round(float("-2013.256")),
+ "v5": round(double("-2013.893823748327284"))
+ "v6": round(123456, -1),
+ "v7": round(456.456, 2),
+ "v8": round(456.456, -1),
+ "v9": round(-456.456, -2)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0, "v6": 123460, "v7": 456.46, "v8": 460, "v9": -500 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="sign"></a>sign</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">sign(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the sign of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": sign(1), "v2": sign(2), "v3": sign(0), "v4": sign(float("0.5")), "v5": sign(double("-1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1, "v2": 1, "v3": 0, "v4": 1, "v5": -1 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="sin"></a>sin</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">sin(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the sine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> sine value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": sin(1), "v2": sin(2), "v3": sin(0), "v4": sin(float("0.5")), "v5": sin(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.8414709848078965, "v2": 0.9092974268256817, "v3": 0.0, "v4": 0.479425538604203, "v5": 0.8268795405320025 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="sinh"></a>sinh</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">sinh(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the hyperbolic sine value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": sinh(1), "v2": sinh(2), "v3": sinh(0), "v4": sinh(float("0.5")), "v5": sinh(double("8")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1.1752011936438014, "v2": 3.626860407847019, "v3": 0.0, "v4": 0.5210953054937474, "v5": 1490.4788257895502 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="sqrt"></a>sqrt</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">sqrt(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the square root of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> square root value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": sqrt(1), "v2": sqrt(2), "v3": sqrt(0), "v4": sqrt(float("0.5")), "v5": sqrt(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1.0, "v2": 1.4142135623730951, "v3": 0.0, "v4": 0.7071067811865476, "v5": 31.622776601683793 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="tan"></a>tan</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">tan(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the tangent value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> tangent value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": tan(1), "v2": tan(2), "v3": tan(0), "v4": tan(float("0.5")), "v5": tan(double("1000")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1.5574077246549023, "v2": -2.185039863261519, "v3": 0.0, "v4": 0.5463024898437905, "v5": 1.4703241557027185 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="tanh"></a>tanh</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">tanh(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the hyperbolic tangent value of the argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": tanh(1), "v2": tanh(2), "v3": tanh(0), "v4": tanh(float("0.5")), "v5": tanh(double("8")) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.7615941559557649, "v2": 0.964027580075817, "v3": 0.0, "v4": 0.4621171572600098, "v5": 0.999999774929676 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="trunc"></a>trunc</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">trunc(numeric_value, number_digits)
+</pre></div></div>
+</li>
+<li>
+
+<p>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.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the <tt>double</tt> tangent value for the argument,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-numeric value,</li>
+<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "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) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1, "v2": 2, "v3": 0.12, "v4": 10.0, "v5": 1000.525 }
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div>
+<div class="section">
+<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">round_half_to_even(numeric_value, [precision])
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the closest numeric value to <tt>numeric_value</tt> that is a multiple of ten to the power of minus <tt>precision</tt>. <tt>precision</tt> is optional and by default value <tt>0</tt> is used.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+<li><tt>precision</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> field representing the number of digits in the fraction of the the result</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The rounded value for the given number in the same type as the input argument,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-numeric value,</li>
+<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "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)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2013, "v2": -4036, "v3": 1.0, "v4": -2013.0, "v5": -2014.0, "v6": -2013.89, "v7": 2013, "v8": -2013.256 }
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
+<div class="section">
+<h3><a name="concat"></a>concat</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">concat(string1, string2, ...)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a concatenated string from arguments.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string1</tt>: a string value,</li>
+<li><tt>string2</tt>: a string value,</li>
+<li>….</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a concatenated string from arguments,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">concat("test ", "driven ", "development");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"test driven development"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="contains"></a>contains</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">contains(string, substring_to_contain)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
+<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error,</li>
+<li><tt>false</tt> otherwise.</li>
+</ul>
+</li>
+<li>
+
+<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
+</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">{ "v1": contains("I like x-phone", "phone"), "v2": contains("one", "phone") };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ends_with"></a>ends_with</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">ends_with(string, substring_to_end_with)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
+<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error,</li>
+<li><tt>false</tt> otherwise.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": ends_with(" love product-b its shortcut_menu is awesome:)", ":)"),
+ "v2": ends_with(" awsome:)", ":-)")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">initcap(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts a given string <tt>string</tt> so that the first letter of each word is uppercase and every other letter is lowercase. The function has an alias called “title”.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": initcap("ASTERIXDB is here!"), "v2": title("ASTERIXDB is here!") };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": "Asterixdb Is Here!", "v2": "Asterixdb Is Here!" }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="length"></a>length</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">length(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the length of the string <tt>string</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">length("test string");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">11
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="lower"></a>lower</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">lower(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">lower("ASTERIXDB");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"asterixdb"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ltrim"></a>ltrim</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">ltrim(string[, chars]);
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
+<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a trimmed, new <tt>string</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">ltrim("me like x-phone", "eml");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">" like x-phone"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="position"></a>position</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">position(string, string_pattern)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>. The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
+<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
+<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the first position that <tt>string_pattern</tt> appears within <tt>string</tt> (starting at 0), or -1 if it does not appear,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will return a <tt>null</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": position("ppphonepp", "phone"),
+ "v2": position("hone", "phone"),
+ "v3": position1("ppphonepp", "phone"),
+ "v4": position1("hone", "phone"),
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 2, "v2": -1, v3": 3, "v4": -1 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="regexp_contains"></a>regexp_contains</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">regexp_contains(string, string_pattern[, string_flags])
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
+<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
+<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
+<ul>
+
+<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+<li>any other non-string input value will return a <tt>null</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": regexp_contains("pphonepp", "p*hone"),
+ "v2": regexp_contains("hone", "p+hone")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="regexp_like"></a>regexp_like</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">regexp_like(string, string_pattern[, string_flags])
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
+<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
+<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
+<ul>
+
+<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+<li>any other non-string input value will return a <tt>null</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": regexp_like(" can't stand acast the network is horrible:(", ".*acast.*"),
+ "v2": regexp_like("acast", ".*acst.*")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="regexp_position"></a>regexp_position</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">regexp_position(string, string_pattern[, string_flags])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns first position of the regular expression <tt>string_pattern</tt> (a Java regular expression pattern) within <tt>string</tt>. The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li>0-Based: <tt>regexp_position</tt>, <tt>regexp_pos</tt>, <tt>regexp_position0</tt>, <tt>regexp_pos0</tt>, <tt>regex_position</tt>, <tt>regex_pos</tt>, <tt>regex_position0</tt>, <tt>regex_pos0</tt>.</li>
+<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
+<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
+<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
+<ul>
+
+<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the first position that the regular expression <tt>string_pattern</tt> appears in <tt>string</tt> (starting at 0), or -1 if it does not appear.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will return a <tt>null</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": regexp_position("pphonepp", "p*hone"),
+ "v2": regexp_position("hone", "p+hone"),
+ "v3": regexp_position1("pphonepp", "p*hone"),
+ "v4": regexp_position1("hone", "p+hone")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0, "v2": -1, "v3": 1, "v4": -1 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="regexp_replace"></a>regexp_replace</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
+regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the string <tt>string</tt> matches the given regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern), and replaces the matched pattern <tt>string_pattern</tt> with the new pattern <tt>string_replacement</tt>.</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
+<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
+<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
+<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
+<ul>
+
+<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
+</ul>
+</li>
+<li><tt>replacement_limit</tt>: (Optional) an <tt>integer</tt> specifying the maximum number of replacements to make (if negative then all occurrences will be replaced)</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+<li>any other non-string input value will return a <tt>null</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">regexp_replace(" like x-phone the voicemail_service is awesome", " like x-phone", "like product-a");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"like product-a the voicemail_service is awesome"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="repeat"></a>repeat</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">repeat(string, n)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
+<li><tt>n</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value - how many times the string should be repeated.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-string value,</li>
+<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">repeat("test", 3);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"testtesttest"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="replace"></a>replace</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">replace(string, search_string, replacement_string[, limit])
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds occurrences of the given substring <tt>search_string</tt> in the input string <tt>string</tt> and replaces them with the new substring <tt>replacement_string</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : an input <tt>string</tt>,</li>
+<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
+<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
+<li><tt>limit</tt> : (Optional) an <tt>integer</tt> - maximum number of occurrences to be replaced. If not specified or negative then all occurrences will be replaced</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": replace(" like x-phone the voicemail_service is awesome", " like x-phone", "like product-a"),
+ "v2": replace("x-phone and x-phone", "x-phone", "product-a", 1)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": "like product-a the voicemail_service is awesome",
+ "v2": "product-a and x-phone"
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="reverse"></a>reverse</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">reverse(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a string formed by reversing characters in the input <tt>string</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-string value</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">reverse("hello");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"olleh"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="rtrim"></a>rtrim</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">rtrim(string[, chars]);
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new string with all trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
+<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a trimmed, new <tt>string</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": rtrim("i like x-phone", "x-phone"),
+ "v2": rtrim("i like x-phone", "onexph")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": "i like ", "v2": "i like " }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="split"></a>split</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">split(string, sep)
+</pre></div></div>
+</li>
+<li>
+
+<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">split("test driven development", " ");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ "test", "driven", "development" ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="starts_with"></a>starts_with</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">starts_with(string, substring_to_start_with)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
+<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error,</li>
+<li><tt>false</tt> otherwise.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1" : starts_with(" like the plan, amazing", " like"),
+ "v2" : starts_with("I like the plan, amazing", " like")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="substr"></a>substr</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">substr(string, offset[, length])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the substring from the given string <tt>string</tt> based on the given start offset <tt>offset</tt> with the optional <tt>length</tt>. The function uses the 0-based position. Another version of the function uses the 1-based position. Below are the aliases for each version:</p>
+</li>
+<li>
+
+<p>Aliases:</p>
+<ul>
+
+<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
+<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
+<li><tt>offset</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the starting offset of the substring in <tt>string</tt> (starting at 0). If negative then counted from the end of the string.</li>
+<li><tt>length</tt> : (Optional) an an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the length of the substring.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> that represents the substring,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or if the substring could not be obtained because the starting offset is not within string bounds or <tt>length</tt> is negative.</li>
+<li>a <tt>null</tt> will be returned if:
+<ul>
+
+<li>the first argument is any other non-string value.</li>
+<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
+<li>the third argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> if the argument is present.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": substr("test string", 6, 3), "v2": substr1("test string", 6, 3) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": "tri", "v2": "str" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>substring</tt>.</p></div>
+<div class="section">
+<h3><a name="trim"></a>trim</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">trim(string[, chars]);
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
+<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a trimmed, new <tt>string</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">trim("i like x-phone", "xphoen");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">" like "
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="upper"></a>upper</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">upper(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">upper("hello")
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"HELLO"
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div>
+<div class="section">
+<h3><a name="string_concat"></a>string_concat</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">string_concat(array)
+</pre></div></div>
+</li>
+<li>
+
+<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of <tt>string</tt>s (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the concatenated <tt>string</tt> value,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">string_concat(["ASTERIX", " ", "ROCKS!"]);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"ASTERIX ROCKS!"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="string_join"></a>string_join</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">string_join(array, string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
+<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the joined <tt>string</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
+<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-array value, or contains any other non-string value,</li>
+<li>or, the second argument is any other non-string value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">string_join(["ASTERIX", "ROCKS~"], "!! ");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"ASTERIX!! ROCKS~"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">string_to_codepoint(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts the string <tt>string</tt> to its code_based representation.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">string_to_codepoint("Hello ASTERIX!");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">codepoint_to_string(array)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"Hello ASTERIX!"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="substring_before"></a>substring_before</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">substring_before(string, string_pattern)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
+<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> that represents the substring,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">substring_before(" like x-phone", "x-phone");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">" like "
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="substring_after"></a>substring_after</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>substring_after(string, string_pattern);</p>
+</li>
+<li>
+
+<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
+<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> that represents the substring,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">substring_after(" like x-phone", "xph");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"one"
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
+<div class="section">
+<h3><a name="parse_binary"></a>parse_binary</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>parse_binary(string, encoding)</p>
+</li>
+<li>
+
+<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
+<li><tt>encoding</tt> : a string notation specifies the encoding type of the given <tt>string</tt>. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>[ parse_binary(“ABCDEF0123456789”,“hex”), parse_binary(“abcdef0123456789”,“HEX”), parse_binary(‘QXN0ZXJpeAE=’,“base64”) ];</p>
+</li>
+<li>
+
+<p>The expected result is:</p>
+<p>[ hex(“ABCDEF0123456789”), hex(“ABCDEF0123456789”), hex(“4173746572697801”) ]</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="print_binary"></a>print_binary</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>print_binary(binary, encoding)</p>
+</li>
+<li>
+
+<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
+<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">[ print_binary(hex("ABCDEF0123456789"), "base64"), print_binary(base64("q83vASNFZ4k="), "hex") ]
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result are:</p>
+
+<div>
+<div>
+<pre class="source">[ "q83vASNFZ4k=", "ABCDEF0123456789" ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="binary_length"></a>binary_length</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>binary_length(binary)</p>
+</li>
+<li>
+
+<p>Returns the number of bytes storing the binary data.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>bigint</tt> that represents the number of bytes,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-binary input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">binary_length(hex("00AA"))
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+<p>2</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="sub_binary"></a>sub_binary</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>sub_binary(binary, offset[, length])</p>
+</li>
+<li>
+
+<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
+<li><tt>offset</tt> : a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the starting offset of the sub binary in <tt>binary</tt> (starting at 0),</li>
+<li><tt>length</tt> : (Optional) a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the length of the sub binary.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>binary</tt> that represents the sub binary,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-binary value,</li>
+<li>or, the second argument is any other non-integer value,</li>
+<li>or, the third argument is any other non-integer value, if it is present.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">sub_binary(hex("AABBCCDD"), 4);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is</p>
+
+<div>
+<div>
+<pre class="source">hex("DD")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="binary_concat"></a>binary_concat</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>binary_concat(array)</p>
+</li>
+<li>
+
+<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of binaries (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
+</ul>
+</li>
+<li>Return Value :
+<ul>
+
+<li>the concatenated <tt>binary</tt> value,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>binary_concat([hex(“42”), hex(""), hex(‘42’)]);</p>
+</li>
+<li>
+
+<p>The expected result is</p>
+<p>hex(“4242”)</p>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
+<div class="section">
+<h3><a name="create_point"></a>create_point</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">create_point(x, y)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
+</li>
+<li>Arguments:</li>
+<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
+<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
+<li>Return Value:</li>
+<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-double input value will cause a type error.</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "point": create_point(30.0,70.0) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "point": point("30.0,70.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="create_line"></a>create_line</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">create_line(point1, point2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
+<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-point input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "line": create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "line": line("30.0,70.0 50.0,90.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="create_rectangle"></a>create_rectangle</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">create_rectangle(point1, point2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
+<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-point input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "rectangle": create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "rectangle": rectangle("30.0,70.0 50.0,90.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="create_circle"></a>create_circle</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">create_circle(point, radius)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
+<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-point value,</li>
+<li>or, the second argument is any other non-double value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "circle": create_circle(create_point(30.0,70.0), 5.0) }
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "circle": circle("30.0,70.0 5.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="create_polygon"></a>create_polygon</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">create_polygon(array)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates the primitive type <tt>polygon</tt> using the double values provided in the argument <tt>array</tt>. 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.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "polygon": create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "polygon": polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_x(point) or get_y(point)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point</tt> : a <tt>point</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-point input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "x_coordinate": get_x(create_point(2.3,5.0)), "y_coordinate": get_y(create_point(2.3,5.0)) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "x_coordinate": 2.3, "y_coordinate": 5.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_points"></a>get_points</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_points(spatial_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-spatial-object input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ point("1.0,1.0"), point("2.0,2.0"), point("3.0,3.0"), point("4.0,4.0") ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-circle input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "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))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "circle_radius": 1.0, "circle_center": point("6.0,3.0") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="spatial_distance"></a>spatial_distance</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">spatial_distance(point1, point2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point1</tt> : a <tt>point</tt>.</li>
+<li><tt>point2</tt> : a <tt>point</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-point input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">spatial_distance(point("47.44,80.65"), create_point(30.0,70.0));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">20.434678857275934
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="spatial_area"></a>spatial_area</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">spatial_area(spatial_2d_expression)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-2d-spatial-object will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">78.53981625
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
+<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-spatial-object input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">spatial_intersect(point("39.28,70.48"), create_rectangle(create_point(30.0,70.0), create_point(40.0,80.0)));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">true
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="spatial_cell"></a>spatial_cell</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
+<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
+<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
+<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first or second argument is any other non-point value,</li>
+<li>or, the second or third argument is any other non-double value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">spatial_cell(point("39.28,70.48"), create_point(20.0,50.0), 5.5, 6.0);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">rectangle("36.5,68.0 42.0,74.0");
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
+<p>AsterixDB supports queries with different similarity functions, including <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> and <a class="externalLink" href="https://en.wikipedia.org/wiki/Jaccard_index">Jaccard</a>.</p>
+<div class="section">
+<h3><a name="edit_distance"></a>edit_distance</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">edit_distance(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
+<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">edit_distance("SuzannaTillson", "Suzanna Tilson");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">2
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">edit_distance_check(expression1, expression2, threshold)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
+<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
+<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> with two items:
+<ul>
+
+<li>The first item contains a <tt>boolean</tt> value representing whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within the given threshold.</li>
+<li>The second item contains an <tt>integer</tt> that represents the edit distance of <tt>expression1</tt> and <tt>expression2</tt> if the first item is true.</li>
+<li>If the first item is false, then the second item is set to 2147483647.</li>
+</ul>
+</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first or second argument is any other non-string value,</li>
+<li>or, the third argument is any other non-bigint value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">edit_distance_check("happy","hapr",2);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ true, 2 ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">edit_distance_contains(expression1, expression2, threshold)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether <tt>expression1</tt> contains <tt>expression2</tt> with an <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> within a given threshold.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
+<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
+<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> with two items:
+<ul>
+
+<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
+<li>The second item contains an <tt>integer</tt> that represents the required edit distance for <tt>expression1</tt> to contain <tt>expression2</tt> if the first item is true.</li>
+</ul>
+</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first or second argument is any other non-string value,</li>
+<li>or, the third argument is any other non-bigint value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">edit_distance_contains("happy","hapr",2);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ true, 1 ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">similarity_jaccard(array1, array2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> of <tt>array1</tt> and <tt>array2</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
+<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
+</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">0.6
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">similarity_jaccard_check(array1, array2, threshold)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether <tt>array1</tt> and <tt>array2</tt> have a <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> greater than or equal to threshold. Again, the “check” version of Jaccard is faster than the “non_check” version.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
+<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
+<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> with two items:
+<ul>
+
+<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
+<li>The second item contains a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt> if it is greater than or equal to the threshold, or 0 otherwise.</li>
+</ul>
+</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
+<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first or second argument is any other non-array value,
+<ul>
+
+<li>or, the third argument is any other non-double value.</li>
+</ul>
+</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
+</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ false, 0.0 ]
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
+<div class="section">
+<h3><a name="word_tokens"></a>word_tokens</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">word_tokens(string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-string input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">word_tokens("I like the phone, awesome!");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ "i", "like", "the", "phone", "awesome" ]
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
+<div class="section">
+<h3><a name="get_year.2Fget_month.2Fget_day.2Fget_hour.2Fget_minute.2Fget_second.2Fget_millisecond"></a>get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Accessors for accessing fields in a temporal value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>temporal_value</tt> : a temporal value represented as one of the following types: <tt>date</tt>, <tt>datetime</tt>, <tt>time</tt>, and <tt>duration</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "year": get_year(date("2010-10-30")),
+ "month": get_month(datetime("1987-11-19T23:49:23.938")),
+ "day": get_day(date("2010-10-30")),
+ "hour": get_hour(time("12:23:34.930+07:00")),
+ "min": get_minute(duration("P3Y73M632DT49H743M3948.94S")),
+ "second": get_second(datetime("1987-11-19T23:49:23.938")),
+ "ms": get_millisecond(duration("P3Y73M632DT49H743M3948.94S"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "year": 2010, "month": 11, "day": 30, "hour": 5, "min": 28, "second": 23, "ms": 94 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">adjust_datetime_for_timezone(datetime, string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
+<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-datetime value,</li>
+<li>or, the second argument is any other non-string value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">adjust_datetime_for_timezone(datetime("2008-04-26T10:10:00"), "+08:00");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"2008-04-26T18:10:00.000+08:00"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">adjust_time_for_timezone(time, string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
+<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-time value,</li>
+<li>or, the second argument is any other non-string value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime("2008-04-26T10:10:00")), "+08:00");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"18:10:00.000+08:00"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
+<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-datetime value,</li>
+<li>or, the second argument is any other non-duration input value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">calendar_duration_from_datetime(
+ datetime("2016-03-26T10:10:00"),
+ datetime("2016-03-26T10:10:00") - datetime("2011-01-01T00:00:00")
+);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">duration("P5Y2M24DT10H10M")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-duration input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">get_year_month_duration(duration("P12M50DT10H"));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">year_month_duration("P1Y")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="months_from_year_month_duration.2Fms_from_day_time_duration"></a>months_from_year_month_duration/ms_from_day_time_duration</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-duration input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "months": months_from_year_month_duration(get_year_month_duration(duration("P5Y7MT50M"))),
+ "milliseconds": ms_from_day_time_duration(get_day_time_duration(duration("P5Y7MT50M")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{"months": 67, "milliseconds": 3000000}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">duration_from_months/duration_from_ms(number_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-duration input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">duration_from_months(8);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">duration("P8M")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">duration_from_interval(interval_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-duration input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "dr1" : duration_from_interval(interval(date("2010-10-30"), date("2010-12-21"))),
+ "dr2" : duration_from_interval(interval(datetime("2012-06-26T01:01:01.111"), datetime("2012-07-27T02:02:02.222"))),
+ "dr3" : duration_from_interval(interval(time("12:32:38"), time("20:29:20"))),
+ "dr4" : duration_from_interval(null)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "dr1": day_time_duration("P52D"),
+ "dr2": day_time_duration("P31DT1H1M1.111S"),
+ "dr3": day_time_duration("PT7H56M42S"),
+ "dr4": null
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="current_date"></a>current_date</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">current_date()
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the current date.</p>
+</li>
+<li>Arguments: None</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>date</tt> value of the date when the function is called.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="current_time"></a>current_time</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">current_time()
+</pre></div></div>
+</li>
+<li>
+
+<p>Get the current time</p>
+</li>
+<li>Arguments: None</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>time</tt> value of the time when the function is called.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="current_datetime"></a>current_datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">current_datetime()
+</pre></div></div>
+</li>
+<li>
+
+<p>Get the current datetime</p>
+</li>
+<li>Arguments: None</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_date_from_datetime(datetime)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>date</tt> value from the datetime,</li>
+<li>any other non-datetime input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_time_from_datetime(datetime)
+</pre></div></div>
+</li>
+<li>
+
+<p>Get the time value from the given datetime value <tt>datetime</tt></p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>time</tt> value from the datetime.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-datetime input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">get_time_from_datetime(datetime("2016-03-26T10:10:00"));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">time("10:10:00.000Z")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="day_of_week"></a>day_of_week</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">day_of_week(date)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds the day of the week for a given date (1_7)</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-date input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">day_of_week(datetime("2012-12-30T12:12:12.039Z"));
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">7
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">date_from_unix_time_in_days(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of days.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of seconds.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
+<ul>
+
+<li>Syntax:</li>
+</ul>
+<p>datetime_from_date_time(date,time)</p>
+<ul>
+
+<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
+<ul>
+
+<li>Arguments:</li>
+<li><tt>date</tt>: a <tt>date</tt> value</li>
+<li><tt>time</tt> a <tt>time</tt> value</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if
+<ul>
+
+<li>the first argument is any other non-date value,</li>
+<li>or, the second argument is any other non-time value.</li>
+</ul>
+</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">time_from_unix_time_in_ms(numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "date": date_from_unix_time_in_days(15800),
+ "datetime": datetime_from_unix_time_in_ms(1365139700000),
+ "time": time_from_unix_time_in_ms(3748)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "date": date("2013-04-05"), "datetime": datetime("2013-04-05T05:28:20.000Z"), "time": time("00:00:03.748Z") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">unix_time_from_date_in_days(date_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of days,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-date input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-datetime input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of seconds,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-datetime input value will cause a type error.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">unix_time_from_time_in_ms(time_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-datetime input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "date": date_from_unix_time_in_days(15800),
+ "datetime": datetime_from_unix_time_in_ms(1365139700000),
+ "time": time_from_unix_time_in_ms(3748)
+}
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "date": date("2013-04-05"), "datetime": datetime("2013-04-05T05:28:20.000Z"), "time": time("00:00:03.748Z") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
+<ul>
+
+<li>Syntax:</li>
+</ul>
+<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
+<ul>
+
+<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
+<li>Arguments:
+<ul>
+
+<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
+<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>.Characters used to create date expression:</li>
+<li><tt>h</tt> hours</li>
+<li><tt>m</tt> minutes</li>
+<li><tt>s</tt> seconds</li>
+<li><tt>n</tt> milliseconds</li>
+<li><tt>a</tt> am/pm</li>
+<li><tt>z</tt> timezone</li>
+<li><tt>Y</tt> year</li>
+<li><tt>M</tt> month</li>
+<li><tt>D</tt> day</li>
+<li><tt>W</tt> weekday</li>
+<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:</li>
+<li>the first argument is any other non-date value,</li>
+<li>the second argument is any other non-string value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">parse_time("30:30","m:s");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">time("00:30:30.000Z")
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
+</pre></div></div>
+</li>
+<li>
+
+<p>Creates a <tt>string</tt> representing a <tt>date/time/date_time</tt> value of the <tt>date</tt> using the formatting <tt>formatting_expression</tt></p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
+<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>. Characters used to create date expression:</li>
+<li><tt>h</tt> hours</li>
+<li><tt>m</tt> minutes</li>
+<li><tt>s</tt> seconds</li>
+<li><tt>n</tt> milliseconds</li>
+<li><tt>a</tt> am/pm</li>
+<li><tt>z</tt> timezone</li>
+<li><tt>Y</tt> year</li>
+<li><tt>M</tt> month</li>
+<li><tt>D</tt> day</li>
+<li><tt>W</tt> weekday</li>
+<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-date value,</li>
+<li>the second argument is any other non-string value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">print_time(time("00:30:30.000Z"),"m:s");
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"30:30"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_interval_start/get_interval_end(interval)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the start/end of the given interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval</tt>: the interval to be accessed.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the time instances of the interval) representing the starting or ending time,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-interval value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "start": get_interval_start(interval_start_from_date("1984-01-01", "P1Y")),
+ "end": get_interval_end(interval_start_from_date("1984-01-01", "P1Y"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "start": date("1984_01_01"), "end": date("1985_01_01") }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_interval_start_date.2Fget_interval_start_datetimeget_interval_start_time.2C_get_interval_end_date.2Fget_interval_end_datetime.2Fget_interval_end_time"></a>get_interval_start_date/get_interval_start_datetimeget_interval_start_time, get_interval_end_date/get_interval_end_datetime/get_interval_end_time</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_interval_start_date/get_interval_start_datetime/get_interval_start_time/get_interval_end_date/get_interval_end_datetime/get_interval_end_time(interval)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval</tt>: the interval to be accessed.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-interval value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "start1": get_interval_start_date(interval_start_from_date("1984-01-01", "P1Y")),
+ "end1": get_interval_end_date(interval_start_from_date("1984-01-01", "P1Y")),
+ "start2": get_interval_start_datetime(interval_start_from_datetime("1984-01-01T08:30:00.000", "P1Y1H")),
+ "end2": get_interval_end_datetime(interval_start_from_datetime("1984-01-01T08:30:00.000", "P1Y1H")),
+ "start3": get_interval_start_time(interval_start_from_time("08:30:00.000", "P1H")),
+ "end3": get_interval_end_time(interval_start_from_time("08:30:00.000", "P1H"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "start1": date("1984-01-01"),
+ "end1": date("1985-01-01"),
+ "start2": datetime("1984-01-01T08:30:00.000Z"),
+ "end2": datetime("1985-01-01T09:30:00.000Z"),
+ "start3": time("08:30:00.000Z"),
+ "end3": time("09:30:00.000Z")
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_overlapping_interval(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
+<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>interval</tt> that is overlapping <tt>interval1</tt> and <tt>interval2</tt>. If <tt>interval1</tt> and <tt>interval2</tt> do not overlap <tt>null</tt> is returned. Note each interval must be of the same type.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "overlap1": get_overlapping_interval(interval(time("11:23:39"), time("18:27:19")), interval(time("12:23:39"), time("23:18:00"))),
+ "overlap2": get_overlapping_interval(interval(time("12:23:39"), time("18:27:19")), interval(time("07:19:39"), time("09:18:00"))),
+ "overlap3": get_overlapping_interval(interval(date("1980-11-30"), date("1999-09-09")), interval(date("2013-01-01"), date("2014-01-01"))),
+ "overlap4": get_overlapping_interval(interval(date("1980-11-30"), date("2099-09-09")), interval(date("2013-01-01"), date("2014-01-01"))),
+ "overlap5": get_overlapping_interval(interval(datetime("1844-03-03T11:19:39"), datetime("2000-10-30T18:27:19")), interval(datetime("1989-03-04T12:23:39"), datetime("2009-10-10T23:18:00"))),
+ "overlap6": get_overlapping_interval(interval(datetime("1989-03-04T12:23:39"), datetime("2000-10-30T18:27:19")), interval(datetime("1844-03-03T11:19:39"), datetime("1888-10-10T23:18:00")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "overlap1": interval(time("12:23:39.000Z"), time("18:27:19.000Z")),
+ "overlap2": null,
+ "overlap3": null,
+ "overlap4": interval(date("2013-01-01"), date("2014_01_01")),
+ "overlap5": interval(datetime("1989-03-04T12:23:39.000Z"), datetime("2000-10-30T18:27:19.000Z")),
+ "overlap6": null
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_bin"></a>interval_bin</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
+<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
+<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
+<ul>
+
+<li>datetime +|_ year_month_duration</li>
+<li>datetime +|_ day_time_duration</li>
+<li>date +|_ year_month_duration</li>
+<li>date +|_ day_time_duration</li>
+<li>time +|_ day_time_duration</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
+<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "bin1": interval_bin(date("2010-10-30"), date("1990-01-01"), year_month_duration("P1Y")),
+ "bin2": interval_bin(datetime("1987-11-19T23:49:23.938"), datetime("1990-01-01T00:00:00.000Z"), year_month_duration("P6M")),
+ "bin3": interval_bin(time("12:23:34.930+07:00"), time("00:00:00"), day_time_duration("PT1M")),
+ "bin4": interval_bin(datetime("1987-11-19T23:49:23.938"), datetime("2013-01-01T00:00:00.000"), day_time_duration("PT24H"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "bin1": interval(date("2010-01-01"),date("2011-01-01")),
+ "bin2": interval(datetime("1987-07-01T00:00:00.000Z"), datetime("1988-01-01T00:00:00.000Z")),
+ "bin3": interval(time("05:23:00.000Z"), time("05:24:00.000Z")),
+ "bin4": interval(datetime("1987-11-19T00:00:00.000Z"), datetime("1987-11-20T00:00:00.000Z"))
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
+</pre></div></div>
+</li>
+<li>
+
+<p>Construct an <tt>interval</tt> value by the given starting <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> and the <tt>duration</tt> that the interval lasts.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>date/time/datetime</tt>: a <tt>string</tt> representing a <tt>date</tt>, <tt>time</tt> or <tt>datetime</tt>, or a <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> value, representing the starting time point.</li>
+<li><tt>duration</tt>: a <tt>string</tt> or <tt>duration</tt> value representing the duration of the interval. Note that duration cannot be negative value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
+<li>or, the second argument is any other non-duration value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval1": interval_start_from_date("1984-01-01", "P1Y"),
+ "interval2": interval_start_from_time(time("02:23:28.394"), "PT3H24M"),
+ "interval3": interval_start_from_datetime("1999-09-09T09:09:09.999", duration("P2M30D"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expectecd result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval1": interval(date("1984-01-01"), date("1985-01-01")),
+ "interval2": interval(time("02:23:28.394Z"), time("05:47:28.394Z")),
+ "interval3": interval(datetime("1999-09-09T09:09:09.999Z"), datetime("1999-12-09T09:09:09.999Z"))
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="overlap_bins"></a>overlap_bins</h3>
+<ul>
+
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type.</li>
+</ul>
+</li>
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval</tt>: an <tt>interval</tt> value</li>
+<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
+<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
+<ul>
+
+<li>datetime +|_ year_month_duration</li>
+<li>datetime +|_ day_time_duration</li>
+<li>date +|_ year_month_duration</li>
+<li>date +|_ day_time_duration</li>
+<li>time +|_ day_time_duration</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>. Note that the internal type as <tt>time_to_bin</tt> and <tt>duration_bin_size</tt>.</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first arugment is any other non-interval value,</li>
+<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
+<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "timebins": overlap_bins(interval(time("17:23:37"), time("18:30:21")), time("00:00:00"), day_time_duration("PT30M")),
+ "datebins": overlap_bins(interval(date("1984-03-17"), date("2013-08-22")), date("1990-01-01"), year_month_duration("P10Y")),
+ "datetimebins": overlap_bins(interval(datetime("1800-01-01T23:59:48.938"), datetime("2015-07-26T13:28:30.218")),
+ datetime("1900-01-01T00:00:00.000"), year_month_duration("P100Y"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "timebins": [
+ interval(time("17:00:00.000Z"), time("17:30:00.000Z")),
+ interval(time("17:30:00.000Z"), time("18:00:00.000Z")),
+ interval(time("18:00:00.000Z"), time("18:30:00.000Z")),
+ interval(time("18:30:00.000Z"), time("19:00:00.000Z"))
+ ],
+ "datebins": [
+ interval(date("1980-01-01"), date("1990-01-01")),
+ interval(date("1990-01-01"), date("2000-01-01")),
+ interval(date("2000-01-01"), date("2010-01-01")),
+ interval(date("2010-01-01"), date("2020-01-01"))
+ ],
+ "datetimebins": [
+ interval(datetime("1800-01-01T00:00:00.000Z"), datetime("1900-01-01T00:00:00.000Z")),
+ interval(datetime("1900-01-01T00:00:00.000Z"), datetime("2000-01-01T00:00:00.000Z")),
+ interval(datetime("2000-01-01T00:00:00.000Z"), datetime("2100-01-01T00:00:00.000Z"))
+ ]
+};
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div>
+<div class="section">
+<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_before(interval1, interval2)
+interval_after(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These two functions check whether an interval happens before/after another interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_before(interval1, interval2)</tt> is true if and only if <tt>interval1.end < interval2.start</tt>, and <tt>interval_after(interval1, interval2)</tt> is true if and only if <tt>interval1.start > interval2.end</tt>.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval_before": interval_before(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2005-05-01"), date("2012-09-09"))),
+ "interval_after": interval_after(interval(date("2005-05-01"), date("2012-09-09")),
+ interval(date("2000-01-01"), date("2005-01-01")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "interval_before": true, "interval_after": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_covers(interval1, interval2)
+interval_covered_by(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These two functions check whether one interval covers the other interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>
+
+<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
+<p>interval1.start <= interval2.start AND interval1.end >= interval2.end</p>
+<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
+<p>interval2.start <= interval1.start AND interval2.end >= interval1.end</p>
+</li>
+<li>
+
+<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
+</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval_covers": interval_covers(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2000-03-01"), date("2004-09-09"))),
+ "interval_covered_by": interval_covered_by(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2004-09-10"), date("2012-08-01")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "interval_covers": true, "interval_covered_by": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_overlaps(interval1, interval2)
+interval_overlapped_by(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These functions check whether two intervals overlap with each other.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
+<p>interval1.start < interval2.start AND interval2.end > interval1.end AND interval1.end > interval2.start</p></li>
+</ul>
+<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
+
+<div>
+<div>
+<pre class="source">interval2.start < interval1.start
+AND interval1.end > interval2.end
+AND interval2.end > interval1.start
+</pre></div></div>
+
+<ul>
+
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+<p>Note that <tt>interval_overlaps</tt> and <tt>interval_overlapped_by</tt> are following the Allen’s relations on the definition of overlap.</p>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "overlaps": interval_overlaps(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2004-05-01"), date("2012-09-09"))),
+ "overlapped_by": interval_overlapped_by(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2004-05-01"), date("2012-09-09"))))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "overlaps": true, "overlapped_by": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
+<p>Note that <tt>interval_overlapping</tt> is not an Allen’s Relation, but syntactic sugar we added for the case that the intersect of two intervals is not empty. Basically this function returns true if any of these functions return true: <tt>interval_overlaps</tt>, <tt>interval_overlapped_by</tt>, <tt>interval_covers</tt>, or <tt>interval_covered_by</tt>.</p>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_overlapping(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>This functions check whether two intervals share any points with each other.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>
+
+<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
+<p>interval1.start < interval2.end AND interval1.end > interval2.start</p>
+</li>
+<li>
+
+<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
+</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "overlapping1": interval_overlapping(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2004-05-01"), date("2012-09-09"))),
+ "overlapping2": interval_overlapping(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2004-09-10"), date("2006-12-31")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "overlapping1": true, "overlapping2": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_meets(interval1, interval2)
+interval_met_by(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These two functions check whether an interval meets with another interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_meets(interval1, interval2)</tt> is true if and only if <tt>interval1.end = interval2.start</tt>, and <tt>interval_met_by(interval1, interval2)</tt> is true if and only if <tt>interval1.start = interval2.end</tt>. If any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "meets": interval_meets(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2005-01-01"), date("2012-09-09"))),
+ "metby": interval_met_by(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2004-09-10"), date("2006-08-01")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "meets": true, "metby": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_starts(interval1, interval2)
+interval_started_by(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These two functions check whether one interval starts with the other interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
+<p>interval1.start = interval2.start AND interval1.end <= interval2.end</p></li>
+</ul>
+<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
+
+<div>
+<div>
+<pre class="source">interval1.start = interval2.start
+AND interval2.end <= interval1.end
+</pre></div></div>
+
+<ul>
+
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval_starts": interval_starts(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("2000-01-01"), date("2012-09-09"))),
+ "interval_started_by": interval_started_by(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2006-08-01"), date("2006-08-02")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "interval_starts": true, "interval_started_by": true }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">interval_ends(interval1, interval2)
+interval_ended_by(interval1, interval2)
+</pre></div></div>
+</li>
+<li>
+
+<p>These two functions check whether one interval ends with the other interval.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>
+
+<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
+<p>interval1.end = interval2.end AND interval1.start >= interval2.start</p>
+<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
+<p>interval2.end = interval1.end AND interval2.start >= interval1.start</p>
+</li>
+<li>
+
+<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
+</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-interval input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Examples:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "interval_ends": interval_ends(interval(date("2000-01-01"), date("2005-01-01")),
+ interval(date("1998-01-01"), date("2005-01-01"))),
+ "interval_ended_by": interval_ended_by(interval(date("2006-08-01"), date("2007-03-01")),
+ interval(date("2006-09-10"), date("2007-03-01")))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "interval_ends": true, "interval_ended_by": true }
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
+<div class="section">
+<h3><a name="get_object_fields"></a>get_object_fields</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_object_fields(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Access the object field names, type and open status for a given object.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : a object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an array of <tt>object</tt> values that include the field_name <tt>string</tt>, field_type <tt>string</tt>, is_open <tt>boolean</tt> (used for debug purposes only: <tt>true</tt> if field is open and <tt>false</tt> otherwise), and optional nested <tt>orderedList</tt> for the values of a nested object,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
+<li>any other non-object input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">get_object_fields(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"},
+ "related": ["Hivestrix", "Preglix", "Apache VXQuery"]
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ { "field-name": "id", "field-type": "INT64", "is-open": false },
+ { "field-name": "project", "field-type": "STRING", "is-open": false },
+ { "field-name": "address", "field-type": "RECORD", "is-open": false,
+ "nested": [
+ { "field-name": "city", "field-type": "STRING", "is-open": false },
+ { "field-name": "state", "field-type": "STRING", "is-open": false }
+ ]
+ },
+ { "field-name":
+ "related",
+ "field-type": "ORDEREDLIST",
+ "is-open": false,
+ "list": [
+ { "field-type": "STRING" },
+ { "field-type": "STRING" },
+ { "field-type": "STRING" }
+ ]
+ }
+]
+</pre></div></div>
+</li>
+</ul>
+<p>]</p></div>
+<div class="section">
+<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_object_field_value(input_object, string)
+</pre></div></div>
+</li>
+<li>
+
+<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
+<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>any</tt> value saved in the designated field of the object,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-object value,</li>
+<li>or, the second argument is any other non-string value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">get_object_field_value({
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"},
+ "related": ["Hivestrix", "Preglix", "Apache VXQuery"]
+ },
+ "project"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">"AsterixDB"
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_remove_fields(input_object, field_names)
+</pre></div></div>
+</li>
+<li>
+
+<p>Remove indicated fields from a object given a list of field names.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt>: a object value.</li>
+<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>a new object value without the fields listed in the second argument,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-object value,</li>
+<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_remove_fields(
+ {
+ "id":1,
+ "project":"AsterixDB",
+ "address":{"city":"Irvine", "state":"CA"},
+ "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+ },
+ [["address", "city"], "related"]
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id":1,
+ "project":"AsterixDB",
+ "address":{ "state": "CA" }
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_add_fields"></a>object_add_fields</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_add_fields(input_object, fields)
+</pre></div></div>
+</li>
+<li>
+
+<p>Add fields to a object given a list of field names.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : a object value.</li>
+<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a new object value with the new fields included,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li>the first argument is any other non-object value,</li>
+<li>the second argument is any other non-array value, or contains non-object items.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_add_fields(
+ {
+ "id":1,
+ "project":"AsterixDB",
+ "address":{"city":"Irvine", "state":"CA"},
+ "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+ },
+ [{"field-name":"employment_location", "field-value":create_point(30.0,70.0)}]
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id":1,
+ "project":"AsterixDB",
+ "address":{"city":"Irvine", "state":"CA"},
+ "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+ "employment_location": point("30.0,70.0")
+ }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_merge"></a>object_merge</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_merge(object1, object2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Merge two different objects into a new object.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>object1</tt> : a object value.</li>
+<li><tt>object2</tt> : a object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a new object value with fields from both input objects. If a field’s names in both objects are the same, an exception is issued,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>any other non-object input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_merge(
+ {
+ "id":1,
+ "project":"AsterixDB",
+ "address":{"city":"Irvine", "state":"CA"},
+ "related":["Hivestrix", "Preglix", "Apache VXQuery"]
+ },
+ {
+ "user_id": 22,
+ "employer": "UC Irvine",
+ "employment_type": "visitor"
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "employment_type": "visitor",
+ "address": {
+ "city": "Irvine",
+ "state": "CA"
+ },
+ "related": [
+ "Hivestrix",
+ "Preglix",
+ "Apache VXQuery"
+ ],
+ "user_id": 22,
+ "project": "AsterixDB",
+ "employer": "UC Irvine",
+ "id": 1
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_length"></a>object_length</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_length(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns number of top-level fields in the given object</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an integer that represents the number of top-level fields in the given object,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_length(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"},
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">3
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_names"></a>object_names</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_names(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns names of top-level fields in the given object</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an array with top-level field names of the given object,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_names(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"},
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ "id", "project", "address" ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_remove"></a>object_remove</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_remove(input_object, field_name)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+<li><tt>field_name</tt> : a string field name.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
+<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
+<li><tt>null</tt> if the argument <tt>input_object</tt> is <tt>null</tt> or any other non-object value, or the argument <tt>field_name</tt> is <tt>null</tt> or any other non-string value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_remove(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ , "address"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id": 1,
+ "project": "AsterixDB",
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_rename"></a>object_rename</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_rename(input_object, old_field, new_field)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt></p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
+<li><tt>new_field</tt> : a string representing the new field name to replace <tt>old_field</tt> inside the object <tt>input_object</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>A new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is <tt>null</tt> or <tt>input_object</tt> is non-object value, or <tt>old_field</tt> is non-string value, or <tt>new_field</tt> is any non-string value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_rename(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ , "address"
+ , "location"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id": 1,
+ "project": "AsterixDB",
+ "location": {"city": "Irvine", "state": "CA"}
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_unwrap"></a>object_unwrap</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_unwrap(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
+<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> is null, or an empty object, or there is more than one name-value pair in <tt>input_object</tt>, or any non-object value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_unwrap(
+ {
+ "id": 1
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ 1
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_replace"></a>object_replace</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_replace(input_object, old_value, new_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt></p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
+<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>A new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
+<li>a type error will be raised if:
+<ul>
+
+<li><tt>old_value</tt> is not a primitive type value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_replace(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ , "AsterixDB"
+ , "Apache AsterixDB"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id": 1,
+ "project": "Apache AsterixDB",
+ "location": {"city": "Irvine", "state": "CA"}
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_add"></a>object_add</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_add(input_object, field_name, field_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+<li><tt>field_name</tt> : a string representing a field name to be added.</li>
+<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>A new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>,</li>
+<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not a string,</li>
+<li><tt>input_object</tt> if <tt>field_name</tt>already exists in <tt>input_object</tt> or <tt>field_value</tt> is missing.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_add(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ , "company"
+ , "Apache"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id": 1,
+ "project": "AsterixDB",
+ "location": {"city": "Irvine", "state": "CA"},
+ "company": "Apache"
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_put"></a>object_put</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_put(input_object, field_name, field_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Adds, modifies, or removes a field of an object.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+<li><tt>field_name</tt> : a string representing a field name to be added.</li>
+<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>, or with updated <tt>field_name</tt> value to <tt>field_value</tt> if <tt>field_name</tt> already exists in <tt>input_object</tt>, or with <tt>field_name</tt>removed if <tt>field_name</tt> already exists in <tt>input_object</tt> and <tt>field_value</tt> is <tt>missing</tt>,</li>
+<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not not a string.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_put(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ , "project"
+ , "Apache AsterixDB"
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "id": 1,
+ "project": "Apache AsterixDB",
+ "location": {"city": "Irvine", "state": "CA"}
+}
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_values"></a>object_values</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_values(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>An array of the values of the fields in <tt>input_object</tt>,</li>
+<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_values(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ 1,
+ "AsterixDB",
+ {"city": "Irvine", "state": "CA"}
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="object_pairs"></a>object_pairs</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">object_pairs(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an array of objects describing fields of <tt>input_object</tt>. For each field of the <tt>input_object</tt> the returned array contains an object with two fields <tt>name</tt> and <tt>value</tt> which are set to the <tt>input_object</tt>’s field name and value.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>input_object</tt> : an object value.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
+<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">object_pairs(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ { "name": "id", "value": 1 },
+ { "name": "project", "value": "AsterixDB" },
+ { "name": "address", "value": {"city": "Irvine", "state": "CA"} }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="pairs"></a>pairs</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">pairs(input_object)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns an array of arrays describing fields of <tt>input_object</tt>, including nested fields. For each field of the <tt>input_object</tt> the returned array contains an array with two elements. The first element is the name and the second one is the value of the <tt>input_object</tt>’s field. The input object is introspected recursively, so all fields of its nested objects are returned. Nested objects contained in arrays and multisets are also processed by this function.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>An array of arrays with name, value pairs of the fields in <tt>input_object</tt>, including nested fields. Each inner array has exactly two items: name and value of the <tt>input_object</tt>’s field.</li>
+<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
+<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">pairs(
+ {
+ "id": 1,
+ "project": "AsterixDB",
+ "address": {"city": "Irvine", "state": "CA"}
+ }
+ );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ [ "id", 1 ],
+ [ "project", "AsterixDB" ],
+ [ "address", { "city": "Irvine", "state": "CA" } ],
+ [ "city", "Irvine" ],
+ [ "state", "CA" ]
+]
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
+<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
+<p>The query language also supports standard SQL aggregate functions (e.g., <tt>MIN</tt>, <tt>MAX</tt>, <tt>SUM</tt>, <tt>COUNT</tt>, and <tt>AVG</tt>). Note that these are not real functions in the query language, but just syntactic sugars over corresponding builtin aggregate functions (e.g., <tt>ARRAY_MIN</tt>, <tt>ARRAY_MAX</tt>, <tt>ARRAY_SUM</tt>, <tt>ARRAY_COUNT</tt>, and <tt>ARRAY_AVG</tt>). Refer to <a href="manual.html#SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a> for details.</p>
+<p>The <tt>DISTINCT</tt> keyword may be used with built-in aggregate functions and standard SQL aggregate functions. It may also be used with aggregate functions used as window functions. It determines whether the function aggregates all values in the group, or distinct values only. Refer to <a href="manual.html#Aggregation_functions">Aggregation Functions</a> for details.</p>
+<p>Aggregate functions may be used as window functions when they are used with an OVER clause. Refer to <a href="manual.html#Over_clauses">OVER Clauses</a> for details.</p>
+<div class="section">
+<h3><a name="array_count"></a>array_count</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_count(collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the number of non-null and non-missing items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li>any other non-array and non-multiset input value will cause an error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">5
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_avg"></a>array_avg</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_avg(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">1.725
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_sum"></a>array_sum</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_sum(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sum of non-null and non-missing items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the sum of the non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">6.9
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_min"></a>array_min</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_min(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the min value of non-null and non-missing values in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among numeric items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
+<li>any other non-array and non-multiset input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">0.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_max"></a>array_max</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_max(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the max value of non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among numeric items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
+<li>any other non-array and non-multiset input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">3.4
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_stddev_samp(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">1.4591664287073858
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_stddev_pop(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">1.2636751956100112
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_var_samp"></a>array_var_samp</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_var_samp(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">2.1291666666666664
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_var_pop"></a>array_var_pop</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_var_pop(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">1.5968749999999998
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_skewness"></a>array_skewness</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_skewness(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">-0.04808451539164242
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">array_kurtosis(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the non-null and non-missing numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
+<li>any other non-array and non-multiset input value will cause a type error,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">-1.342049701096427
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_count"></a>strict_count</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_count(collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the number of items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
+<li>or a <tt>null</tt> value,</li>
+<li>or a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_count( [1, 2, null, missing] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">4
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_avg"></a>strict_avg</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_avg(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the average value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_avg( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">200.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_sum"></a>strict_sum</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_sum(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sum of the items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the sum of the numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_sum( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">600
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_min"></a>strict_min</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_min(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the min value of comparable items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the min value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among numeric items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
+<li>any other non-array and non-multiset input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_min( [10.2, 100, 5] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">5.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_max"></a>strict_max</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_max(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the max value of numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>The max value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among numeric items.</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
+<li>any other non-array and non-multiset input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_max( [10.2, 100, 5] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">100.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_stddev_samp(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_stddev_samp( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">100.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_stddev_pop(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_stddev_pop( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">81.64965809277261
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_var_samp(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the sample variance value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_var_samp( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">10000.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_var_pop(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the population variance value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_var_pop( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">6666.666666666667
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_skewness"></a>strict_skewness</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_skewness(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the skewness value of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_skewness( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">0.0
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">strict_kurtosis(num_collection)
+</pre></div></div>
+</li>
+<li>
+
+<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>num_collection</tt> could be:
+<ul>
+
+<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
+<li>or, a <tt>null</tt> value,</li>
+<li>or, a <tt>missing</tt> value.</li>
+</ul>
+</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
+<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
+<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
+<li>any other non-numeric value in the input collection will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">strict_kurtosis( [100, 200, 300] );
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">-1.5
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
+<div class="section">
+<h3><a name="greatest"></a>greatest</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">greatest(numeric_value1, numeric_value2, ...)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the greatest value among arguments.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li>….</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the greatest values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among items.</li>
+<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": greatest(1, 2, 3), "v2": greatest(float("0.5"), double("-0.5"), 5000) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 3, "v2": 5000.0 }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="least"></a>least</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">least(numeric_value1, numeric_value2, ...)
+</pre></div></div>
+</li>
+<li>
+
+<p>Computes the least value among arguments.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
+<li>….</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>the least values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-> <tt>smallint</tt>-><tt>integer</tt>-><tt>bigint</tt>-><tt>float</tt>-><tt>double</tt>) among items.</li>
+<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
+<li>any other non-numeric input value will cause a type error.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": least(1, 2, 3), "v2": least(float("0.5"), double("-0.5"), 5000) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 1, "v2": -0.5 }
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
+<div class="section">
+<h3><a name="get_type"></a>get_type</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">get_type(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a string describing the type of the given <tt>expr</tt>. This includes incomplete information types (i.e. <tt>missing</tt> and <tt>null</tt>).</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": get_type(true),
+ "b": get_type(false),
+ "c": get_type(null),
+ "d": get_type(missing),
+ "e": get_type("d"),
+ "f": gettype(4.0),
+ "g": gettype(5),
+ "h": gettype(["1", 2]),
+ "i": gettype({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": "boolean", "b": "boolean", "c": "null", "d": "missing", "e": "string", "f": "double", "g": "bigint", "h": "array", "i": "object" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>gettype</tt>.</p></div>
+<div class="section">
+<h3><a name="is_array"></a>is_array</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_array(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_array(true),
+ "b": is_array(false),
+ "c": isarray(null),
+ "d": isarray(missing),
+ "e": isarray("d"),
+ "f": isarray(4.0),
+ "g": isarray(5),
+ "h": isarray(["1", 2]),
+ "i": isarray({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": true, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isarray</tt>.</p></div>
+<div class="section">
+<h3><a name="is_multiset"></a>is_multiset</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_multiset(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_multiset(true),
+ "b": is_multiset(false),
+ "c": is_multiset(null),
+ "d": is_multiset(missing),
+ "e": is_multiset("d"),
+ "f": ismultiset(4.0),
+ "g": ismultiset(["1", 2]),
+ "h": ismultiset({"a":1}),
+ "i": ismultiset({{"hello", 9328, "world", [1, 2, null]}})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ismultiset</tt>.</p></div>
+<div class="section">
+<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_atomic(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_atomic(true),
+ "b": is_atomic(false),
+ "c": isatomic(null),
+ "d": isatomic(missing),
+ "e": isatomic("d"),
+ "f": isatom(4.0),
+ "g": isatom(5),
+ "h": isatom(["1", 2]),
+ "i": isatom({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": true, "b": true, "c": null, "e": true, "f": true, "g": true, "h": false, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
+<div class="section">
+<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_boolean(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": isboolean(true),
+ "b": isboolean(false),
+ "c": is_boolean(null),
+ "d": is_boolean(missing),
+ "e": isbool("d"),
+ "f": isbool(4.0),
+ "g": isbool(5),
+ "h": isbool(["1", 2]),
+ "i": isbool({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": true, "b": true, "c": null, "e": false, "f": false, "g": false, "h": false, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
+<div class="section">
+<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_binary(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_binary(true),
+ "b": is_binary(false),
+ "c": isbinary(null),
+ "d": isbinary(missing),
+ "e": isbin(point("1,2")),
+ "f": isbin(hex("ABCDEF0123456789")),
+ "g": is_bin(sub_binary(hex("AABBCCDD"), 4)),
+ "h": is_bin(2),
+ "i": is_bin({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": true, "g": true, "h": false, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
+<div class="section">
+<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_number(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a numeric value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>smallint</tt>/<tt>tinyint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_number(true),
+ "b": is_number(false),
+ "c": isnumber(null),
+ "d": isnumber(missing),
+ "e": isnumber("d"),
+ "f": isnum(4.0),
+ "g": isnum(5),
+ "h": isnum(["1", 2]),
+ "i": isnum({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": true, "g": true, "h": false, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
+<div class="section">
+<h3><a name="is_point"></a>is_point</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_point(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_point(true),
+ "b": is_point(false),
+ "c": is_point(null),
+ "d": is_point(missing),
+ "e": is_point(point("1,2")),
+ "f": ispoint(line("30.0,70.0 50.0,90.0")),
+ "g": ispoint(rectangle("30.0,70.0 50.0,90.0")),
+ "h": ispoint(circle("30.0,70.0 5.0")),
+ "i": ispoint(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": ispoint(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": false, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ispoint</tt>.</p></div>
+<div class="section">
+<h3><a name="is_line"></a>is_line</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_line(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_line(true),
+ "b": is_line(false),
+ "c": is_line(null),
+ "d": is_line(missing),
+ "e": is_line(point("1,2")),
+ "f": isline(line("30.0,70.0 50.0,90.0")),
+ "g": isline(rectangle("30.0,70.0 50.0,90.0")),
+ "h": isline(circle("30.0,70.0 5.0")),
+ "i": isline(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": isline(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": true, "g": false, "h": false, "i": false, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isline</tt>.</p></div>
+<div class="section">
+<h3><a name="is_rectangle"></a>is_rectangle</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_rectangle(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_rectangle(true),
+ "b": is_rectangle(false),
+ "c": is_rectangle(null),
+ "d": is_rectangle(missing),
+ "e": is_rectangle(point("1,2")),
+ "f": isrectangle(line("30.0,70.0 50.0,90.0")),
+ "g": isrectangle(rectangle("30.0,70.0 50.0,90.0")),
+ "h": isrectangle(circle("30.0,70.0 5.0")),
+ "i": isrectangle(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": isrectangle(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": true, "h": false, "i": false, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isrectangle</tt>.</p></div>
+<div class="section">
+<h3><a name="is_circle"></a>is_circle</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_circle(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_circle(true),
+ "b": is_circle(false),
+ "c": is_circle(null),
+ "d": is_circle(missing),
+ "e": is_circle(point("1,2")),
+ "f": iscircle(line("30.0,70.0 50.0,90.0")),
+ "g": iscircle(rectangle("30.0,70.0 50.0,90.0")),
+ "h": iscircle(circle("30.0,70.0 5.0")),
+ "i": iscircle(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": iscircle(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": true, "i": false, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>iscircle</tt>.</p></div>
+<div class="section">
+<h3><a name="is_polygon"></a>is_polygon</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_polygon(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_polygon(true),
+ "b": is_polygon(false),
+ "c": is_polygon(null),
+ "d": is_polygon(missing),
+ "e": is_polygon(point("1,2")),
+ "f": ispolygon(line("30.0,70.0 50.0,90.0")),
+ "g": ispolygon(rectangle("30.0,70.0 50.0,90.0")),
+ "h": ispolygon(circle("30.0,70.0 5.0")),
+ "i": ispolygon(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": ispolygon(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ispolygon</tt>.</p></div>
+<div class="section">
+<h3><a name="is_spatial"></a>is_spatial</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_spatial(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a spatial value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt>/<tt>line</tt>/<tt>rectangle</tt>/<tt>circle</tt>/<tt>polygon</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_spatial(true),
+ "b": is_spatial(false),
+ "c": is_spatial(null),
+ "d": is_spatial(missing),
+ "e": is_spatial(point("1,2")),
+ "f": isspatial(line("30.0,70.0 50.0,90.0")),
+ "g": isspatial(rectangle("30.0,70.0 50.0,90.0")),
+ "h": isspatial(circle("30.0,70.0 5.0")),
+ "i": isspatial(polygon("1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0")),
+ "j": isspatial(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": true, "g": true, "h": true, "i": true, "j": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isspatial</tt>.</p></div>
+<div class="section">
+<h3><a name="is_date"></a>is_date</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_date(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_date(true),
+ "b": is_date(false),
+ "c": is_date(null),
+ "d": is_date(missing),
+ "e": is_date(date("-19700101")),
+ "f": isdate(date("2013-01-01")),
+ "g": isdate(time("12:12:12.039Z")),
+ "h": isdate(datetime("2013-01-01T12:12:12.039Z")),
+ "i": isdate(duration("P100Y12MT12M")),
+ "j": isdate(interval(date("2013-01-01"), date("20130505"))),
+ "k": isdate(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": true, "g": false, "h": false, "i": false, "j": false, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isdate</tt>.</p></div>
+<div class="section">
+<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_datetime(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_datetime(true),
+ "b": is_datetime(false),
+ "c": is_datetime(null),
+ "d": is_datetime(missing),
+ "e": is_datetime(datetime("2016-02-02T12:09:22.023Z")),
+ "f": isdatetime(datetime("2011-03-03T12:10:42.011Z")),
+ "g": isdatetime(time("12:12:12.039Z")),
+ "h": is_timestamp(datetime("2013-01-01T12:12:12.039Z")),
+ "i": is_timestamp(duration("P100Y12MT12M")),
+ "j": istimestamp(interval(date("2013-01-01"), date("20130505"))),
+ "k": istimestamp(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": true, "g": false, "h": true, "i": false, "j": false, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
+<div class="section">
+<h3><a name="is_time"></a>is_time</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_time(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source"> {
+ "a": is_time(true),
+ "b": is_time(false),
+ "c": is_time(null),
+ "d": is_time(missing),
+ "e": is_time(time("08:00:00.000Z")),
+ "f": istime(date("2013-01-01")),
+ "g": istime(time("12:12:12.039Z")),
+ "h": istime(datetime("2013-01-01T12:12:12.039Z")),
+ "i": istime(duration("P100Y12MT12M")),
+ "j": istime(interval(date("2013-01-01"), date("20130505"))),
+ "k": istime(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": true, "h": false, "i": false, "j": false, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>istime</tt>.</p></div>
+<div class="section">
+<h3><a name="is_duration"></a>is_duration</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_duration(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a duration value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source"> {
+ "a": is_duration(true),
+ "b": is_duration(false),
+ "c": is_duration(null),
+ "d": is_duration(missing),
+ "e": is_duration(duration("-PT20.943S")),
+ "f": isduration(date("2013-01-01")),
+ "g": isduration(time("12:12:12.039Z")),
+ "h": isduration(datetime("2013-01-01T12:12:12.039Z")),
+ "i": isduration(duration("P100Y12MT12M")),
+ "j": isduration(interval(date("2013-01-01"), date("20130505"))),
+ "k": isduration(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": true, "j": false, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isduration</tt>.</p></div>
+<div class="section">
+<h3><a name="is_interval"></a>is_interval</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_interval(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source"> {
+ "a": is_interval(true),
+ "b": is_interval(false),
+ "c": is_interval(null),
+ "d": is_interval(missing),
+ "e": is_interval(interval(datetime("2013-01-01T00:01:01.000Z"), datetime("2013-05-05T13:39:01.049Z"))),
+ "f": isinterval(date("2013-01-01")),
+ "g": isinterval(time("12:12:12.039Z")),
+ "h": isinterval(datetime("2013-01-01T12:12:12.039Z")),
+ "i": isinterval(duration("P100Y12MT12M")),
+ "j": isinterval(interval(date("2013-01-01"), date("20130505"))),
+ "k": isinterval(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": false, "j": true, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isinterval</tt>.</p></div>
+<div class="section">
+<h3><a name="is_temporal"></a>is_temporal</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_temporal(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a temporal value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>date/datetime/time/duration/year_month_duration/day_time_duration/interval</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source"> {
+ "a": is_temporal(true),
+ "b": is_temporal(false),
+ "c": is_temporal(null),
+ "d": is_temporal(missing),
+ "e": is_temporal(duration("-PT20.943S")),
+ "f": istemporal(date("2013-01-01")),
+ "g": istemporal(time("12:12:12.039Z")),
+ "h": istemporal(datetime("2013-01-01T12:12:12.039Z")),
+ "i": istemporal(duration("P100Y12MT12M")),
+ "j": istemporal(interval(date("2013-01-01"), date("20130505"))),
+ "k": istemporal(3)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": true, "g": true, "h": true, "i": true, "j": true, "k": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>istemporal</tt>.</p></div>
+<div class="section">
+<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_object(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_object(true),
+ "b": is_object(false),
+ "c": isobject(null),
+ "d": isobject(missing),
+ "e": isobj("d"),
+ "f": isobj(4.0),
+ "g": isobj(5),
+ "h": isobj(["1", 2]),
+ "i": isobj({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+<p>{ “a”: false, “b”: false, “c”: null, “e”: false, “f”: false, “g”: false, “h”: false, “i”: true }</p>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
+<div class="section">
+<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_string(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_string(true),
+ "b": isstring(false),
+ "c": isstring(null),
+ "d": isstr(missing),
+ "e": isstr("d"),
+ "f": isstr(4.0),
+ "g": isstr(5),
+ "h": isstr(["1", 2]),
+ "i": isstr({"a":1})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
+<div class="section">
+<h3><a name="is_uuid"></a>is_uuid</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_uuid(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
+<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source"> {
+ "a": is_uuid(true),
+ "b": is_uuid(false),
+ "c": is_uuid(null),
+ "d": is_uuid(missing),
+ "e": isuuid(4.0),
+ "f": isuuid(date("2013-01-01")),
+ "g": isuuid(uuid("5c848e5c-6b6a-498f-8452-8847a2957421"))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": false, "b": false, "c": null, "e": false, "f": false, "g": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isuuid</tt>.</p></div>
+<div class="section">
+<h3><a name="is_null"></a>is_null</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_null(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
+<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": is_null(null), "v2": is_null(1), "v3": is_null(missing) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isnull</tt>.</p></div>
+<div class="section">
+<h3><a name="is_missing"></a>is_missing</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_missing(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": is_missing(null), "v2": is_missing(1), "v3": is_missing(missing) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": false, "v2": false, "v3": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ismissing</tt>.</p></div>
+<div class="section">
+<h3><a name="is_unknown"></a>is_unknown</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">is_unknown(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt>/``missing<tt>value (</tt>true<tt>) or not (</tt>false`).</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": is_unknown(null), "v2": is_unknown(1), "v3": is_unknown(missing) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": true, "v2": false, "v3": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>isunknown</tt>.</p></div>
+<div class="section">
+<h3><a name="to_array"></a>to_array</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_array(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to an <tt>array</tt> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
+<li>if the argument is of <tt>multiset</tt> type then it is returned as an <tt>array</tt> with elements in an undefined order</li>
+<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_array("asterix"),
+ "v2": to_array(["asterix"]),
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": ["asterix"], "v2": ["asterix"] }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>toarray</tt>.</p></div>
+<div class="section">
+<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_atomic(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of primitive type then it is returned as is</li>
+<li>if the argument is of <tt>array</tt> or <tt>multiset</tt> type and has only one element then the result of invoking to_atomic() on that element is returned</li>
+<li>if the argument is of <tt>object</tt> type and has only one field then the result of invoking to_atomic() on the value of that field is returned</li>
+<li>otherwise <tt>null</tt> is returned</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_atomic("asterix"),
+ "v2": to_atomic(["asterix"]),
+ "v3": to_atomic([0, 1]),
+ "v4": to_atomic({"value": "asterix"}),
+ "v5": to_number({"x": 1, "y": 2})
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": "asterix", "v2": "asterix", "v3": null, "v4": "asterix", "v5": null }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
+<div class="section">
+<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_boolean(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to a <tt>boolean</tt> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
+<li>if the argument is of numeric type then <tt>false</tt> is returned if it is <tt>0</tt> or <tt>NaN</tt>, otherwise <tt>true</tt></li>
+<li>if the argument is of <tt>string</tt> type then <tt>false</tt> is returned if it’s empty, otherwise <tt>true</tt></li>
+<li>if the argument is of <tt>array</tt> or <tt>multiset</tt> type then <tt>false</tt> is returned if it’s size is <tt>0</tt>, otherwise <tt>true</tt></li>
+<li>if the argument is of <tt>object</tt> type then <tt>false</tt> is returned if it has no fields, otherwise <tt>true</tt></li>
+<li>type error is raised for all other input types</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_boolean(0),
+ "v2": to_boolean(1),
+ "v3": to_boolean(""),
+ "v4": to_boolean("asterix")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": false, "v2": true, "v3": false, "v4": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
+<div class="section">
+<h3><a name="to_bigint"></a>to_bigint</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_bigint(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to an integer value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>boolean</tt> type then <tt>1</tt> is returned if it is <tt>true</tt>, <tt>0</tt> if it is <tt>false</tt></li>
+<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
+<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
+<li>if the argument is of <tt>string</tt> type and can be parsed as integer then that integer value is returned, otherwise <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
+<li>type error is raised for all other input types</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_bigint(false),
+ "v2": to_bigint(true),
+ "v3": to_bigint(10),
+ "v4": to_bigint(float("1e100")),
+ "v5": to_bigint(double("1e1000")),
+ "v6": to_bigint("20")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0, "v2": 1, "v3": 10, "v4": 9223372036854775807, "v5": 9223372036854775807, "v6": 20 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>tobigint</tt>.</p></div>
+<div class="section">
+<h3><a name="to_double"></a>to_double</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_double(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to a <tt>double</tt> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>boolean</tt> type then <tt>1.0</tt> is returned if it is <tt>true</tt>, <tt>0.0</tt> if it is <tt>false</tt></li>
+<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
+<li>if the argument is of <tt>string</tt> type and can be parsed as <tt>double</tt> then that <tt>double</tt> value is returned, otherwise <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
+<li>type error is raised for all other input types</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_double(false),
+ "v2": to_double(true),
+ "v3": to_double(10),
+ "v4": to_double(11.5),
+ "v5": to_double("12.5")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0.0, "v2": 1.0, "v3": 10.0, "v4": 11.5, "v5": 12.5 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>todouble</tt>.</p></div>
+<div class="section">
+<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_number(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to a numeric value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of numeric type then it is returned as is</li>
+<li>if the argument is of <tt>boolean</tt> type then <tt>1</tt> is returned if it is <tt>true</tt>, <tt>0</tt> if it is <tt>false</tt></li>
+<li>if the argument is of <tt>string</tt> type and can be parsed as <tt>bigint</tt> then that <tt>bigint</tt> value is returned, otherwise if it can be parsed as <tt>double</tt> then that <tt>double</tt> value is returned, otherwise <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
+<li>type error is raised for all other input types</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_number(false),
+ "v2": to_number(true),
+ "v3": to_number(10),
+ "v4": to_number(11.5),
+ "v5": to_number("12.5")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": 0, "v2": 1, "v3": 10, "v4": 11.5, "v5": 12.5 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
+<div class="section">
+<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_object(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to an <tt>object</tt> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
+<li>otherwise an empty <tt>object</tt> is returned</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_object({"value": "asterix"}),
+ "v2": to_object("asterix")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": {"value": "asterix"}, "v2": {} }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
+<div class="section">
+<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">to_string(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Converts input value to a string value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
+<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
+<li>if the argument is of <tt>boolean</tt> type then <tt>"true"</tt> is returned if it is <tt>true</tt>, <tt>"false"</tt> if it is <tt>false</tt></li>
+<li>if the argument is of numeric type then its string representation is returned</li>
+<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
+<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
+<li>type error is raised for all other input types</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": to_string(false),
+ "v2": to_string(true),
+ "v3": to_string(10),
+ "v4": to_string(11.5),
+ "v5": to_string("asterix")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": "false", "v2": "true", "v3": "10", "v4": "11.5", "v5": "asterix" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
+<div class="section">
+<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_null(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
+<li>a value of the first non-<tt>null</tt> argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": if_null(),
+ "b": if_null(null),
+ "c": if_null(null, "asterixdb"),
+ "d": is_missing(if_null(missing))
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": null, "b": null, "c": "asterixdb", "d": true }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ifnull</tt>.</p></div>
+<div class="section">
+<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_missing(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
+<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": if_missing(),
+ "b": if_missing(missing),
+ "c": if_missing(missing, "asterixdb"),
+ "d": if_missing(null, "asterixdb")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": null, "b": null, "c": "asterixdb", "d": null }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ifmissing</tt>.</p></div>
+<div class="section">
+<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
+<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": if_missing_or_null(),
+ "b": if_missing_or_null(null, missing),
+ "c": if_missing_or_null(null, missing, "asterixdb")
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": null, "b": null, "c": "asterixdb" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
+<div class="section">
+<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_inf(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
+<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-infinite number argument</li>
+<li>the first non-infinite number argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_null(if_inf(null)),
+ "b": is_missing(if_inf(missing)),
+ "c": is_null(if_inf(double("INF"))),
+ "d": if_inf(1, null, missing) ],
+ "e": is_null(if_inf(null, missing, 1)) ],
+ "f": is_missing(if_inf(missing, null, 1)) ],
+ "g": if_inf(float("INF"), 1) ],
+ "h": to_string(if_inf(float("INF"), double("NaN"), 1)) ]
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": true, "b": true, "c": true, "d": 1, "e": true, "f": true, "g": 1, "h": "NaN" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ifinf</tt>.</p></div>
+<div class="section">
+<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_nan(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
+<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-<tt>NaN</tt> number argument</li>
+<li>the first non-<tt>NaN</tt> number argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_null(if_nan(null)),
+ "b": is_missing(if_nan(missing)),
+ "c": is_null(if_nan(double("NaN"))),
+ "d": if_nan(1, null, missing) ],
+ "e": is_null(if_nan(null, missing, 1)) ],
+ "f": is_missing(if_nan(missing, null, 1)) ],
+ "g": if_nan(float("NaN"), 1) ],
+ "h": to_string(if_nan(float("NaN"), double("INF"), 1)) ]
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": true, "b": true, "c": true, "d": 1, "e": true, "f": true, "g": 1, "h": "INF" }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ifnan</tt>.</p></div>
+<div class="section">
+<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite and non-<tt>NaN</tt> number argument</li>
+<li>a <tt>null</tt> if <tt>null</tt> argument or any other non-number argument was encountered before the first non-infinite and non-<tt>NaN</tt> number argument</li>
+<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": is_null(if_nan_or_inf(null)),
+ "b": is_missing(if_nan_or_inf(missing)),
+ "c": is_null(if_nan_or_inf(double("NaN"), double("INF"))),
+ "d": if_nan_or_inf(1, null, missing) ],
+ "e": is_null(if_nan_or_inf(null, missing, 1)) ],
+ "f": is_missing(if_nan_or_inf(missing, null, 1)) ],
+ "g": if_nan_or_inf(float("NaN"), float("INF"), 1) ],
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": true, "b": true, "c": true, "d": 1, "e": true, "f": true, "g": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
+<div class="section">
+<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">null_if(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if
+<ul>
+
+<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
+<li><tt>argument1</tt> = <tt>argument2</tt></li>
+</ul>
+</li>
+<li>a value of the first argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": null_if("asterixdb", "asterixdb"),
+ "b": null_if(1, 2)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": null, "b": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>nullif</tt>.</p></div>
+<div class="section">
+<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">missing_if(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>missing</tt> if
+<ul>
+
+<li>any argument is a <tt>missing</tt> value, or</li>
+<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
+</ul>
+</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
+<li>a value of the first argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": missing_if("asterixdb", "asterixdb")
+ "b": missing_if(1, 2),
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "b": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>missingif</tt>.</p></div>
+<div class="section">
+<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">nan_if(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
+<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
+<li>a value of the first argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": to_string(nan_if("asterixdb", "asterixdb")),
+ "b": nan_if(1, 2)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": "NaN", "b": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>nanif</tt>.</p></div>
+<div class="section">
+<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">posinf_if(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
+<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
+<li>a value of the first argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": to_string(posinf_if("asterixdb", "asterixdb")),
+ "b": posinf_if(1, 2)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": "+INF", "b": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>posinfif</tt>.</p></div>
+<div class="section">
+<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">neginf_if(expression1, expression2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
+<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
+<li>a value of the first argument otherwise</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "a": to_string(neginf_if("asterixdb", "asterixdb")),
+ "b": neginf_if(1, 2)
+};
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "a": "-INF", "b": 1 }
+</pre></div></div>
+</li>
+</ul>
+<p>The function has an alias <tt>neginfif</tt>.</p><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
+<div class="section">
+<h3><a name="uuid"></a>uuid</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">uuid()
+</pre></div></div>
+</li>
+<li>
+
+<p>Generates a <tt>uuid</tt>.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li>none</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a generated, random <tt>uuid</tt>.</li>
+</ul>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="len"></a>len</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+<p>len(array)</p>
+</li>
+<li>
+
+<p>Returns the length of the array array.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>array</tt> : an <tt>array</tt>, <tt>multiset</tt>, <tt>null</tt>, or <tt>missing</tt>, represents the collection that needs to be checked.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">len(["Hello", "World"])
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">2
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="not"></a>not</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">not(expr)
+</pre></div></div>
+</li>
+<li>
+
+<p>Inverts a <tt>boolean</tt> value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr</tt> : an expression</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
+<li>other non-boolean argument value will cause a type error.</li>
+</ul>
+</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">{ "v1": `not`(true), "v2": `not`(false), "v3": `not`(null), "v4": `not`(missing) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "v1": false, "v2": true, "v3": null }
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="random"></a>random</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">random( [seed_value] )
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a random number, accepting an optional seed value</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>seed_value</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value representing the seed number.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li>A random number of type <tt>double</tt> between 0 and 1,</li>
+<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">{
+ "v1": random(),
+ "v2": random(unix_time_from_datetime_in_ms(current_datetime()))
+};
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="range"></a>range</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">range(start_numeric_value, end_numeric_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Generates a series of <tt>bigint</tt> values based start the <tt>start_numeric_value</tt> until the <tt>end_numeric_value</tt>.</p>
+</li>
+<li>Arguments:</li>
+<li><tt>start_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the start value.</li>
+<li><tt>end_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the max final value.</li>
+<li>Return Value:
+<ul>
+
+<li>an array that starts with the integer value of <tt>start_numeric_value</tt> and ends with the integer value of <tt>end_numeric_value</tt>, where the value of each entry in the array is the integer successor of the value in the preceding entry.</li>
+</ul>
+</li>
+<li>Example:
+
+<div>
+<div>
+<pre class="source">range(0, 3);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[ 0, 1, 2, 3 ]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="switch_case"></a>switch_case</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">switch_case(
+ condition,
+ case1, case1_result,
+ case2, case2_result,
+ ...,
+ default, default_result
+)
+</pre></div></div>
+</li>
+<li>
+
+<p>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.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>condition</tt>: a variable (any type is allowed).</li>
+<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
+<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
+</ul>
+</li>
+<li>Example 1:
+
+<div>
+<div>
+<pre class="source">switch_case(
+ "a",
+ "a", 0,
+ "x", 1,
+ "y", 2,
+ "z", 3
+);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">0
+</pre></div></div>
+</li>
+<li>
+
+<p>Example 2:</p>
+
+<div>
+<div>
+<pre class="source">switch_case(
+ "a",
+ "x", 1,
+ "y", 2,
+ "z", 3
+);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">3
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="deep_equal"></a>deep_equal</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">deep_equal(expr1, expr2)
+</pre></div></div>
+</li>
+<li>
+
+<p>Assess the equality between two expressions of any type (e.g., object, arrays, or multiset). Two objects are deeply equal iff both their types and values are equal.</p>
+</li>
+<li>Arguments:
+<ul>
+
+<li><tt>expr1</tt> : an expression,</li>
+<li><tt>expr2</tt> : an expression.</li>
+</ul>
+</li>
+<li>Return Value:
+<ul>
+
+<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
+<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
+<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+
+<div>
+<div>
+<pre class="source">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"]
+ }
+);
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">false
+</pre></div></div>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Bitwise_Functions"></a><a name="BitwiseFunctions" id="BitwiseFunctions">Bitwise Functions</a></h2>
+<p>All Bit/Binary functions can only operate on 64-bit signed integers.</p>
+<p><b>Note:</b> All non-integer numbers and other data types result in null.</p>
+<p><b>Note:</b> The query language uses two’s complement representation.</p>
+<p>When looking at the value in binary form, bit 1 is the Least Significant Bit (LSB) and bit 32 is the Most Significant Bit (MSB).</p>
+<p>(MSB) Bit 32 → <tt>0000 0000 0000 0000 0000 0000 0000 0000</tt> ← Bit 1 (LSB)</p>
+<div class="section">
+<h3><a name="bitand"></a>bitand</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITAND(int_value1, int_value2, ... , int_valueN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result of a bitwise AND operation performed on all input integer values.</p>
+<p>The bitwise AND operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If all bits are 1, then the corresponding result bit is set to 1; otherwise it is set to 0 (zero).</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the bitwise AND between all of the input integers.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Compare 3 (0011 in binary) and 6 (0110 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": BITAND(3,6) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": 2 }
+</pre></div></div>
+
+<p>This results in 2 (0010 in binary) because only bit 2 is set in both 3 (00<b>1</b>1) and 6 (01<b>1</b>0).</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Compare 4.5 and 3 (0011 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": BITAND(4.5,3) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": null }
+</pre></div></div>
+
+<p>The result is null because 4.5 is not an integer.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>Compare 4.0 (0100 in binary) and 3 (0011 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": BITAND(4.0,3) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": 0 }
+</pre></div></div>
+
+<p>This results in 0 (zero) because 4.0 (0100) and 3 (0011) do not share any bits that are both 1.</p>
+</li>
+<li>
+
+<p>Example 4:</p>
+<p>Compare 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": BITAND(3,6,15) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitAND": 2 }
+</pre></div></div>
+
+<p>This results in 2 (0010 in binary) because only the 2nd bit from the right is 1 in all three numbers.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bitclear"></a>bitclear</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITCLEAR(int_value, positions)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result after clearing the specified bit, or array of bits in <tt>int_value</tt> using the given <tt>positions</tt>.</p>
+<p><b>Note:</b> Specifying a negative or zero bit position makes the function return a null.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to clear.</p>
+</li>
+<li>
+
+<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be cleared.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the result after clearing the bit or bits specified.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Clear bit 1 from 6 (0110 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": BITCLEAR(6,1) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": 6 }
+</pre></div></div>
+
+<p>This results in 6 (011<b>0</b> in binary) because bit 1 was already zero.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Clear bits 1 and 2 from 6 (01<b>10</b> in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": BITCLEAR(6,[1,2]) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": 4 }
+</pre></div></div>
+
+<p>This results in 4 (01<b>0</b>0 in binary) because bit 2 changed to zero.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>Clear bits 1, 2, 4, and 5 from 31 (0<b>11</b>1<b>11</b> in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": BITCLEAR(31,[1,2,4,5]) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitCLEAR": 4 }
+</pre></div></div>
+
+<p>This results in 4 (0<b>00</b>1<b>00</b>) because bits 1, 2, 4, and 5 changed to zero.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bitnot"></a>bitnot</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITNOT(int_value)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the results of a bitwise logical NOT operation performed on an integer value.</p>
+<p>The bitwise logical NOT operation reverses the bits in the value. For each value bit that is 1, the corresponding result bit will be set to 0 (zero); and for each value bit that is 0 (zero), the corresponding result bit will be set to 1.</p>
+<p><b>Note:</b> All bits of the integer will be altered by this operation.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bits to reverse.</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the result after performing the logical NOT operation.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Perform the NOT operation on 3 (0000 0000 0000 0000 0000 0000 0000 0011 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitNOT": BITNOT(3) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitNOT": -4 }
+</pre></div></div>
+
+<p>This results in -4 (<b>1111 1111 1111 1111 1111 1111 1111 1100</b> in binary) because all bits changed.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bitor"></a>bitor</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITOR(int_value1, int_value2, ... , int_valueN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result of a bitwise inclusive OR operation performed on all input integer values.</p>
+<p>The bitwise inclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If any bit is 1, the corresponding result bit is set to 1; otherwise, it is set to 0 (zero).</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the bitwise OR between all of the input integers.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": BITOR(3,6) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": 7 }
+</pre></div></div>
+
+<p>This results in 7 (0<b>111</b> in binary) because at least 1 bit of each (00<b>11</b> and 0<b>11</b>0) is 1 in bits 1, 2, and 3.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Perform OR on 3 (0011 in binary) and -4 (1000 0000 0000 … 0000 1100 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": BITOR(3,-4) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": -1 }
+</pre></div></div>
+
+<p>This results in -1 (<b>1111 1111 1111 … 1111 1111</b> in binary) because the two 1 bits in 3 fill in the two 0 bits in -4 to turn on all the bits.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": BITOR(3,6,15) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitOR": 15 }
+</pre></div></div>
+
+<p>This results in 15 (1111 in binary) because there is at least one 1 in each of the four rightmost bits.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bitset"></a>bitset</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITSET(int_value, positions)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result after setting the specified bit <tt>position</tt>, or array of bit positions, to 1 in the given <tt>int_value</tt>.</p>
+<p><b>Note:</b> Specifying a negative or zero position makes the function return a null.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to set.</p>
+</li>
+<li>
+
+<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be set.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the result after setting the bit or bits specified. If the bit is already set, then it stays set.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Set bit 1 in the value 6 (011<b>0</b> in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": BITSET(6,1) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": 7 }
+</pre></div></div>
+
+<p>This results in 7 (011<b>1</b> in binary) because bit 1 changed to 1.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Set bits 1 and 2 in the value 6 (01<b>10</b> in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": BITSET(6,[1,2]) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": 7 }
+</pre></div></div>
+
+<p>This also results in 7 (01<b>11</b> in binary) because bit 1 changed while bit 2 remained the same.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>Set bits 1 and 4 in the value 6 (<b>0</b>11<b>0</b> in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": BITSET(6,[1,4]) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSET": 15 }
+</pre></div></div>
+
+<p>This results in 15 (<b>1</b>11<b>1</b> in binary) because bit 1 and 4 changed to ones.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bitshift"></a>bitshift</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITSHIFT(int_value, shift_amount[, rotate])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result of a bit shift operation performed on the integer value <tt>int_value</tt>. The <tt>shift_amount</tt> supports left and right shifts. These are logical shifts. The third parameter <tt>rotate</tt> supports circular shift. This is similar to the BitROTATE function in Oracle.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to shift.</p>
+</li>
+<li>
+
+<p><tt>shift_amount</tt>: An integer, or any valid expression which evaluates to an integer, that contains the number of bits to shift.</p>
+<ul>
+
+<li>
+
+<p>A positive (+) number means this is a LEFT shift.</p>
+</li>
+<li>
+
+<p>A negative (-) number means this is a RIGHT shift.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p><tt>rotate</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean, where:</p>
+<ul>
+
+<li>
+
+<p>FALSE means this is a LOGICAL shift, where bits shifted off the end of a value are considered lost.</p>
+</li>
+<li>
+
+<p>TRUE means this is a CIRCULAR shift (shift-and-rotate operation), where bits shifted off the end of a value are rotated back onto the value at the <i>other</i> end. In other words, the bits rotate in what might be thought of as a circular pattern; therefore, these bits are not lost.</p>
+</li>
+</ul>
+<p>If omitted, the default is FALSE.</p>
+</li>
+</ul>
+<p>For comparison, see the below table.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Input </th>
+<th> Shift </th>
+<th> Result of Logical Shift (Rotate FALSE) </th>
+<th> Result of Circular Shift (Rotate TRUE) </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> 6 (0000 0110) </td>
+<td> 4 </td>
+<td> 96 (0110 0000) </td>
+<td> 96 (0110 0000) </td></tr>
+<tr class="a">
+<td> 6 (0000 0110) </td>
+<td> 3 </td>
+<td> 48 (0011 0000) </td>
+<td> 48 (0011 0000) </td></tr>
+<tr class="b">
+<td> 6 (0000 0110) </td>
+<td> 2 </td>
+<td> 24 (0001 1000) </td>
+<td> 24 (0001 1000) </td></tr>
+<tr class="a">
+<td> 6 (0000 0110) </td>
+<td> 1 </td>
+<td> 12 (0000 1100) </td>
+<td> 12 (0000 1100) </td></tr>
+<tr class="b">
+<td> <b>6 (0000 0110)</b> </td>
+<td> <b>0</b> </td>
+<td> <b>6 (0000 0110)</b> </td>
+<td> <b>6 (0000 0110)</b> </td></tr>
+<tr class="a">
+<td> 6 (0000 0110) </td>
+<td> -1 </td>
+<td> 3 (0000 0011) </td>
+<td> 3 (0000 0011) </td></tr>
+<tr class="b">
+<td> 6 (0000 0110) </td>
+<td> -2 </td>
+<td> 1 (0000 0001) </td>
+<td> -9223372036854775807 (1000 0000 … 0000 0001) </td></tr>
+<tr class="a">
+<td> 6 (0000 0110) </td>
+<td> -3 </td>
+<td> 0 (0000 0000) </td>
+<td> -4611686018427387904 (1100 0000 … 0000 0000) </td></tr>
+<tr class="b">
+<td> 6 (0000 0110) </td>
+<td> -4 </td>
+<td> 0 (0000 0000) </td>
+<td> 6917529027641081856 (0110 0000 … 0000 0000) </td></tr>
+</tbody>
+</table>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the result of either a logical or circular shift of the given integer.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Logical left shift of the number 6 (0110 in binary) by one bit.</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": BITSHIFT(6,1,FALSE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": 12 }
+</pre></div></div>
+
+<p>This results in 12 (1100 in binary) because the 1-bits moved from positions 2 and 3 to positions 3 and 4.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Logical right shift of the number 6 (0110 in binary) by two bits.</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": BITSHIFT(6,-2) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": 1 }
+</pre></div></div>
+
+<p>This results in 1 (0001 in binary) because the 1-bit in position 3 moved to position 1 and the 1-bit in position 2 was dropped.</p>
+</li>
+<li>
+
+<p>Example 2b:</p>
+<p>Circular right shift of the number 6 (0110 in binary) by two bits.</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": BITSHIFT(6,-2,TRUE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": -9223372036854775807 }
+</pre></div></div>
+
+<p>This results in -9223372036854775807 (1100 0000 0000 0000 0000 0000 0000 0000 in binary) because the two 1-bits wrapped right, around to the Most Significant Digit position and changed the integer’s sign to negative.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>Circular left shift of the number 524288 (1000 0000 0000 0000 0000 in binary) by 45 bits.</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": BITSHIFT(524288,45,TRUE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitSHIFT": 1 }
+</pre></div></div>
+
+<p>This results in 1 because the 1-bit wrapped left, around to the Least Significant Digit position.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="bittest"></a>bittest</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITTEST(int_value, positions [, all_set])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns TRUE if the specified bit, or bits, is a 1; otherwise, returns FALSE if the specified bit, or bits, is a 0 (zero).</p>
+<p><b>Note:</b> Specifying a negative or zero bit position will result in null being returned.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to test.</p>
+</li>
+<li>
+
+<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be tested.</p>
+</li>
+<li>
+
+<p><tt>all_set</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean.</p>
+<ul>
+
+<li>
+
+<p>When <tt>all_set</tt> is FALSE, then it returns TRUE even if one bit in one of the positions is set.</p>
+</li>
+<li>
+
+<p>When <tt>all_set</tt> is TRUE, then it returns TRUE only if all input positions are set.</p>
+</li>
+</ul>
+<p>If omitted, the default is FALSE.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>A boolean, that follows the below table:
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> <tt>int_value</tt> </th>
+<th> <tt>all_set</tt> </th>
+<th> Return Value </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> <i>all</i> specified bits are TRUE </td>
+<td> FALSE </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> <i>all</i> specified bits are TRUE </td>
+<td> TRUE </td>
+<td> TRUE </td></tr>
+<tr class="b">
+<td> <i>some</i> specified bits are TRUE </td>
+<td> FALSE </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> <i>some</i> specified bits are TRUE </td>
+<td> TRUE </td>
+<td> FALSE </td></tr>
+</tbody>
+</table>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>In the number 6 (0110 in binary), is bit 1 set?</p>
+
+<div>
+<div>
+<pre class="source">{ "IsBitSET": ISBITSET(6,1) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "IsBitSET": false }
+</pre></div></div>
+
+<p>This returns FALSE because bit 1 of 6 (011<b>0</b> in binary) is not set to 1.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>In the number 1, is either bit 1 or bit 2 set?</p>
+
+<div>
+<div>
+<pre class="source">{ "BitTEST": BITTEST(1,[1,2],FALSE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitTEST": true }
+</pre></div></div>
+
+<p>This returns TRUE because bit 1 of the number 1 (000<b>1</b> in binary) is set to 1.</p>
+</li>
+<li>
+
+<p>Example 3:</p>
+<p>In the number 6 (0110 in binary), are both bits 2 and 3 set?</p>
+
+<div>
+<div>
+<pre class="source">{ "IsBitSET": ISBITSET(6,[2,3],TRUE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "IsBitSET": true }
+</pre></div></div>
+
+<p>This returns TRUE because both bits 2 and 3 in the number 6 (0<b>11</b>0 in binary) are set to 1.</p>
+</li>
+<li>
+
+<p>Example 4:</p>
+<p>In the number 6 (0110 in binary), are all the bits in positions 1 through 3 set?</p>
+
+<div>
+<div>
+<pre class="source">{ "BitTEST": BITTEST(6,[1,3],TRUE) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitTEST": false }
+</pre></div></div>
+
+<p>This returns FALSE because bit 1 in the number 6 (011<b>0</b> in binary) is set to 0 (zero).</p>
+</li>
+</ul>
+<p>The function has an alias <tt>isbitset</tt>.</p></div>
+<div class="section">
+<h3><a name="bitxor"></a>bitxor</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">BITXOR(int_value1, int_value2, ... , int_valueN)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the result of a bitwise Exclusive OR operation performed on two or more integer values.</p>
+<p>The bitwise Exclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of <tt>int_value2</tt>.</p>
+<p>If there are more than two input values, the first two are compared; then their result is compared to the next input value; and so on.</p>
+<p>When the compared bits do not match, the result bit is 1; otherwise, the compared bits do match, and the result bit is 0 (zero), as summarized:</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Bit 1 </th>
+<th> Bit 2 </th>
+<th> XOR Result Bit </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> 0 </td>
+<td> 0 </td>
+<td> 0 </td></tr>
+<tr class="a">
+<td> 0 </td>
+<td> 1 </td>
+<td> 1 </td></tr>
+<tr class="b">
+<td> 1 </td>
+<td> 0 </td>
+<td> 1 </td></tr>
+<tr class="a">
+<td> 1 </td>
+<td> 1 </td>
+<td> 0 </td></tr>
+</tbody>
+</table>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, representing the bitwise XOR between the input integers.</li>
+</ul>
+</li>
+<li>
+
+<p>Limitations:</p>
+<ul>
+
+<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitXOR": BITXOR(3,6) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitXOR": 5 }
+</pre></div></div>
+
+<p>This returns 5 (0101 in binary) because the 1st bit pair and 3rd bit pair are different (resulting in 1) while the 2nd bit pair and 4th bit pair are the same (resulting in 0):</p>
+
+<div>
+<div>
+<pre class="source">0011 (3)
+0110 (6)
+====
+0101 (5)
+</pre></div></div>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
+
+<div>
+<div>
+<pre class="source">{ "BitXOR": BITXOR(3,6,15) };
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">{ "BitXOR": 10 }
+</pre></div></div>
+
+<p>This returns 10 (1010 in binary) because 3 XOR 6 equals 5 (0101 in binary), and then 5 XOR 15 equals 10 (1010 in binary).</p>
+</li>
+</ul><!--
+ ! 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.
+ !-->
+</div></div>
+<div class="section">
+<h2><a name="Window_Functions"></a><a name="WindowFunctions" id="WindowFunctions">Window Functions</a></h2>
+<p>Window functions are used to compute an aggregate or cumulative value, based on a portion of the tuples selected by a query. For each input tuple, a movable window of tuples is defined. The window determines the tuples to be used by the window function.</p>
+<p>The tuples are not grouped into a single output tuple — each tuple remains separate in the query output.</p>
+<p>All window functions must be used with an OVER clause. Refer to <a href="manual.html#Over_clauses">OVER Clauses</a> for details.</p>
+<p>Window functions cannot appear in the FROM clause clause or LIMIT clause.</p>
+<p>The examples in this section use the <tt>GleambookMessages</tt> dataset, described in the section on <a href="manual.html#SELECT_statements">SELECT Statements</a>.</p>
+<div class="section">
+<h3><a name="cume_dist"></a>cume_dist</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">CUME_DIST() OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the percentile rank of the current tuple as part of the cumulative distribution – that is, the number of tuples ranked lower than or equal to the current tuple, including the current tuple, divided by the total number of tuples in the window partition.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (1.0) for each tuple.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>None.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>A number greater than 0 and less than or equal to 1. The higher the value, the higher the ranking.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, find the cumulative distribution of all messages in order of message ID.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.messageId, m.authorId, CUME_DIST() OVER (
+ PARTITION BY m.authorId
+ ORDER BY m.messageId
+) AS `rank`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "rank": 0.2,
+ "messageId": 2,
+ "authorId": 1
+ },
+ {
+ "rank": 0.4,
+ "messageId": 4,
+ "authorId": 1
+ },
+ {
+ "rank": 0.6,
+ "messageId": 8,
+ "authorId": 1
+ },
+ {
+ "rank": 0.8,
+ "messageId": 10,
+ "authorId": 1
+ },
+ {
+ "rank": 1,
+ "messageId": 11,
+ "authorId": 1
+ },
+ {
+ "rank": 0.5,
+ "messageId": 3,
+ "authorId": 2
+ },
+ {
+ "rank": 1,
+ "messageId": 6,
+ "authorId": 2
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="dense_rank"></a>dense_rank</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">DENSE_RANK() OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the dense rank of the current tuple – that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
+<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
+<p>For this function, when any tuples have the same rank, the rank of the next tuple will be consecutive, so there will not be a gap in the sequence of returned values. For example, if there are three tuples ranked 2, the next dense rank is 3.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>None.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, greater than or equal to 1.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, find the dense rank of all messages in order of location.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
+DENSE_RANK() OVER (
+ PARTITION BY m.authorId
+ ORDER BY m.senderLocation[1]
+) AS `rank`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "rank": 1,
+ "authorId": 1,
+ "messageId": 10,
+ "longitude": 70.01
+ },
+ {
+ "rank": 2,
+ "authorId": 1,
+ "messageId": 11,
+ "longitude": 77.49
+ },
+ {
+ "rank": 3,
+ "authorId": 1,
+ "messageId": 2,
+ "longitude": 80.87
+ },
+ {
+ "rank": 3,
+ "authorId": 1,
+ "messageId": 8,
+ "longitude": 80.87
+ },
+ {
+ "rank": 4,
+ "authorId": 1,
+ "messageId": 4,
+ "longitude": 97.04
+ },
+ {
+ "rank": 1,
+ "authorId": 2,
+ "messageId": 6,
+ "longitude": 75.56
+ },
+ {
+ "rank": 2,
+ "authorId": 2,
+ "messageId": 3,
+ "longitude": 81.01
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="first_value"></a>first_value</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">FIRST_VALUE(expr) [nulls-treatment] OVER (window-definition)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the requested value from the first tuple in the current window frame, where the window frame is specified by the window definition.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>expr</tt>: The value that you want to return from the first tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
+</ul>
+</li>
+<li>
+
+<p>Modifiers:</p>
+<ul>
+
+<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the first value in the window frame.
+<ul>
+
+<li>
+
+<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the first tuple. In this case, the function returns the first non-NULL, non-MISSING value.</p>
+</li>
+<li>
+
+<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the first tuple.</p>
+</li>
+</ul>
+<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>The specified value from the first tuple. The order of the tuples is determined by the window order clause.</p>
+</li>
+<li>
+
+<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
+</li>
+<li>
+
+<p>In the following cases, this function may return unpredictable results.</p>
+<ul>
+
+<li>
+
+<p>If the window order clause is omitted.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, show the length of each message, including the length of the shortest message from that author.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+FIRST_VALUE(LENGTH(m.message)) OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+) AS shortest_message
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "shortest_message": 31,
+ "authorId": 1,
+ "messageId": 8
+ },
+ {
+ "message_length": 39,
+ "shortest_message": 31,
+ "authorId": 1,
+ "messageId": 11
+ },
+ {
+ "message_length": 44,
+ "shortest_message": 31,
+ "authorId": 1,
+ "messageId": 4
+ },
+ {
+ "message_length": 45,
+ "shortest_message": 31,
+ "authorId": 1,
+ "messageId": 2
+ },
+ {
+ "message_length": 51,
+ "shortest_message": 31,
+ "authorId": 1,
+ "messageId": 10
+ },
+ {
+ "message_length": 35,
+ "shortest_message": 35,
+ "authorId": 2,
+ "messageId": 3
+ },
+ {
+ "message_length": 44,
+ "shortest_message": 35,
+ "authorId": 2,
+ "messageId": 6
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="lag"></a>lag</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">LAG(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the value from a tuple at a given offset prior to the current tuple position.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
+</li>
+<li>
+
+<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
+</li>
+<li>
+
+<p><tt>default</tt>: (Optional) The value to return when the offset goes out of partition scope. If omitted, the default is NULL.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Modifiers:</p>
+<ul>
+
+<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
+<ul>
+
+<li>
+
+<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
+</li>
+<li>
+
+<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
+</li>
+</ul>
+<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>The specified value from the offset tuple.</p>
+</li>
+<li>
+
+<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, show the length of each message, including the length of the next-shortest message.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+LAG(LENGTH(m.message), 1, "No shorter message") OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+) AS next_shortest_message
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "authorId": 1,
+ "messageId": 8,
+ "next_shortest_message": "No shorter message"
+ },
+ {
+ "message_length": 39,
+ "authorId": 1,
+ "messageId": 11,
+ "next_shortest_message": 31
+ },
+ {
+ "message_length": 44,
+ "authorId": 1,
+ "messageId": 4,
+ "next_shortest_message": 39
+ },
+ {
+ "message_length": 45,
+ "authorId": 1,
+ "messageId": 2,
+ "next_shortest_message": 44
+ },
+ {
+ "message_length": 51,
+ "authorId": 1,
+ "messageId": 10,
+ "next_shortest_message": 45
+ },
+ {
+ "message_length": 35,
+ "authorId": 2,
+ "messageId": 3,
+ "next_shortest_message": "No shorter message"
+ },
+ {
+ "message_length": 44,
+ "authorId": 2,
+ "messageId": 6,
+ "next_shortest_message": 35
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="last_value"></a>last_value</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">LAST_VALUE(expr) [nulls-treatment] OVER (window-definition)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the requested value from the last tuple in the current window frame, where the window frame is specified by the window definition.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>expr</tt>: The value that you want to return from the last tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
+</ul>
+</li>
+<li>
+
+<p>Modifiers:</p>
+<ul>
+
+<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the last tuple in the window frame.
+<ul>
+
+<li>
+
+<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the last tuple. In this case, the function returns the last non-NULL, non-MISSING value.</p>
+</li>
+<li>
+
+<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the last tuple.</p>
+</li>
+</ul>
+<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>The specified value from the last tuple. The order of the tuples is determined by the window order clause.</p>
+</li>
+<li>
+
+<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
+</li>
+<li>
+
+<p>In the following cases, this function may return unpredictable results.</p>
+<ul>
+
+<li>
+
+<p>If the window order clause is omitted.</p>
+</li>
+<li>
+
+<p>If the window frame clause is omitted.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the last value of the input expression.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, show the length of each message, including the length of the longest message from that author.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+LAST_VALUE(LENGTH(m.message)) OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- ➊
+) AS longest_message
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "longest_message": 51,
+ "authorId": 1,
+ "messageId": 8
+ },
+ {
+ "message_length": 39,
+ "longest_message": 51,
+ "authorId": 1,
+ "messageId": 11
+ },
+ {
+ "message_length": 44,
+ "longest_message": 51,
+ "authorId": 1,
+ "messageId": 4
+ },
+ {
+ "message_length": 45,
+ "longest_message": 51,
+ "authorId": 1,
+ "messageId": 2
+ },
+ {
+ "message_length": 51,
+ "longest_message": 51,
+ "authorId": 1,
+ "messageId": 10
+ },
+ {
+ "message_length": 35,
+ "longest_message": 44,
+ "authorId": 2,
+ "messageId": 3
+ },
+ {
+ "message_length": 44,
+ "longest_message": 44,
+ "authorId": 2,
+ "messageId": 6
+ }
+]
+</pre></div></div>
+
+<p>➀ This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that the longest message would always be the same as the current message.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="lead"></a>lead</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">LEAD(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the value from a tuple at a given offset ahead of the current tuple position.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
+</li>
+<li>
+
+<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
+</li>
+<li>
+
+<p><tt>default</tt>: (Optional) The value to return when the offset goes out of window partition scope. If omitted, the default is NULL.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Modifiers:</p>
+<ul>
+
+<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
+<ul>
+
+<li>
+
+<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
+</li>
+<li>
+
+<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
+</li>
+</ul>
+<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>The specified value from the offset tuple.</p>
+</li>
+<li>
+
+<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, show the length of each message, including the length of the next-longest message.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+LEAD(LENGTH(m.message), 1, "No longer message") OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+) AS next_longest_message
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "authorId": 1,
+ "messageId": 8,
+ "next_longest_message": 39
+ },
+ {
+ "message_length": 39,
+ "authorId": 1,
+ "messageId": 11,
+ "next_longest_message": 44
+ },
+ {
+ "message_length": 44,
+ "authorId": 1,
+ "messageId": 4,
+ "next_longest_message": 45
+ },
+ {
+ "message_length": 45,
+ "authorId": 1,
+ "messageId": 2,
+ "next_longest_message": 51
+ },
+ {
+ "message_length": 51,
+ "authorId": 1,
+ "messageId": 10,
+ "next_longest_message": "No longer message"
+ },
+ {
+ "message_length": 35,
+ "authorId": 2,
+ "messageId": 3,
+ "next_longest_message": 44
+ },
+ {
+ "message_length": 44,
+ "authorId": 2,
+ "messageId": 6,
+ "next_longest_message": "No longer message"
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="nth_value"></a>nth_value</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">NTH_VALUE(expr, offset) [nthval-from] [nulls-treatment] OVER (window-definition)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the requested value from a tuple in the current window frame, where the window frame is specified by the window definition.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>
+
+<p><tt>expr</tt>: The value that you want to return from the offset tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
+</li>
+<li>
+
+<p><tt>offset</tt>: The number of the offset tuple within the window frame, counting from 1.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Modifiers:</p>
+<ul>
+
+<li>
+
+<p><a href="manual.html#Nth_val_from">Nth Val From</a>: (Optional) Determines where the function starts counting the offset.</p>
+<ul>
+
+<li>
+
+<p><tt>FROM FIRST</tt>: Counting starts at the first tuple in the window frame. In this case, an offset of 1 is the first tuple in the window frame, 2 is the second tuple, and so on.</p>
+</li>
+<li>
+
+<p><tt>FROM LAST</tt>: Counting starts at the last tuple in the window frame. In this case, an offset of 1 is the last tuple in the window frame, 2 is the second-to-last tuple, and so on.</p>
+</li>
+</ul>
+<p>The order of the tuples is determined by the window order clause. If this modifier is omitted, the default is <tt>FROM FIRST</tt>.</p>
+</li>
+<li>
+
+<p><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window frame.</p>
+<ul>
+
+<li>
+
+<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
+</li>
+<li>
+
+<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
+</li>
+</ul>
+<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>The specified value from the offset tuple.</p>
+</li>
+<li>
+
+<p>In the following cases, this function may return unpredictable results.</p>
+<ul>
+
+<li>
+
+<p>If the window order clause is omitted.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
+</li>
+<li>
+
+<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression when counting <tt>FROM FIRST</tt>, or the last value of the input expression when counting <tt>FROM LAST</tt>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example 1:</p>
+<p>For each author, show the length of each message, including the length of the second shortest message from that author.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+NTH_VALUE(LENGTH(m.message), 2) FROM FIRST OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- ➊
+) AS shortest_message_but_1
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "shortest_message_but_1": 39,
+ "authorId": 1,
+ "messageId": 8
+ },
+ {
+ "message_length": 39,
+ "shortest_message_but_1": 39,
+ "authorId": 1,
+ "messageId": 11 // ➋
+ },
+ {
+ "message_length": 44,
+ "shortest_message_but_1": 39,
+ "authorId": 1,
+ "messageId": 4
+ },
+ {
+ "message_length": 45,
+ "shortest_message_but_1": 39,
+ "authorId": 1,
+ "messageId": 2
+ },
+ {
+ "message_length": 51,
+ "shortest_message_but_1": 39,
+ "authorId": 1,
+ "messageId": 10
+ },
+ {
+ "message_length": 35,
+ "shortest_message_but_1": 44,
+ "authorId": 2,
+ "messageId": 3
+ },
+ {
+ "message_length": 44,
+ "shortest_message_but_1": 44,
+ "authorId": 2,
+ "messageId": 6 // ➋
+ }
+]
+</pre></div></div>
+
+<p>➀ This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that for the shortest message, the function would be unable to find the route with the second shortest message.</p>
+<p>➁ The second shortest message from this author.</p>
+</li>
+<li>
+
+<p>Example 2:</p>
+<p>For each author, show the length of each message, including the length of the second longest message from that author.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId,
+LENGTH(m.message) AS message_length,
+NTH_VALUE(LENGTH(m.message), 2) FROM LAST OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+ ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- ➊
+) AS longest_message_but_1
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "message_length": 31,
+ "longest_message_but_1": 45,
+ "authorId": 1,
+ "messageId": 8
+ },
+ {
+ "message_length": 39,
+ "longest_message_but_1": 45,
+ "authorId": 1,
+ "messageId": 11
+ },
+ {
+ "message_length": 44,
+ "longest_message_but_1": 45,
+ "authorId": 1,
+ "messageId": 4
+ },
+ {
+ "message_length": 45,
+ "longest_message_but_1": 45,
+ "authorId": 1,
+ "messageId": 2 // ➋
+ },
+ {
+ "message_length": 51,
+ "longest_message_but_1": 45,
+ "authorId": 1,
+ "messageId": 10
+ },
+ {
+ "message_length": 35,
+ "longest_message_but_1": 35,
+ "authorId": 2,
+ "messageId": 3 // ➋
+ },
+ {
+ "message_length": 44,
+ "longest_message_but_1": 35,
+ "authorId": 2,
+ "messageId": 6
+ }
+]
+</pre></div></div>
+
+<p>➀ This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean the function would be unable to find the second longest message for shorter messages.</p>
+<p>➁ The second longest message from this author.</p>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ntile"></a>ntile</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">NTILE(num_tiles) OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Divides the window partition into the specified number of tiles, and allocates each tuple in the window partition to a tile, so that as far as possible each tile has an equal number of tuples. When the set of tuples is not equally divisible by the number of tiles, the function puts more tuples into the lower-numbered tiles. For each tuple, the function returns the number of the tile into which that tuple was placed.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted then the tuples are processed in an undefined order.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>num_tiles</tt>: The number of tiles into which you want to divide the window partition. This argument can be an expression and must evaluate to a number. If the number is not an integer, it will be truncated.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An value greater than or equal to 1 and less than or equal to the number of tiles.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>Allocate each message to one of three tiles by length and message ID.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.messageId, LENGTH(m.message) AS `length`,
+NTILE(3) OVER (
+ ORDER BY LENGTH(m.message), m.messageId
+) AS `ntile`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "length": 31,
+ "ntile": 1,
+ "messageId": 8
+ },
+ {
+ "length": 35,
+ "ntile": 1,
+ "messageId": 3
+ },
+ {
+ "length": 39,
+ "ntile": 1,
+ "messageId": 11
+ },
+ {
+ "length": 44,
+ "ntile": 2,
+ "messageId": 4
+ },
+ {
+ "length": 44,
+ "ntile": 2,
+ "messageId": 6
+ },
+ {
+ "length": 45,
+ "ntile": 3,
+ "messageId": 2
+ },
+ {
+ "length": 51,
+ "ntile": 3,
+ "messageId": 10
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="percent_rank"></a>percent_rank</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">PERCENT_RANK() OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the percentile rank of the current tuple – that is, the rank of the tuples minus one, divided by the total number of tuples in the window partition minus one.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (0) for each tuple.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>None.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>A number between 0 and 1. The higher the value, the higher the ranking.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, find the percentile rank of all messages in order of message ID.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.messageId, m.authorId, PERCENT_RANK() OVER (
+ PARTITION BY m.authorId
+ ORDER BY m.messageId
+) AS `rank`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "rank": 0,
+ "messageId": 2,
+ "authorId": 1
+ },
+ {
+ "rank": 0.25,
+ "messageId": 4,
+ "authorId": 1
+ },
+ {
+ "rank": 0.5,
+ "messageId": 8,
+ "authorId": 1
+ },
+ {
+ "rank": 0.75,
+ "messageId": 10,
+ "authorId": 1
+ },
+ {
+ "rank": 1,
+ "messageId": 11,
+ "authorId": 1
+ },
+ {
+ "rank": 0,
+ "messageId": 3,
+ "authorId": 2
+ },
+ {
+ "rank": 1,
+ "messageId": 6,
+ "authorId": 2
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="rank"></a>rank</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">RANK() OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the rank of the current tuple – that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
+<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
+<p>When any tuples have the same rank, the rank of the next tuple will include all preceding tuples, so there may be a gap in the sequence of returned values. For example, if there are three tuples ranked 2, the next rank is 5.</p>
+<p>To avoid gaps in the returned values, use the DENSE_RANK() function instead.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>None.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, greater than or equal to 1.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, find the rank of all messages in order of location.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
+RANK() OVER (
+ PARTITION BY m.authorId
+ ORDER BY m.senderLocation[1]
+) AS `rank`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "rank": 1,
+ "authorId": 1,
+ "messageId": 10,
+ "longitude": 70.01
+ },
+ {
+ "rank": 2,
+ "authorId": 1,
+ "messageId": 11,
+ "longitude": 77.49
+ },
+ {
+ "rank": 3,
+ "authorId": 1,
+ "messageId": 2,
+ "longitude": 80.87
+ },
+ {
+ "rank": 3,
+ "authorId": 1,
+ "messageId": 8,
+ "longitude": 80.87
+ },
+ {
+ "rank": 5,
+ "authorId": 1,
+ "messageId": 4,
+ "longitude": 97.04
+ },
+ {
+ "rank": 1,
+ "authorId": 2,
+ "messageId": 6,
+ "longitude": 75.56
+ },
+ {
+ "rank": 2,
+ "authorId": 2,
+ "messageId": 3,
+ "longitude": 81.01
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="ratio_to_report"></a>ratio_to_report</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">RATIO_TO_REPORT(expr) OVER (window-definition)
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns the fractional ratio of the specified value for each tuple to the sum of values for all tuples in the window frame.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li><tt>expr</tt>: The value for which you want to calculate the fractional ratio. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>
+
+<p>A number between 0 and 1, representing the fractional ratio of the value for the current tuple to the sum of values for all tuples in the current window frame. The sum of returned values for all tuples in the current window frame is 1.</p>
+</li>
+<li>
+
+<p>If the input expression does not evaluate to a number, or the sum of values for all tuples is zero, it returns NULL.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, calculate the length of each message as a fraction of the total length of all messages.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.messageId, m.authorId,
+RATIO_TO_REPORT(LENGTH(m.message)) OVER (
+ PARTITION BY m.authorId
+) AS length_ratio
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "length_ratio": 0.21428571428571427,
+ "messageId": 2,
+ "authorId": 1
+ },
+ {
+ "length_ratio": 0.20952380952380953,
+ "messageId": 4,
+ "authorId": 1
+ },
+ {
+ "length_ratio": 0.14761904761904762,
+ "messageId": 8,
+ "authorId": 1
+ },
+ {
+ "length_ratio": 0.24285714285714285,
+ "messageId": 10,
+ "authorId": 1
+ },
+ {
+ "length_ratio": 0.18571428571428572,
+ "messageId": 11,
+ "authorId": 1
+ },
+ {
+ "length_ratio": 0.4430379746835443,
+ "messageId": 3,
+ "authorId": 2
+ },
+ {
+ "length_ratio": 0.5569620253164557,
+ "messageId": 6,
+ "authorId": 2
+ }
+]
+</pre></div></div>
+</li>
+</ul></div>
+<div class="section">
+<h3><a name="row_number"></a>row_number</h3>
+<ul>
+
+<li>
+
+<p>Syntax:</p>
+
+<div>
+<div>
+<pre class="source">ROW_NUMBER() OVER ([window-partition-clause] [window-order-clause])
+</pre></div></div>
+</li>
+<li>
+
+<p>Returns a unique row number for every tuple in every window partition. In each window partition, the row numbering starts at 1.</p>
+<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
+</li>
+<li>
+
+<p>Arguments:</p>
+<ul>
+
+<li>None.</li>
+</ul>
+</li>
+<li>
+
+<p>Clauses:</p>
+<ul>
+
+<li>
+
+<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
+</li>
+<li>
+
+<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
+</li>
+</ul>
+</li>
+<li>
+
+<p>Return Value:</p>
+<ul>
+
+<li>An integer, greater than or equal to 1.</li>
+</ul>
+</li>
+<li>
+
+<p>Example:</p>
+<p>For each author, number all messages in order of length.</p>
+
+<div>
+<div>
+<pre class="source">SELECT m.messageId, m.authorId,
+ROW_NUMBER() OVER (
+ PARTITION BY m.authorId
+ ORDER BY LENGTH(m.message)
+) AS `row`
+FROM GleambookMessages AS m;
+</pre></div></div>
+</li>
+<li>
+
+<p>The expected result is:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "row": 1,
+ "messageId": 8,
+ "authorId": 1
+ },
+ {
+ "row": 2,
+ "messageId": 11,
+ "authorId": 1
+ },
+ {
+ "row": 3,
+ "messageId": 4,
+ "authorId": 1
+ },
+ {
+ "row": 4,
+ "messageId": 2,
+ "authorId": 1
+ },
+ {
+ "row": 5,
+ "messageId": 10,
+ "authorId": 1
+ },
+ {
+ "row": 1,
+ "messageId": 3,
+ "authorId": 2
+ },
+ {
+ "row": 2,
+ "messageId": 6,
+ "authorId": 2
+ }
+]
+</pre></div></div>
+</li>
+</ul><hr />
+<p><a name="fn_1" id="fn_1">1</a>. If the query contains the GROUP BY clause or any <a href="#AggregateFunctions">aggregate functions</a>, this expression must only depend on GROUP BY expressions or aggregate functions.</p></div></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/docs/0.9.5/sqlpp/filters.html b/docs/0.9.5/sqlpp/filters.html
new file mode 100644
index 0000000..c65f62e
--- /dev/null
+++ b/docs/0.9.5/sqlpp/filters.html
@@ -0,0 +1,142 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/sqlpp/filters.md at 2020-07-30
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200730" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – Filter-Based LSM Index Acceleration</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-07-30</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5-SNAPSHOT</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li class="active"><a href="#"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>Filter-Based LSM Index Acceleration</h1>
+<div class="section">
+<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
+<ul>
+
+<li><a href="#Motivation">Motivation</a></li>
+<li><a href="#FiltersInAsterixDB">Filters in AsterixDB</a></li>
+<li><a href="#FiltersAndMergePolicies">Filters and Merge Policies</a></li>
+</ul></div>
+<div class="section">
+<h2><a name="Motivation_.5BBack_to_TOC.5D"></a><a name="Motivation" id="Motivation">Motivation</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>Traditional relational databases usually employ conventional index structures such as B+ trees due to their low read latency. However, such traditional index structures use in-place writes to perform updates, resulting in costly random writes to disk. Today’s emerging applications often involve insert-intensive workloads for which the cost of random writes prohibits efficient ingestion of data. Consequently, popular NoSQL systems such as Cassandra, HBase, LevelDB, BigTable, etc. have adopted Log-Structured Merge (LSM) Trees as their storage structure. LSM-trees avoids the cost of random writes by batching updates into a component of the index that resides in main memory – an <i>in-memory component</i>. When the space occupancy of the in-memory component exceeds a specified threshold, its entries are <i>flushed</i> to disk forming a new component – a <i>disk component</i>. As disk components accumulate on disk, they are periodically merged together subject to a <i>merge policy</i> that decides when and what to merge. The benefit of the LSM-trees comes at the cost of possibly sacrificing read efficiency, but, it has been shown in previous studies that these inefficiencies can be mostly mitigated.</p>
+<p>AsterixDB has also embraced LSM-trees, not just by using them as primary indexes, but also by using the same LSM-ification technique for all of its secondary index structures. In particular, AsterixDB adopted a generic framework for converting a class of indexes (that includes conventional B+ trees, R trees, and inverted indexes) into LSM-based secondary indexes, allowing higher data ingestion rates. In fact, for certain index structures, our results have shown that using an LSM-based version of an index can be made to significantly outperform its conventional counterpart for <i>both</i> ingestion and query speed (an example of such an index being the R-tree for spatial data).</p>
+<p>Since an LSM-based index naturally partitions data into multiple disk components, it is possible, when answering certain queries, to exploit partitioning to only access some components and safely filter out the remaining components, thus reducing query times. For instance, referring to our <a href="primer.html#ADM:_Modeling_Semistructured_Data_in_AsterixDB">TinySocial</a> example, suppose a user always retrieves tweets from the <tt>TweetMessages</tt> dataset based on the <tt>send-time</tt> field (e.g., tweets posted in the last 24 hours). Since there is not a secondary index on the <tt>send-time</tt> field, the only available option for AsterixDB would be to scan the whole <tt>TweetMessages</tt> dataset and then apply the predicate as a post-processing step. However, if disk components of the primary index were tagged with the minimum and maximum timestamp values of the objects they contain, we could utilize the tagged information to directly access the primary index and prune components that do not match the query predicate. Thus, we could save substantial cost by avoiding scanning the whole dataset and only access the relevant components. We simply call such tagging information that are associated with components, filters. (Note that even if there were a secondary index on <tt>send-time</tt> field, using filters could save substantial cost by avoiding accessing the secondary index, followed by probing the primary index for every fetched entry.) Moreover, the same filtering technique can also be used with any secondary LSM index (e.g., an LSM R-tree), in case the query contains multiple predicates (e.g., spatial and temporal predicates), to obtain similar pruning power.</p></div>
+<div class="section">
+<h2><a name="Filters_in_AsterixDB_.5BBack_to_TOC.5D"></a><a name="FiltersInAsterixDB" id="FiltersInAsterixDB">Filters in AsterixDB</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>We have added support for LSM-based filters to all of AsterixDB’s index types. To enable the use of filters, the user must specify the filter’s key when creating a dataset, as shown below:</p>
+<div class="section">
+<div class="section">
+<h4><a name="Creating_a_Dataset_with_a_Filter"></a>Creating a Dataset with a Filter</h4>
+
+<div>
+<div>
+<pre class="source"> create dataset Tweets(TweetType) primary key tweetid with filter on send-time;
+</pre></div></div>
+
+<p>Filters can be created on any totally ordered datatype (i.e., any field that can be indexed using a B+ -tree), such as integers, doubles, floats, UUIDs, datetimes, etc.</p>
+<p>When a dataset with a filter is created, the name of the filter’s key field is persisted in the <tt>Metadata.Dataset</tt> dataset (which is the metadata dataset that stores the details of each dataset in an AsterixDB instance) so that DML operations against the dataset can recognize the existence of filters and can update them or utilize them accordingly. Creating a dataset with a filter in AsterixDB implies that the primary and all secondary indexes of that dataset will maintain filters on their disk components. Once a filtered dataset is created, the user can use the dataset normally (just like any other dataset). AsterixDB will automatically maintain the filters and will leverage them to efficiently answer queries whenever possible (i.e., when a query has predicates on the filter’s key).</p></div></div></div>
+<div class="section">
+<h2><a name="Filters_and_Merge_Policies_.5BBack_to_TOC.5D"></a><a name="FiltersAndMergePolicies" id="FiltersAndMergePolicies">Filters and Merge Policies</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>The AsterixDB default merge policy, the prefix merge policy, relies on component sizes and the number of components to decide which components to merge. This merge policy has proven to provide excellent performance for both ingestion and queries. However, when evaluating our filtering solution with the prefix policy, we observed a behavior that can reduce filter effectiveness. In particular, we noticed that under the prefix merge policy, the disk components of a secondary index tend to be constantly merged into a single component. This is because the prefix policy relies on a single size parameter for all of the indexes of a dataset. This parameter is typically chosen based on the sizes of the disk components of the primary index, which tend to be much larger than the sizes of the secondary indexes’ disk components. This difference caused the prefix merge policy to behave similarly to the constant merge policy (i.e., relatively poorly) when applied to secondary indexes in the sense that the secondary indexes are constantly merged into a single disk component. Consequently, the effectiveness of filters on secondary indexes was greatly reduced under the prefix-merge policy, but they were still effective when probing the primary index. Based on this behavior, we developed a new merge policy, an improved version of the prefix policy, called the correlated-prefix policy. The basic idea of this policy is that it delegates the decision of merging the disk components of all the indexes in a dataset to the primary index. When the policy decides that the primary index needs to be merged (using the same decision criteria as for the prefix policy), then it will issue successive merge requests to the I/O scheduler on behalf of all other indexes associated with the same dataset. The end result is that secondary indexes will always have the same number of disk components as their primary index under the correlated-prefix merge policy. This has improved query performance, since disk components of secondary indexes now have a much better chance of being pruned.</p></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/docs/0.9.5/sqlpp/fulltext.html b/docs/0.9.5/sqlpp/fulltext.html
new file mode 100644
index 0000000..193a6b7
--- /dev/null
+++ b/docs/0.9.5/sqlpp/fulltext.html
@@ -0,0 +1,196 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/sqlpp/fulltext.md at 2020-07-30
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200730" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – AsterixDB Support of Full-text search queries</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-07-30</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5-SNAPSHOT</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li class="active"><a href="#"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>AsterixDB Support of Full-text search queries</h1>
+<div class="section">
+<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
+<ul>
+
+<li><a href="#Motivation">Motivation</a></li>
+<li><a href="#Syntax">Syntax</a></li>
+<li><a href="#FulltextIndex">Creating and utilizing a Full-text index</a></li>
+</ul></div>
+<div class="section">
+<h2><a name="Motivation_.5BBack_to_TOC.5D"></a><a name="Motivation" id="Motivation">Motivation</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>Full-Text Search (FTS) queries are widely used in applications where users need to find records that satisfy an FTS predicate, i.e., where simple string-based matching is not sufficient. These queries are important when finding documents that contain a certain keyword is crucial. FTS queries are different from substring matching queries in that FTS queries find their query predicates as exact keywords in the given string, rather than treating a query predicate as a sequence of characters. For example, an FTS query that finds “rain” correctly returns a document when it contains “rain” as a word. However, a substring-matching query returns a document whenever it contains “rain” as a substring, for instance, a document with “brain” or “training” would be returned as well.</p></div>
+<div class="section">
+<h2><a name="Syntax_.5BBack_to_TOC.5D"></a><a name="Syntax" id="Syntax">Syntax</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>The syntax of AsterixDB FTS follows a portion of the XQuery FullText Search syntax. Two basic forms are as follows:</p>
+
+<div>
+<div>
+<pre class="source"> ftcontains(Expression1, Expression2, {FullTextOption})
+ ftcontains(Expression1, Expression2)
+</pre></div></div>
+
+<p>For example, we can execute the following query to find Chirp messages where the <tt>messageText</tt> field includes “voice” as a word. Please note that an FTS search is case-insensitive. Thus, “Voice” or “voice” will be evaluated as the same word.</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select element {"chirpId": msg.chirpId}
+ from ChirpMessages msg
+ where ftcontains(msg.messageText, "voice", {"mode":"any"});
+</pre></div></div>
+
+<p>The DDL and DML of TinySocial can be found in <a href="../sqlpp/primer-sqlpp.html#ADM:_Modeling_Semistructured_Data_in_AsterixDB">ADM: Modeling Semistructured Data in AsterixDB</a>.</p>
+<p>The <tt>Expression1</tt> is an expression that should be evaluable as a string at runtime as in the above example where <tt>msg.messageText</tt> is a string field. The <tt>Expression2</tt> can be a string, an (un)ordered list of string value(s), or an expression. In the last case, the given expression should be evaluable into one of the first two types, i.e., into a string value or an (un)ordered list of string value(s).</p>
+<p>The following examples are all valid expressions.</p>
+
+<div>
+<div>
+<pre class="source"> ... where ftcontains(msg.messageText, "sound")
+ ... where ftcontains(msg.messageText, "sound", {"mode":"any"})
+ ... where ftcontains(msg.messageText, ["sound", "system"], {"mode":"any"})
+ ... where ftcontains(msg.messageText, {{"speed", "stand", "customization"}}, {"mode":"all"})
+</pre></div></div>
+
+<p>The last <tt>FullTextOption</tt> parameter clarifies the given FTS request. If you omit the <tt>FullTextOption</tt> parameter, then the default value will be set for each possible option. Currently, we only have one option named <tt>mode</tt>. And as we extend the FTS feature, more options will be added. Please note that the format of <tt>FullTextOption</tt> is a record, thus you need to put the option(s) in a record <tt>{}</tt>. The <tt>mode</tt> option indicates whether the given FTS query is a conjunctive (AND) or disjunctive (OR) search request. This option can be either <tt>“all”</tt> (AND) or <tt>“any”</tt> (OR). The default value for <tt>mode</tt> is <tt>“all”</tt>. If one specifies <tt>“any”</tt>, a disjunctive search will be conducted. For example, the following query will find documents whose <tt>messageText</tt> field contains “sound” or “system”, so a document will be returned if it contains either “sound”, “system”, or both of the keywords.</p>
+
+<div>
+<div>
+<pre class="source"> ... where ftcontains(msg.messageText, ["sound", "system"], {"mode":"any"})
+</pre></div></div>
+
+<p>The other option parameter,<tt>“all”</tt>, specifies a conjunctive search. The following examples will find the documents whose <tt>messageText</tt> field contains both “sound” and “system”. If a document contains only “sound” or “system” but not both, it will not be returned.</p>
+
+<div>
+<div>
+<pre class="source"> ... where ftcontains(msg.messageText, ["sound", "system"], {"mode":"all"})
+ ... where ftcontains(msg.messageText, ["sound", "system"])
+</pre></div></div>
+
+<p>Currently AsterixDB doesn’t (yet) support phrase searches, so the following query will not work.</p>
+
+<div>
+<div>
+<pre class="source"> ... where ftcontains(msg.messageText, "sound system", {"mode":"any"})
+</pre></div></div>
+
+<p>As a workaround solution, the following query can be used to achieve a roughly similar goal. The difference is that the following queries will find documents where <tt>msg.messageText</tt> contains both “sound” and “system”, but the order and adjacency of “sound” and “system” are not checked, unlike in a phrase search. As a result, the query below would also return documents with “sound system can be installed.”, “system sound is perfect.”, or “sound is not clear. You may need to install a new system.”</p>
+
+<div>
+<div>
+<pre class="source"> ... where ftcontains(msg.messageText, ["sound", "system"], {"mode":"all"})
+ ... where ftcontains(msg.messageText, ["sound", "system"])
+</pre></div></div>
+</div>
+<div class="section">
+<h2><a name="Creating_and_utilizing_a_Full-text_index_.5BBack_to_TOC.5D"></a><a name="FulltextIndex" id="FulltextIndex">Creating and utilizing a Full-text index</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>When there is a full-text index on the field that is being searched, rather than scanning all records, AsterixDB can utilize that index to expedite the execution of a FTS query. To create a full-text index, you need to specify the index type as <tt>fulltext</tt> in your DDL statement. For instance, the following DDL statement create a full-text index on the <tt>GleambookMessages.message</tt> attribute. Note that a full-text index cannot be built on a dataset with the variable-length primary key (e.g., string).</p>
+
+<div>
+<div>
+<pre class="source">use TinySocial;
+
+create index messageFTSIdx on GleambookMessages(message) type fulltext;
+</pre></div></div></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/docs/0.9.5/sqlpp/manual.html b/docs/0.9.5/sqlpp/manual.html
new file mode 100644
index 0000000..8d62f44
--- /dev/null
+++ b/docs/0.9.5/sqlpp/manual.html
@@ -0,0 +1,4935 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/sqlpp/manual.md at 2020-08-07
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200807" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – The Query Language</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-08-07</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li class="active"><a href="#"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>The Query Language</h1>
+<ul>
+
+<li><a href="#Introduction">1. Introduction</a></li>
+<li><a href="#Expressions">2. Expressions</a>
+<ul>
+
+<li><a href="#Operator_expressions">Operator Expressions</a>
+<ul>
+
+<li><a href="#Arithmetic_operators">Arithmetic Operators</a></li>
+<li><a href="#Collection_operators">Collection Operators</a></li>
+<li><a href="#Comparison_operators">Comparison Operators</a></li>
+<li><a href="#Logical_operators">Logical Operators</a></li>
+</ul>
+</li>
+<li><a href="#Quantified_expressions">Quantified Expressions</a></li>
+<li><a href="#Path_expressions">Path Expressions</a></li>
+<li><a href="#Primary_expressions">Primary Expressions</a>
+<ul>
+
+<li><a href="#Literals">Literals</a></li>
+<li><a href="#Variable_references">Variable References</a></li>
+<li><a href="#Parenthesized_expressions">Parenthesized Expressions</a></li>
+<li><a href="#Function_call_expressions">Function call Expressions</a></li>
+<li><a href="#Case_expressions">Case Expressions</a></li>
+<li><a href="#Constructors">Constructors</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a href="#Queries">3. Queries</a>
+<ul>
+
+<li><a href="#Declarations">Declarations</a></li>
+<li><a href="#SELECT_statements">SELECT Statements</a></li>
+<li><a href="#Select_clauses">SELECT Clauses</a>
+<ul>
+
+<li><a href="#Select_element">Select Element/Value/Raw</a></li>
+<li><a href="#SQL_select">SQL-style Select</a></li>
+<li><a href="#Select_star">Select *</a></li>
+<li><a href="#Select_distinct">Select Distinct</a></li>
+<li><a href="#Unnamed_projections">Unnamed Projections</a></li>
+<li><a href="#Abbreviated_field_access_expressions">Abbreviated Field Access Expressions</a></li>
+</ul>
+</li>
+<li><a href="#Unnest_clauses">UNNEST Clauses</a>
+<ul>
+
+<li><a href="#Inner_unnests">Inner Unnests</a></li>
+<li><a href="#Left_outer_unnests">Left Outer Unnests</a></li>
+<li><a href="#Expressing_joins_using_unnests">Expressing Joins Using Unnests</a></li>
+</ul>
+</li>
+<li><a href="#From_clauses">FROM clauses</a>
+<ul>
+
+<li><a href="#Binding_expressions">Binding Expressions</a></li>
+<li><a href="#Multiple_from_terms">Multiple From Terms</a></li>
+<li><a href="#Expressing_joins_using_from_terms">Expressing Joins Using From Terms</a></li>
+<li><a href="#Implicit_binding_variables">Implicit Binding Variables</a></li>
+</ul>
+</li>
+<li><a href="#Join_clauses">JOIN Clauses</a>
+<ul>
+
+<li><a href="#Inner_joins">Inner Joins</a></li>
+<li><a href="#Left_outer_joins">Left Outer Joins</a></li>
+</ul>
+</li>
+<li><a href="#Group_By_clauses">GROUP BY Clauses</a>
+<ul>
+
+<li><a href="#Group_variables">Group Variables</a></li>
+<li><a href="#Implicit_group_key_variables">Implicit Group Key Variables</a></li>
+<li><a href="#Implicit_group_variables">Implicit Group Variables</a></li>
+<li><a href="#Aggregation_functions">Aggregation Functions</a></li>
+<li><a href="#SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a></li>
+<li><a href="#SQL-92_compliant_gby">SQL-92 Compliant GROUP BY Aggregations</a></li>
+<li><a href="#Column_aliases">Column Aliases</a></li>
+</ul>
+</li>
+<li><a href="#Where_having_clauses">WHERE Clauses and HAVING Clauses</a></li>
+<li><a href="#Order_By_clauses">ORDER BY Clauses</a></li>
+<li><a href="#Limit_clauses">LIMIT Clauses</a></li>
+<li><a href="#With_clauses">WITH Clauses</a></li>
+<li><a href="#Let_clauses">LET Clauses</a></li>
+<li><a href="#Union_all">UNION ALL</a></li>
+<li><a href="#Over_clauses">OVER Clauses</a>
+<ul>
+
+<li><a href="#Window_function_call">Window Function Call</a></li>
+<li><a href="#Window_function_options">Window Function Options</a></li>
+<li><a href="#Window_frame_variable">Window Frame Variable</a></li>
+<li><a href="#Window_definition">Window Definition</a></li>
+</ul>
+</li>
+<li><a href="#Vs_SQL-92">Differences from SQL-92</a></li>
+</ul>
+</li>
+<li><a href="#Errors">4. Errors</a>
+<ul>
+
+<li><a href="#Syntax_errors">Syntax Errors</a></li>
+<li><a href="#Identifier_resolution_errors">Identifier Resolution Errors</a></li>
+<li><a href="#Type_errors">Type Errors</a></li>
+<li><a href="#Resource_errors">Resource Errors</a></li>
+</ul>
+</li>
+<li><a href="#DDL_and_DML_statements">5. DDL and DML Statements</a>
+<ul>
+
+<li><a href="#Lifecycle_management_statements">Lifecycle Management Statements</a>
+<ul>
+
+<li><a href="#Dataverses">Dataverses</a></li>
+<li><a href="#Types">Types</a></li>
+<li><a href="#Datasets">Datasets</a></li>
+<li><a href="#Indices">Indices</a></li>
+<li><a href="#Functions">Functions</a></li>
+<li><a href="#Synonyms">Synonyms</a></li>
+<li><a href="#Removal">Removal</a></li>
+<li><a href="#Load_statement">Load Statement</a></li>
+</ul>
+</li>
+<li><a href="#Modification_statements">Modification Statements</a>
+<ul>
+
+<li><a href="#Inserts">Inserts</a></li>
+<li><a href="#Upserts">Upserts</a></li>
+<li><a href="#Deletes">Deletes</a></li>
+</ul>
+</li>
+</ul>
+</li>
+<li><a href="#Reserved_keywords">Appendix 1. Reserved Keywords</a></li>
+<li><a href="#Performance_tuning">Appendix 2. Performance Tuning</a>
+<ul>
+
+<li><a href="#Parallelism_parameter">Parallelism Parameter</a></li>
+<li><a href="#Memory_parameters">Memory Parameters</a></li>
+</ul>
+</li>
+<li><a href="#Variable_bindings_and_name_resolution">Appendix 3. Variable Bindings and Name Resolution</a></li>
+</ul><!--
+ ! 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.
+ !-->
+
+<h1><a name="Introduction" id="Introduction">1. Introduction</a><font size="3" /></h1>
+<p>This document is intended as a reference guide to the full syntax and semantics of AsterixDB’s query language, a SQL-based language for working with semistructured data. The language is a derivative of SQL++, a declarative query language for JSON data which is largely backwards compatible with SQL. SQL++ originated from research in the FORWARD project at UC San Diego, and it has much in common with SQL; some differences exist due to the different data models that the two languages were designed to serve. SQL was designed for interacting with the flat, schema-ified world of relational databases, while SQL++ generalizes SQL to also handle nested data formats (like JSON) and the schema-optional (or even schema-less) data models of modern NoSQL and BigData systems.</p>
+<p>In the context of Apache AsterixDB, the query language is intended for working with the Asterix Data Model (<a href="../datamodel.html">ADM</a>), a data model based on a superset of JSON with an enriched and flexible type system. New AsterixDB users are encouraged to read and work through the (much friendlier) guide “<a href="primer-sqlpp.html">AsterixDB 101: An ADM and SQL++ Primer</a>” before attempting to make use of this document. In addition, readers are advised to read through the <a href="../datamodel.html">Asterix Data Model (ADM) reference guide</a> first as well, as an understanding of the data model is a prerequisite to understanding the query language.</p>
+<p>In what follows, we detail the features of the query language in a grammar-guided manner. We list and briefly explain each of the productions in the query grammar, offering examples (and results) for clarity.</p><!--
+ ! 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.
+ !-->
+
+<h1><a name="Expressions" id="Expressions">2. Expressions</a></h1><!--
+ ! 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.
+ !-->
+
+<p>The query language is a highly composable expression language. Each expression in the query language returns zero or more data model instances. There are three major kinds of expressions. At the topmost level, an expression can be an OperatorExpression (similar to a mathematical expression) or a QuantifiedExpression (which yields a boolean value). Each will be detailed as we explore the full grammar of the language.</p>
+
+<div>
+<div>
+<pre class="source">Expression ::= OperatorExpression | QuantifiedExpression
+</pre></div></div>
+
+<p>Note that in the following text, words enclosed in angle brackets denote keywords that are not case-sensitive.</p>
+<div class="section">
+<h2><a name="Operator_Expressions"></a><a name="Operator_expressions" id="Operator_expressions">Operator Expressions</a></h2>
+<p>Operators perform a specific operation on the input values or expressions. The syntax of an operator expression is as follows:</p>
+
+<div>
+<div>
+<pre class="source">OperatorExpression ::= PathExpression
+ | Operator OperatorExpression
+ | OperatorExpression Operator (OperatorExpression)?
+ | OperatorExpression <BETWEEN> OperatorExpression <AND> OperatorExpression
+</pre></div></div>
+
+<p>The language provides a full set of operators that you can use within its statements. Here are the categories of operators:</p>
+<ul>
+
+<li><a href="#Arithmetic_operators">Arithmetic Operators</a>, to perform basic mathematical operations;</li>
+<li><a href="#Collection_operators">Collection Operators</a>, to evaluate expressions on collections or objects;</li>
+<li><a href="#Comparison_operators">Comparison Operators</a>, to compare two expressions;</li>
+<li><a href="#Logical_operators">Logical Operators</a>, to combine operators using Boolean logic.</li>
+</ul>
+<p>The following table summarizes the precedence order (from higher to lower) of the major unary and binary operators:</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Operation </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> EXISTS, NOT EXISTS </td>
+<td> Collection emptiness testing </td></tr>
+<tr class="a">
+<td> ^ </td>
+<td> Exponentiation </td></tr>
+<tr class="b">
+<td> *, /, DIV, MOD (%) </td>
+<td> Multiplication, division, modulo </td></tr>
+<tr class="a">
+<td> +, - </td>
+<td> Addition, subtraction </td></tr>
+<tr class="b">
+<td> || </td>
+<td> String concatenation </td></tr>
+<tr class="a">
+<td> IS NULL, IS NOT NULL, IS MISSING, IS NOT MISSING, <br />IS UNKNOWN, IS NOT UNKNOWN, IS VALUED, IS NOT VALUED </td>
+<td> Unknown value comparison </td></tr>
+<tr class="b">
+<td> BETWEEN, NOT BETWEEN </td>
+<td> Range comparison (inclusive on both sides) </td></tr>
+<tr class="a">
+<td> =, !=, <>, <, >, <=, >=, LIKE, NOT LIKE, IN, NOT IN </td>
+<td> Comparison </td></tr>
+<tr class="b">
+<td> NOT </td>
+<td> Logical negation </td></tr>
+<tr class="a">
+<td> AND </td>
+<td> Conjunction </td></tr>
+<tr class="b">
+<td> OR </td>
+<td> Disjunction </td></tr>
+</tbody>
+</table>
+<p>In general, if any operand evaluates to a <tt>MISSING</tt> value, the enclosing operator will return <tt>MISSING</tt>; if none of operands evaluates to a <tt>MISSING</tt> value but there is an operand evaluates to a <tt>NULL</tt> value, the enclosing operator will return <tt>NULL</tt>. However, there are a few exceptions listed in <a href="#Comparison_operators">comparison operators</a> and <a href="#Logical_operators">logical operators</a>.</p>
+<div class="section">
+<h3><a name="Arithmetic_Operators"></a><a name="Arithmetic_operators" id="Arithmetic_operators">Arithmetic Operators</a></h3>
+<p>Arithmetic operators are used to exponentiate, add, subtract, multiply, and divide numeric values, or concatenate string values.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Purpose </th>
+<th> Example </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> +, - </td>
+<td> As unary operators, they denote a <br />positive or negative expression </td>
+<td> SELECT VALUE -1; </td></tr>
+<tr class="a">
+<td> +, - </td>
+<td> As binary operators, they add or subtract </td>
+<td> SELECT VALUE 1 + 2; </td></tr>
+<tr class="b">
+<td> * </td>
+<td> Multiply </td>
+<td> SELECT VALUE 4 * 2; </td></tr>
+<tr class="a">
+<td> / </td>
+<td> Divide (returns a value of type <tt>double</tt> if both operands are integers)</td>
+<td> SELECT VALUE 5 / 2; </td></tr>
+<tr class="b">
+<td> DIV </td>
+<td> Divide (returns an integer value if both operands are integers) </td>
+<td> SELECT VALUE 5 DIV 2; </td></tr>
+<tr class="a">
+<td> MOD (%) </td>
+<td> Modulo </td>
+<td> SELECT VALUE 5 % 2; </td></tr>
+<tr class="b">
+<td> ^ </td>
+<td> Exponentiation </td>
+<td> SELECT VALUE 2^3; </td></tr>
+<tr class="a">
+<td> || </td>
+<td> String concatenation </td>
+<td> SELECT VALUE “ab”||“c”||“d”; </td></tr>
+</tbody>
+</table></div>
+<div class="section">
+<h3><a name="Collection_Operators"></a><a name="Collection_operators" id="Collection_operators">Collection Operators</a></h3>
+<p>Collection operators are used for membership tests (IN, NOT IN) or empty collection tests (EXISTS, NOT EXISTS).</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Purpose </th>
+<th> Example </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> IN </td>
+<td> Membership test </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.lang IN [“en”, “de”]; </td></tr>
+<tr class="a">
+<td> NOT IN </td>
+<td> Non-membership test </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.lang NOT IN [“en”]; </td></tr>
+<tr class="b">
+<td> EXISTS </td>
+<td> Check whether a collection is not empty </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE EXISTS cm.referredTopics; </td></tr>
+<tr class="a">
+<td> NOT EXISTS </td>
+<td> Check whether a collection is empty </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE NOT EXISTS cm.referredTopics; </td></tr>
+</tbody>
+</table></div>
+<div class="section">
+<h3><a name="Comparison_Operators"></a><a name="Comparison_operators" id="Comparison_operators">Comparison Operators</a></h3>
+<p>Comparison operators are used to compare values. The comparison operators fall into one of two sub-categories: missing value comparisons and regular value comparisons. The query language (and JSON) has two ways of representing missing information in a object - the presence of the field with a NULL for its value (as in SQL), and the absence of the field (which JSON permits). For example, the first of the following objects represents Jack, whose friend is Jill. In the other examples, Jake is friendless a la SQL, with a friend field that is NULL, while Joe is friendless in a more natural (for JSON) way, i.e., by not having a friend field.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+<p>{“name”: “Jack”, “friend”: “Jill”}</p>
+<p>{“name”: “Jake”, “friend”: NULL}</p>
+<p>{“name”: “Joe”}</p>
+<p>The following table enumerates all of the query language’s comparison operators.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Purpose </th>
+<th> Example </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> IS NULL </td>
+<td> Test if a value is NULL </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS NULL; </td></tr>
+<tr class="a">
+<td> IS NOT NULL </td>
+<td> Test if a value is not NULL </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS NOT NULL; </td></tr>
+<tr class="b">
+<td> IS MISSING </td>
+<td> Test if a value is MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS MISSING; </td></tr>
+<tr class="a">
+<td> IS NOT MISSING </td>
+<td> Test if a value is not MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS NOT MISSING;</td></tr>
+<tr class="b">
+<td> IS UNKNOWN </td>
+<td> Test if a value is NULL or MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS UNKNOWN; </td></tr>
+<tr class="a">
+<td> IS NOT UNKNOWN </td>
+<td> Test if a value is neither NULL nor MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS NOT UNKNOWN;</td></tr>
+<tr class="b">
+<td> IS KNOWN (IS VALUED) </td>
+<td> Test if a value is neither NULL nor MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS KNOWN; </td></tr>
+<tr class="a">
+<td> IS NOT KNOWN (IS NOT VALUED) </td>
+<td> Test if a value is NULL or MISSING </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name IS NOT KNOWN; </td></tr>
+<tr class="b">
+<td> BETWEEN </td>
+<td> Test if a value is between a start value and <br />a end value. The comparison is inclusive <br />to both start and end values. </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId BETWEEN 10 AND 20;</td></tr>
+<tr class="a">
+<td> = </td>
+<td> Equality test </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId=10; </td></tr>
+<tr class="b">
+<td> != </td>
+<td> Inequality test </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId!=10;</td></tr>
+<tr class="a">
+<td> <> </td>
+<td> Inequality test </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId<>10;</td></tr>
+<tr class="b">
+<td> < </td>
+<td> Less than </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId<10; </td></tr>
+<tr class="a">
+<td> > </td>
+<td> Greater than </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId>10; </td></tr>
+<tr class="b">
+<td> <= </td>
+<td> Less than or equal to </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId<=10; </td></tr>
+<tr class="a">
+<td> >= </td>
+<td> Greater than or equal to </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId>=10; </td></tr>
+<tr class="b">
+<td> LIKE </td>
+<td> Test if the left side matches a<br /> pattern defined on the right<br /> side; in the pattern, “%” matches <br />any string while “_” matches <br /> any character. </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name LIKE “%Giesen%”;</td></tr>
+<tr class="a">
+<td> NOT LIKE </td>
+<td> Test if the left side does not <br />match a pattern defined on the right<br /> side; in the pattern, “%” matches <br />any string while “_” matches <br /> any character. </td>
+<td> SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name NOT LIKE “%Giesen%”;</td></tr>
+</tbody>
+</table>
+<p>The following table summarizes how the missing value comparison operators work.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Non-NULL/Non-MISSING value </th>
+<th> NULL </th>
+<th> MISSING </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> IS NULL </td>
+<td> FALSE </td>
+<td> TRUE </td>
+<td> MISSING </td></tr>
+<tr class="a">
+<td> IS NOT NULL </td>
+<td> TRUE </td>
+<td> FALSE </td>
+<td> MISSING </td></tr>
+<tr class="b">
+<td> IS MISSING </td>
+<td> FALSE </td>
+<td> FALSE </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> IS NOT MISSING </td>
+<td> TRUE </td>
+<td> TRUE </td>
+<td> FALSE </td></tr>
+<tr class="b">
+<td> IS UNKNOWN </td>
+<td> FALSE </td>
+<td> TRUE </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> IS NOT UNKNOWN </td>
+<td> TRUE </td>
+<td> FALSE </td>
+<td> FALSE</td></tr>
+<tr class="b">
+<td> IS KNOWN (IS VALUED) </td>
+<td> TRUE </td>
+<td> FALSE </td>
+<td> FALSE </td></tr>
+<tr class="a">
+<td> IS NOT KNOWN (IS NOT VALUED) </td>
+<td> FALSE </td>
+<td> TRUE </td>
+<td> TRUE </td></tr>
+</tbody>
+</table></div></div></div>
+<div class="section">
+<h3><a name="Logical_Operators"></a><a name="Logical_operators" id="Logical_operators">Logical Operators</a></h3>
+<p>Logical operators perform logical <tt>NOT</tt>, <tt>AND</tt>, and <tt>OR</tt> operations over Boolean values (<tt>TRUE</tt> and <tt>FALSE</tt>) plus <tt>NULL</tt> and <tt>MISSING</tt>.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Operator </th>
+<th> Purpose </th>
+<th> Example </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> NOT </td>
+<td> Returns true if the following condition is false, otherwise returns false </td>
+<td> SELECT VALUE NOT TRUE; </td></tr>
+<tr class="a">
+<td> AND </td>
+<td> Returns true if both branches are true, otherwise returns false </td>
+<td> SELECT VALUE TRUE AND FALSE; </td></tr>
+<tr class="b">
+<td> OR </td>
+<td> Returns true if one branch is true, otherwise returns false </td>
+<td> SELECT VALUE FALSE OR FALSE; </td></tr>
+</tbody>
+</table>
+<p>The following table is the truth table for <tt>AND</tt> and <tt>OR</tt>.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> A </th>
+<th> B </th>
+<th> A AND B </th>
+<th> A OR B </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> TRUE </td>
+<td> TRUE </td>
+<td> TRUE </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> TRUE </td>
+<td> FALSE </td>
+<td> FALSE </td>
+<td> TRUE </td></tr>
+<tr class="b">
+<td> TRUE </td>
+<td> NULL </td>
+<td> NULL </td>
+<td> TRUE </td></tr>
+<tr class="a">
+<td> TRUE </td>
+<td> MISSING </td>
+<td> MISSING </td>
+<td> TRUE </td></tr>
+<tr class="b">
+<td> FALSE </td>
+<td> FALSE </td>
+<td> FALSE </td>
+<td> FALSE </td></tr>
+<tr class="a">
+<td> FALSE </td>
+<td> NULL </td>
+<td> FALSE </td>
+<td> NULL </td></tr>
+<tr class="b">
+<td> FALSE </td>
+<td> MISSING </td>
+<td> FALSE </td>
+<td> MISSING </td></tr>
+<tr class="a">
+<td> NULL </td>
+<td> NULL </td>
+<td> NULL </td>
+<td> NULL </td></tr>
+<tr class="b">
+<td> NULL </td>
+<td> MISSING </td>
+<td> MISSING </td>
+<td> NULL </td></tr>
+<tr class="a">
+<td> MISSING </td>
+<td> MISSING </td>
+<td> MISSING </td>
+<td> MISSING </td></tr>
+</tbody>
+</table>
+<p>The following table demonstrates the results of <tt>NOT</tt> on all possible inputs.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> A </th>
+<th> NOT A </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> TRUE </td>
+<td> FALSE </td></tr>
+<tr class="a">
+<td> FALSE </td>
+<td> TRUE </td></tr>
+<tr class="b">
+<td> NULL </td>
+<td> NULL </td></tr>
+<tr class="a">
+<td> MISSING </td>
+<td> MISSING </td></tr>
+</tbody>
+</table></div></div>
+<div class="section">
+<h2><a name="Quantified_Expressions"></a><a name="Quantified_expressions" id="Quantified_expressions">Quantified Expressions</a></h2>
+
+<div>
+<div>
+<pre class="source">QuantifiedExpression ::= ( (<ANY>|<SOME>) | <EVERY> ) Variable <IN> Expression ( "," Variable "in" Expression )*
+ <SATISFIES> Expression (<END>)?
+</pre></div></div>
+
+<p>Quantified expressions are used for expressing existential or universal predicates involving the elements of a collection.</p>
+<p>The following pair of examples illustrate the use of a quantified expression to test that every (or some) element in the set [1, 2, 3] of integers is less than three. The first example yields <tt>FALSE</tt> and second example yields <tt>TRUE</tt>.</p>
+<p>It is useful to note that if the set were instead the empty set, the first expression would yield <tt>TRUE</tt> (“every” value in an empty set satisfies the condition) while the second expression would yield <tt>FALSE</tt> (since there isn’t “some” value, as there are no values in the set, that satisfies the condition).</p>
+<p>A quantified expression will return a <tt>NULL</tt> (or <tt>MISSING</tt>) if the first expression in it evaluates to <tt>NULL</tt> (or <tt>MISSING</tt>). A type error will be raised if the first expression in a quantified expression does not return a collection.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">EVERY x IN [ 1, 2, 3 ] SATISFIES x < 3
+SOME x IN [ 1, 2, 3 ] SATISFIES x < 3
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Path_Expressions"></a><a name="Path_expressions" id="Path_expressions">Path Expressions</a></h2>
+
+<div>
+<div>
+<pre class="source">PathExpression ::= PrimaryExpression ( Field | Index )*
+Field ::= "." Identifier
+Index ::= "[" Expression (":" ( Expression )? )? "]"
+</pre></div></div>
+
+<p>Components of complex types in the data model are accessed via path expressions. Path access can be applied to the result of a query expression that yields an instance of a complex type, for example, an object or an array instance.</p>
+<p>For objects, path access is based on field names, and it accesses the field whose name was specified.<br /> For arrays, path access is based on (zero-based) array-style indexing. Array indexes can be used to retrieve either a single element from an array, or a whole subset of an array. Accessing a single element is achieved by providing a single index argument (zero-based element position), while obtaining a subset of an array is achieved by providing the <tt>start</tt> and <tt>end</tt> (zero-based) index positions; the returned subset is from position <tt>start</tt> to position <tt>end - 1</tt>; the <tt>end</tt> position argument is optional. If a position argument is negative then the element position is counted from the end of the array (<tt>-1</tt> addresses the last element, <tt>-2</tt> next to last, and so on). Multisets have similar behavior to arrays, except for retrieving arbitrary items as the order of items is not fixed in multisets.</p>
+<p>Attempts to access non-existent fields or out-of-bound array elements produce the special value <tt>MISSING</tt>. Type errors will be raised for inappropriate use of a path expression, such as applying a field accessor to a numeric value.</p>
+<p>The following examples illustrate field access for an object, index-based element access or subset retrieval of an array, and also a composition thereof.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">({"name": "MyABCs", "array": [ "a", "b", "c"]}).array
+
+(["a", "b", "c"])[2]
+
+(["a", "b", "c"])[-1]
+
+({"name": "MyABCs", "array": [ "a", "b", "c"]}).array[2]
+
+(["a", "b", "c"])[0:2]
+
+(["a", "b", "c"])[0:]
+
+(["a", "b", "c"])[-2:-1]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Primary_Expressions"></a><a name="Primary_expressions" id="Primary_expressions">Primary Expressions</a></h2>
+
+<div>
+<div>
+<pre class="source">PrimaryExpr ::= Literal
+ | VariableReference
+ | ParameterReference
+ | ParenthesizedExpression
+ | FunctionCallExpression
+ | CaseExpression
+ | Constructor
+</pre></div></div>
+
+<p>The most basic building block for any expression in the query language is PrimaryExpression. This can be a simple literal (constant) value, a reference to a query variable that is in scope, a parenthesized expression, a function call, or a newly constructed instance of the data model (such as a newly constructed object, array, or multiset of data model instances).</p></div>
+<div class="section">
+<h2><a name="Literals" id="Literals">Literals</a></h2>
+
+<div>
+<div>
+<pre class="source">Literal ::= StringLiteral
+ | IntegerLiteral
+ | FloatLiteral
+ | DoubleLiteral
+ | <NULL>
+ | <MISSING>
+ | <TRUE>
+ | <FALSE>
+StringLiteral ::= "\"" (
+ <EscapeQuot>
+ | <EscapeBslash>
+ | <EscapeSlash>
+ | <EscapeBspace>
+ | <EscapeFormf>
+ | <EscapeNl>
+ | <EscapeCr>
+ | <EscapeTab>
+ | ~["\"","\\"])*
+ "\""
+ | "\'"(
+ <EscapeApos>
+ | <EscapeBslash>
+ | <EscapeSlash>
+ | <EscapeBspace>
+ | <EscapeFormf>
+ | <EscapeNl>
+ | <EscapeCr>
+ | <EscapeTab>
+ | ~["\'","\\"])*
+ "\'"
+<ESCAPE_Apos> ::= "\\\'"
+<ESCAPE_Quot> ::= "\\\""
+<EscapeBslash> ::= "\\\\"
+<EscapeSlash> ::= "\\/"
+<EscapeBspace> ::= "\\b"
+<EscapeFormf> ::= "\\f"
+<EscapeNl> ::= "\\n"
+<EscapeCr> ::= "\\r"
+<EscapeTab> ::= "\\t"
+
+IntegerLiteral ::= <DIGITS>
+<DIGITS> ::= ["0" - "9"]+
+FloatLiteral ::= <DIGITS> ( "f" | "F" )
+ | <DIGITS> ( "." <DIGITS> ( "f" | "F" ) )?
+ | "." <DIGITS> ( "f" | "F" )
+DoubleLiteral ::= <DIGITS> "." <DIGITS>
+ | "." <DIGITS>
+</pre></div></div>
+
+<p>Literals (constants) in a query can be strings, integers, floating point values, double values, boolean constants, or special constant values like <tt>NULL</tt> and <tt>MISSING</tt>. The <tt>NULL</tt> value is like a <tt>NULL</tt> in SQL; it is used to represent an unknown field value. The special value <tt>MISSING</tt> is only meaningful in the context of field accesses; it occurs when the accessed field simply does not exist at all in a object being accessed.</p>
+<p>The following are some simple examples of literals.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">'a string'
+"test string"
+42
+</pre></div></div>
+
+<p>Different from standard SQL, double quotes play the same role as single quotes and may be used for string literals in queries as well.</p></div></div></div>
+<div class="section">
+<h3><a name="Variable_References"></a><a name="Variable_references" id="Variable_references">Variable References</a></h3>
+
+<div>
+<div>
+<pre class="source">VariableReference ::= <IDENTIFIER> | <DelimitedIdentifier>
+<IDENTIFIER> ::= (<LETTER> | "_") (<LETTER> | <DIGIT> | "_" | "$")*
+<LETTER> ::= ["A" - "Z", "a" - "z"]
+DelimitedIdentifier ::= "`" (<EscapeQuot>
+ | <EscapeBslash>
+ | <EscapeSlash>
+ | <EscapeBspace>
+ | <EscapeFormf>
+ | <EscapeNl>
+ | <EscapeCr>
+ | <EscapeTab>
+ | ~["`","\\"])*
+ "`"
+</pre></div></div>
+
+<p>A variable in a query can be bound to any legal data model value. A variable reference refers to the value to which an in-scope variable is bound. (E.g., a variable binding may originate from one of the <tt>FROM</tt>, <tt>WITH</tt> or <tt>LET</tt> clauses of a <tt>SELECT</tt> statement or from an input parameter in the context of a function body.) Backticks, for example, `id`, are used for delimited identifiers. Delimiting is needed when a variable’s desired name clashes with a keyword or includes characters not allowed in regular identifiers. More information on exactly how variable references are resolved can be found in the appendix section on Variable Resolution.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">tweet
+id
+`SELECT`
+`my-function`
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Parameter_References"></a><a name="Parameter_references" id="Parameter_references">Parameter References</a></h3>
+
+<div>
+<div>
+<pre class="source">ParameterReference ::= NamedParameterReference | PositionalParameterReference
+NamedParameterReference ::= "$" (<IDENTIFIER> | <DelimitedIdentifier>)
+PositionalParameterReference ::= ("$" <DIGITS>) | "?"
+</pre></div></div>
+
+<p>A statement parameter is an external variable which value is provided through the <a href="../api.html#queryservice">statement execution API</a>. An error will be raised if the parameter is not bound at the query execution time. Positional parameter numbering starts at 1. “?” parameters are interpreted as $1, .. $N in the order in which they appear in the statement.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">$id
+$1
+?
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Parenthesized_Expressions"></a><a name="Parenthesized_expressions" id="Parenthesized_expressions">Parenthesized Expressions</a></h3>
+
+<div>
+<div>
+<pre class="source">ParenthesizedExpression ::= "(" Expression ")" | Subquery
+</pre></div></div>
+
+<p>An expression can be parenthesized to control the precedence order or otherwise clarify a query. For composability, a subquery is also an parenthesized expression.</p>
+<p>The following expression evaluates to the value 2.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">( 1 + 1 )
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Function_Call_Expressions"></a><a name="Function_call_expressions" id="Function_call_expressions">Function Call Expressions</a></h3>
+
+<div>
+<div>
+<pre class="source">FunctionCallExpression ::= ( FunctionName "(" ( Expression ( "," Expression )* )? ")" ) | WindowFunctionCall
+</pre></div></div>
+
+<p>Functions are included in the query language, like most languages, as a way to package useful functionality or to componentize complicated or reusable computations. A function call is a legal query expression that represents the value resulting from the evaluation of its body expression with the given parameter bindings; the parameter value bindings can themselves be any expressions in the query language.</p>
+<p>Note that Window functions, and aggregate functions used as window functions, have a more complex syntax. Window function calls are described in the section on <a href="#Over_clauses">OVER Clauses</a>.</p>
+<p>The following example is a (built-in) function call expression whose value is 8.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">length('a string')
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Case_Expressions"></a><a name="Case_expressions" id="Case_expressions">Case Expressions</a></h2>
+
+<div>
+<div>
+<pre class="source">CaseExpression ::= SimpleCaseExpression | SearchedCaseExpression
+SimpleCaseExpression ::= <CASE> Expression ( <WHEN> Expression <THEN> Expression )+ ( <ELSE> Expression )? <END>
+SearchedCaseExpression ::= <CASE> ( <WHEN> Expression <THEN> Expression )+ ( <ELSE> Expression )? <END>
+</pre></div></div>
+
+<p>In a simple <tt>CASE</tt> expression, the query evaluator searches for the first <tt>WHEN</tt> … <tt>THEN</tt> pair in which the <tt>WHEN</tt> expression is equal to the expression following <tt>CASE</tt> and returns the expression following <tt>THEN</tt>. If none of the <tt>WHEN</tt> … <tt>THEN</tt> pairs meet this condition, and an <tt>ELSE</tt> branch exists, it returns the <tt>ELSE</tt> expression. Otherwise, <tt>NULL</tt> is returned.</p>
+<p>In a searched CASE expression, the query evaluator searches from left to right until it finds a <tt>WHEN</tt> expression that is evaluated to <tt>TRUE</tt>, and then returns its corresponding <tt>THEN</tt> expression. If no condition is found to be <tt>TRUE</tt>, and an <tt>ELSE</tt> branch exists, it returns the <tt>ELSE</tt> expression. Otherwise, it returns <tt>NULL</tt>.</p>
+<p>The following example illustrates the form of a case expression.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CASE (2 < 3) WHEN true THEN "yes" ELSE "no" END
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Constructors" id="Constructors">Constructors</a></h3>
+
+<div>
+<div>
+<pre class="source">Constructor ::= ArrayConstructor | MultisetConstructor | ObjectConstructor
+ArrayConstructor ::= "[" ( Expression ( "," Expression )* )? "]"
+MultisetConstructor ::= "{{" ( Expression ( "," Expression )* )? "}}"
+ObjectConstructor ::= "{" ( FieldBinding ( "," FieldBinding )* )? "}"
+FieldBinding ::= Expression ( ":" Expression )?
+</pre></div></div>
+
+<p>A major feature of the query language is its ability to construct new data model instances. This is accomplished using its constructors for each of the model’s complex object structures, namely arrays, multisets, and objects. Arrays are like JSON arrays, while multisets have bag semantics. Objects are built from fields that are field-name/field-value pairs, again like JSON.</p>
+<p>The following examples illustrate how to construct a new array with 4 items and a new object with 2 fields respectively. Array elements can be homogeneous (as in the first example), which is the common case, or they may be heterogeneous (as in the second example). The data values and field name values used to construct arrays, multisets, and objects in constructors are all simply query expressions. Thus, the collection elements, field names, and field values used in constructors can be simple literals or they can come from query variable references or even arbitrarily complex query expressions (subqueries). Type errors will be raised if the field names in an object are not strings, and duplicate field errors will be raised if they are not distinct.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div>
+<div>
+<pre class="source">[ 'a', 'b', 'c', 'c' ]
+
+[ 42, "forty-two!", { "rank" : "Captain", "name": "America" }, 3.14159 ]
+
+{
+ 'project name': 'Hyracks',
+ 'project members': [ 'vinayakb', 'dtabass', 'chenli', 'tsotras', 'tillw' ]
+}
+</pre></div></div>
+
+<p>If only one expression is specified instead of the field-name/field-value pair in an object constructor then this expression is supposed to provide the field value. The field name is then automatically generated based on the kind of the value expression:</p>
+<ul>
+
+<li>If it is a variable reference expression then generated field name is the name of that variable.</li>
+<li>If it is a field access expression then generated field name is the last identifier in that expression.</li>
+<li>For all other cases, a compilation error will be raised.</li>
+</ul></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT VALUE { user.alias, user.userSince }
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+
+<p>This query outputs:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "alias": "Margarita",
+ "userSince": "2012-08-20T10:10:00"
+} ]
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+
+<h1><a name="Queries" id="Queries">3. Queries</a></h1>
+<p>A query can be any legal expression or <tt>SELECT</tt> statement. A query always ends with a semicolon.</p>
+
+<div>
+<div>
+<pre class="source">Query ::= (Expression | SelectStatement) ";"
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Declarations" id="Declarations">Declarations</a></h2>
+
+<div>
+<div>
+<pre class="source">DatabaseDeclaration ::= "USE" Identifier
+</pre></div></div>
+
+<p>At the uppermost level, the world of data is organized into data namespaces called <b>dataverses</b>. To set the default dataverse for statements, the USE statement is provided.</p>
+<p>As an example, the following statement sets the default dataverse to be “TinySocial”.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">USE TinySocial;
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+
+<p>When writing a complex query, it can sometimes be helpful to define one or more auxilliary functions that each address a sub-piece of the overall query. The declare function statement supports the creation of such helper functions. In general, the function body (expression) can be any legal query expression.</p>
+
+<div>
+<div>
+<pre class="source">FunctionDeclaration ::= "DECLARE" "FUNCTION" Identifier ParameterList "{" Expression "}"
+ParameterList ::= "(" ( <VARIABLE> ( "," <VARIABLE> )* )? ")"
+</pre></div></div>
+
+<p>The following is a simple example of a temporary function definition and its use.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">DECLARE FUNCTION friendInfo(userId) {
+ (SELECT u.id, u.name, len(u.friendIds) AS friendCount
+ FROM GleambookUsers u
+ WHERE u.id = userId)[0]
+ };
+
+SELECT VALUE friendInfo(2);
+</pre></div></div>
+
+<p>For our sample data set, this returns:</p>
+
+<div>
+<div>
+<pre class="source">[
+ { "id": 2, "name": "IsbelDull", "friendCount": 2 }
+]
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="SELECT_Statements"></a><a name="SELECT_statements" id="SELECT_statements">SELECT Statements</a></h2>
+<p>The following shows the (rich) grammar for the <tt>SELECT</tt> statement in the query language.</p>
+
+<div>
+<div>
+<pre class="source">SelectStatement ::= ( WithClause )?
+ SelectSetOperation (OrderbyClause )? ( LimitClause )?
+SelectSetOperation ::= SelectBlock (<UNION> <ALL> ( SelectBlock | Subquery ) )*
+Subquery ::= "(" SelectStatement ")"
+
+SelectBlock ::= SelectClause
+ ( FromClause ( LetClause )?)?
+ ( WhereClause )?
+ ( GroupbyClause ( LetClause )? ( HavingClause )? )?
+ |
+ FromClause ( LetClause )?
+ ( WhereClause )?
+ ( GroupbyClause ( LetClause )? ( HavingClause )? )?
+ SelectClause
+
+SelectClause ::= <SELECT> ( <ALL> | <DISTINCT> )? ( SelectRegular | SelectValue )
+SelectRegular ::= Projection ( "," Projection )*
+SelectValue ::= ( <VALUE> | <ELEMENT> | <RAW> ) Expression
+Projection ::= ( Expression ( <AS> )? Identifier | "*" | Identifier "." "*" )
+
+FromClause ::= <FROM> FromTerm ( "," FromTerm )*
+FromTerm ::= Expression (( <AS> )? Variable)?
+ ( ( JoinType )? ( JoinClause | UnnestClause ) )*
+
+JoinClause ::= <JOIN> Expression (( <AS> )? Variable)? <ON> Expression
+UnnestClause ::= ( <UNNEST> ) Expression
+ ( <AS> )? Variable ( <AT> Variable )?
+JoinType ::= ( <INNER> | <LEFT> ( <OUTER> )? )
+
+WithClause ::= <WITH> WithElement ( "," WithElement )*
+LetClause ::= (<LET> | <LETTING>) LetElement ( "," LetElement )*
+LetElement ::= Variable "=" Expression
+WithElement ::= Variable <AS> Expression
+
+WhereClause ::= <WHERE> Expression
+
+GroupbyClause ::= <GROUP> <BY> Expression ( ( (<AS>)? Variable )?
+ ( "," Expression ( (<AS>)? Variable )? )* )
+ ( <GROUP> <AS> Variable
+ ("(" VariableReference <AS> Identifier
+ ("," VariableReference <AS> Identifier )* ")")?
+ )?
+HavingClause ::= <HAVING> Expression
+
+OrderbyClause ::= <ORDER> <BY> Expression ( <ASC> | <DESC> )?
+ ( "," Expression ( <ASC> | <DESC> )? )*
+LimitClause ::= <LIMIT> Expression ( <OFFSET> Expression )?
+</pre></div></div>
+
+<p>In this section, we will make use of two stored collections of objects (datasets), <tt>GleambookUsers</tt> and <tt>GleambookMessages</tt>, in a series of running examples to explain <tt>SELECT</tt> queries. The contents of the example collections are as follows:</p>
+<p><tt>GleambookUsers</tt> collection (or, dataset):</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "id":1,
+ "alias":"Margarita",
+ "name":"MargaritaStoddard",
+ "nickname":"Mags",
+ "userSince":"2012-08-20T10:10:00",
+ "friendIds":[2,3,6,10],
+ "employment":[{
+ "organizationName":"Codetechno",
+ "start-date":"2006-08-06"
+ },
+ {
+ "organizationName":"geomedia",
+ "start-date":"2010-06-17",
+ "end-date":"2010-01-26"
+ }],
+ "gender":"F"
+},
+{
+ "id":2,
+ "alias":"Isbel",
+ "name":"IsbelDull",
+ "nickname":"Izzy",
+ "userSince":"2011-01-22T10:10:00",
+ "friendIds":[1,4],
+ "employment":[{
+ "organizationName":"Hexviafind",
+ "startDate":"2010-04-27"
+ }]
+},
+{
+ "id":3,
+ "alias":"Emory",
+ "name":"EmoryUnk",
+ "userSince":"2012-07-10T10:10:00",
+ "friendIds":[1,5,8,9],
+ "employment":[{
+ "organizationName":"geomedia",
+ "startDate":"2010-06-17",
+ "endDate":"2010-01-26"
+ }]
+} ]
+</pre></div></div>
+
+<p><tt>GleambookMessages</tt> collection (or, dataset):</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "messageId":2,
+ "authorId":1,
+ "inResponseTo":4,
+ "senderLocation":[41.66,80.87],
+ "message":" dislike x-phone its touch-screen is horrible"
+},
+{
+ "messageId":3,
+ "authorId":2,
+ "inResponseTo":4,
+ "senderLocation":[48.09,81.01],
+ "message":" like product-y the plan is amazing"
+},
+{
+ "messageId":4,
+ "authorId":1,
+ "inResponseTo":2,
+ "senderLocation":[37.73,97.04],
+ "message":" can't stand acast the network is horrible:("
+},
+{
+ "messageId":6,
+ "authorId":2,
+ "inResponseTo":1,
+ "senderLocation":[31.5,75.56],
+ "message":" like product-z its platform is mind-blowing"
+}
+{
+ "messageId":8,
+ "authorId":1,
+ "inResponseTo":11,
+ "senderLocation":[40.33,80.87],
+ "message":" like ccast the 3G is awesome:)"
+},
+{
+ "messageId":10,
+ "authorId":1,
+ "inResponseTo":12,
+ "senderLocation":[42.5,70.01],
+ "message":" can't stand product-w the touch-screen is terrible"
+},
+{
+ "messageId":11,
+ "authorId":1,
+ "inResponseTo":1,
+ "senderLocation":[38.97,77.49],
+ "message":" can't stand acast its plan is terrible"
+} ]
+</pre></div></div>
+</div>
+<div class="section">
+<h2><a name="SELECT_Clause"></a><a name="Select_clauses" id="Select_clauses">SELECT Clause</a></h2>
+<p>The <tt>SELECT</tt> clause always returns a collection value as its result (even if the result is empty or a singleton).</p>
+<div class="section">
+<h3><a name="Select_Element.2FValue.2FRaw"></a><a name="Select_element" id="Select_element">Select Element/Value/Raw</a></h3>
+<p>The <tt>SELECT VALUE</tt> clause returns an array or multiset that contains the results of evaluating the <tt>VALUE</tt> expression, with one evaluation being performed per “binding tuple” (i.e., per <tt>FROM</tt> clause item) satisfying the statement’s selection criteria. For historical reasons the query language also allows the keywords <tt>ELEMENT</tt> or <tt>RAW</tt> to be used in place of <tt>VALUE</tt> (not recommended).</p>
+<p>If there is no FROM clause, the expression after <tt>VALUE</tt> is evaluated once with no binding tuples (except those inherited from an outer environment).</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT VALUE 1;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[
+ 1
+]
+</pre></div></div>
+
+<p>The following example shows a query that selects one user from the GleambookUsers collection.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT VALUE user
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[{
+ "userSince": "2012-08-20T10:10:00.000Z",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "gender": "F",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "alias": "Margarita",
+ "id": 1,
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "end-date": "2010-01-26",
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17"
+ }
+ ]
+} ]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="SQL-style_SELECT"></a><a name="SQL_select" id="SQL_select">SQL-style SELECT</a></h3>
+<p>The traditional SQL-style <tt>SELECT</tt> syntax is also supported in the query language. This syntax can also be reformulated in a <tt>SELECT VALUE</tt> based manner. (E.g., <tt>SELECT expA AS fldA, expB AS fldB</tt> is syntactic sugar for <tt>SELECT VALUE { 'fldA': expA, 'fldB': expB }</tt>.) Unlike in SQL, the result of a query does not preserve the order of expressions in the <tt>SELECT</tt> clause.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT user.alias user_alias, user.name user_name
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "user_name": "MargaritaStoddard",
+ "user_alias": "Margarita"
+} ]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="SELECT_.2A"></a><a name="Select_star" id="Select_star">SELECT *</a></h3>
+<p><tt>SELECT *</tt> returns an object with a nested field for each input tuple. Each field has as its field name the name of a binding variable generated by either the <tt>FROM</tt> clause or <tt>GROUP BY</tt> clause in the current enclosing <tt>SELECT</tt> statement, and its field value is the value of that binding variable.</p>
+<p>Note that the result of <tt>SELECT *</tt> is different from the result of query that selects all the fields of an object.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookUsers user;
+</pre></div></div>
+
+<p>Since <tt>user</tt> is the only binding variable generated in the <tt>FROM</tt> clause, this query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "user": {
+ "userSince": "2012-08-20T10:10:00.000Z",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "gender": "F",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "alias": "Margarita",
+ "id": 1,
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "end-date": "2010-01-26",
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17"
+ }
+ ]
+ }
+}, {
+ "user": {
+ "userSince": "2011-01-22T10:10:00.000Z",
+ "friendIds": [
+ 1,
+ 4
+ ],
+ "name": "IsbelDull",
+ "nickname": "Izzy",
+ "alias": "Isbel",
+ "id": 2,
+ "employment": [
+ {
+ "organizationName": "Hexviafind",
+ "startDate": "2010-04-27"
+ }
+ ]
+ }
+}, {
+ "user": {
+ "userSince": "2012-07-10T10:10:00.000Z",
+ "friendIds": [
+ 1,
+ 5,
+ 8,
+ 9
+ ],
+ "name": "EmoryUnk",
+ "alias": "Emory",
+ "id": 3,
+ "employment": [
+ {
+ "organizationName": "geomedia",
+ "endDate": "2010-01-26",
+ "startDate": "2010-06-17"
+ }
+ ]
+ }
+} ]
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookUsers u, GleambookMessages m
+WHERE m.authorId = u.id and u.id = 2;
+</pre></div></div>
+
+<p>This query does an inner join that we will discuss in <a href="#Multiple_from_terms">multiple from terms</a>. Since both <tt>u</tt> and <tt>m</tt> are binding variables generated in the <tt>FROM</tt> clause, this query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "u": {
+ "userSince": "2011-01-22T10:10:00",
+ "friendIds": [
+ 1,
+ 4
+ ],
+ "name": "IsbelDull",
+ "nickname": "Izzy",
+ "alias": "Isbel",
+ "id": 2,
+ "employment": [
+ {
+ "organizationName": "Hexviafind",
+ "startDate": "2010-04-27"
+ }
+ ]
+ },
+ "m": {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ }
+}, {
+ "u": {
+ "userSince": "2011-01-22T10:10:00",
+ "friendIds": [
+ 1,
+ 4
+ ],
+ "name": "IsbelDull",
+ "nickname": "Izzy",
+ "alias": "Isbel",
+ "id": 2,
+ "employment": [
+ {
+ "organizationName": "Hexviafind",
+ "startDate": "2010-04-27"
+ }
+ ]
+ },
+ "m": {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ }
+} ]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="SELECT_variable..2A"></a><a name="Select_variable_star" id="Select_variable_star">SELECT <i>variable</i>.*</a></h3>
+<p>Whereas <tt>SELECT *</tt> returns all the fields bound to all the variables which are currently defined, the notation <tt>SELECT c.*</tt> returns all the fields of the object bound to variable <tt>c</tt>. The variable <tt>c</tt> must be bound to an object for this to work.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT user.*
+FROM GleambookUsers user;
+</pre></div></div>
+
+<p>Compare this query with the first example given under <a href="#Select_star">SELECT *</a>. This query returns all users from the <tt>GleambookUsers</tt> dataset, but the <tt>user</tt> variable name is omitted from the results:</p>
+
+<div>
+<div>
+<pre class="source">[
+ {
+ "id": 1,
+ "alias": "Margarita",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "userSince": "2012-08-20T10:10:00",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17",
+ "end-date": "2010-01-26"
+ }
+ ],
+ "gender": "F"
+ },
+ {
+ "id": 2,
+ "alias": "Isbel",
+ "name": "IsbelDull",
+ "nickname": "Izzy",
+ "userSince": "2011-01-22T10:10:00",
+ "friendIds": [
+ 1,
+ 4
+ ],
+ "employment": [
+ {
+ "organizationName": "Hexviafind",
+ "startDate": "2010-04-27"
+ }
+ ]
+ },
+ {
+ "id": 3,
+ "alias": "Emory",
+ "name": "EmoryUnk",
+ "userSince": "2012-07-10T10:10:00",
+ "friendIds": [
+ 1,
+ 5,
+ 8,
+ 9
+ ],
+ "employment": [
+ {
+ "organizationName": "geomedia",
+ "startDate": "2010-06-17",
+ "endDate": "2010-01-26"
+ }
+ ]
+ }
+]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="SELECT_DISTINCT"></a><a name="Select_distinct" id="Select_distinct">SELECT DISTINCT</a></h3>
+<p>The <tt>DISTINCT</tt> keyword is used to eliminate duplicate items in results. The following example shows how it works.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT DISTINCT * FROM [1, 2, 2, 3] AS foo;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "foo": 1
+}, {
+ "foo": 2
+}, {
+ "foo": 3
+} ]
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT DISTINCT VALUE foo FROM [1, 2, 2, 3] AS foo;
+</pre></div></div>
+
+<p>This version of the query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ 1
+, 2
+, 3
+ ]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Unnamed_Projections"></a><a name="Unnamed_projections" id="Unnamed_projections">Unnamed Projections</a></h3>
+<p>Similar to standard SQL, the query language supports unnamed projections (a.k.a, unnamed <tt>SELECT</tt> clause items), for which names are generated. Name generation has three cases:</p>
+<ul>
+
+<li>If a projection expression is a variable reference expression, its generated name is the name of the variable.</li>
+<li>If a projection expression is a field access expression, its generated name is the last identifier in the expression.</li>
+<li>For all other cases, the query processor will generate a unique name.</li>
+</ul>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT substr(user.name, 10), user.alias
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+
+<p>This query outputs:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "alias": "Margarita",
+ "$1": "Stoddard"
+} ]
+</pre></div></div>
+
+<p>In the result, <tt>$1</tt> is the generated name for <tt>substr(user.name, 1)</tt>, while <tt>alias</tt> is the generated name for <tt>user.alias</tt>.</p></div></div></div>
+<div class="section">
+<h3><a name="Abbreviated_Field_Access_Expressions"></a><a name="Abbreviated_field_access_expressions" id="Abbreviated_field_access_expressions">Abbreviated Field Access Expressions</a></h3>
+<p>As in standard SQL, field access expressions can be abbreviated (not recommended!) when there is no ambiguity. In the next example, the variable <tt>user</tt> is the only possible variable reference for fields <tt>id</tt>, <tt>name</tt> and <tt>alias</tt> and thus could be omitted in the query. More information on abbbreviated field access can be found in the appendix section on Variable Resolution.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT substr(name, 10) AS lname, alias
+FROM GleambookUsers user
+WHERE id = 1;
+</pre></div></div>
+
+<p>Outputs:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "lname": "Stoddard",
+ "alias": "Margarita"
+} ]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="UNNEST_Clause"></a><a name="Unnest_clauses" id="Unnest_clauses">UNNEST Clause</a></h2>
+<p>For each of its input tuples, the <tt>UNNEST</tt> clause flattens a collection-valued expression into individual items, producing multiple tuples, each of which is one of the expression’s original input tuples augmented with a flattened item from its collection.</p>
+<div class="section">
+<h3><a name="Inner_UNNEST"></a><a name="Inner_unnests" id="Inner_unnests">Inner UNNEST</a></h3>
+<p>The following example is a query that retrieves the names of the organizations that a selected user has worked for. It uses the <tt>UNNEST</tt> clause to unnest the nested collection <tt>employment</tt> in the user’s object.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.id AS userId, e.organizationName AS orgName
+FROM GleambookUsers u
+UNNEST u.employment e
+WHERE u.id = 1;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "orgName": "Codetechno",
+ "userId": 1
+}, {
+ "orgName": "geomedia",
+ "userId": 1
+} ]
+</pre></div></div>
+
+<p>Note that <tt>UNNEST</tt> has SQL’s inner join semantics — that is, if a user has no employment history, no tuple corresponding to that user will be emitted in the result.</p></div></div></div>
+<div class="section">
+<h3><a name="Left_Outer_UNNEST"></a><a name="Left_outer_unnests" id="Left_outer_unnests">Left Outer UNNEST</a></h3>
+<p>As an alternative, the <tt>LEFT OUTER UNNEST</tt> clause offers SQL’s left outer join semantics. For example, no collection-valued field named <tt>hobbies</tt> exists in the object for the user whose id is 1, but the following query’s result still includes user 1.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.id AS userId, h.hobbyName AS hobby
+FROM GleambookUsers u
+LEFT OUTER UNNEST u.hobbies h
+WHERE u.id = 1;
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "userId": 1
+} ]
+</pre></div></div>
+
+<p>Note that if <tt>u.hobbies</tt> is an empty collection or leads to a <tt>MISSING</tt> (as above) or <tt>NULL</tt> value for a given input tuple, there is no corresponding binding value for variable <tt>h</tt> for an input tuple. A <tt>MISSING</tt> value will be generated for <tt>h</tt> so that the input tuple can still be propagated.</p></div></div></div>
+<div class="section">
+<h3><a name="Expressing_Joins_Using_UNNEST"></a><a name="Expressing_joins_using_unnests" id="Expressing_joins_using_unnests">Expressing Joins Using UNNEST</a></h3>
+<p>The <tt>UNNEST</tt> clause is similar to SQL’s <tt>JOIN</tt> clause except that it allows its right argument to be correlated to its left argument, as in the examples above — i.e., think “correlated cross-product”. The next example shows this via a query that joins two data sets, GleambookUsers and GleambookMessages, returning user/message pairs. The results contain one object per pair, with result objects containing the user’s name and an entire message. The query can be thought of as saying “for each Gleambook user, unnest the <tt>GleambookMessages</tt> collection and filter the output with the condition <tt>message.authorId = user.id</tt>”.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u
+UNNEST GleambookMessages m
+WHERE m.authorId = u.id;
+</pre></div></div>
+
+<p>This returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand acast its plan is terrible"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " dislike x-phone its touch-screen is horrible"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand acast the network is horrible:("
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " like ccast the 3G is awesome:)"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand product-w the touch-screen is terrible"
+}, {
+ "uname": "IsbelDull",
+ "message": " like product-z its platform is mind-blowing"
+}, {
+ "uname": "IsbelDull",
+ "message": " like product-y the plan is amazing"
+} ]
+</pre></div></div>
+
+<p>Similarly, the above query can also be expressed as the <tt>UNNEST</tt>ing of a correlated subquery:</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u
+UNNEST (
+ SELECT VALUE msg
+ FROM GleambookMessages msg
+ WHERE msg.authorId = u.id
+) AS m;
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="FROM_clauses"></a><a name="From_clauses" id="From_clauses">FROM clauses</a></h2>
+<p>A <tt>FROM</tt> clause is used for enumerating (i.e., conceptually iterating over) the contents of collections, as in SQL.</p>
+<div class="section">
+<h3><a name="Binding_expressions" id="Binding_expressions">Binding expressions</a></h3>
+<p>In addition to stored collections, a <tt>FROM</tt> clause can iterate over any intermediate collection returned by a valid query expression. In the tuple stream generated by a <tt>FROM</tt> clause, the ordering of the input tuples are not guaranteed to be preserved.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT VALUE foo
+FROM [1, 2, 2, 3] AS foo
+WHERE foo > 2;
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">[
+ 3
+]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Multiple_FROM_Terms"></a><a name="Multiple_from_terms" id="Multiple_from_terms">Multiple FROM Terms</a></h3>
+<p>The query language permits correlations among <tt>FROM</tt> terms. Specifically, a <tt>FROM</tt> binding expression can refer to variables defined to its left in the given <tt>FROM</tt> clause. Thus, the first unnesting example above could also be expressed as follows:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.id AS userId, e.organizationName AS orgName
+FROM GleambookUsers u, u.employment e
+WHERE u.id = 1;
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Expressing_Joins_Using_FROM_Terms"></a><a name="Expressing_joins_using_from_terms" id="Expressing_joins_using_from_terms">Expressing Joins Using FROM Terms</a></h3>
+<p>Similarly, the join intentions of the other <tt>UNNEST</tt>-based join examples above could be expressed as:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u, GleambookMessages m
+WHERE m.authorId = u.id;
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u,
+ (
+ SELECT VALUE msg
+ FROM GleambookMessages msg
+ WHERE msg.authorId = u.id
+ ) AS m;
+</pre></div></div>
+
+<p>Note that the first alternative is one of the SQL-92 approaches to expressing a join.</p></div></div></div>
+<div class="section">
+<h3><a name="Implicit_Binding_Variables"></a><a name="Implicit_binding_variables" id="Implicit_binding_variables">Implicit Binding Variables</a></h3>
+<p>Similar to standard SQL, the query language supports implicit <tt>FROM</tt> binding variables (i.e., aliases), for which a binding variable is generated. Variable generation falls into three cases:</p>
+<ul>
+
+<li>If the binding expression is a variable reference expression, the generated variable’s name will be the name of the referenced variable itself.</li>
+<li>If the binding expression is a field access expression (or a fully qualified name for a dataset), the generated variable’s name will be the last identifier (or the dataset name) in the expression.</li>
+<li>For all other cases, a compilation error will be raised.</li>
+</ul>
+<p>The next two examples show queries that do not provide binding variables in their <tt>FROM</tt> clauses.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT GleambookUsers.name, GleambookMessages.message
+FROM GleambookUsers, GleambookMessages
+WHERE GleambookMessages.authorId = GleambookUsers.id;
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "name": "MargaritaStoddard",
+ "message": " like ccast the 3G is awesome:)"
+}, {
+ "name": "MargaritaStoddard",
+ "message": " can't stand product-w the touch-screen is terrible"
+}, {
+ "name": "MargaritaStoddard",
+ "message": " can't stand acast its plan is terrible"
+}, {
+ "name": "MargaritaStoddard",
+ "message": " dislike x-phone its touch-screen is horrible"
+}, {
+ "name": "MargaritaStoddard",
+ "message": " can't stand acast the network is horrible:("
+}, {
+ "name": "IsbelDull",
+ "message": " like product-y the plan is amazing"
+}, {
+ "name": "IsbelDull",
+ "message": " like product-z its platform is mind-blowing"
+} ]
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT GleambookUsers.name, GleambookMessages.message
+FROM GleambookUsers,
+ (
+ SELECT VALUE GleambookMessages
+ FROM GleambookMessages
+ WHERE GleambookMessages.authorId = GleambookUsers.id
+ );
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">Error: "Syntax error: Need an alias for the enclosed expression:\n(select element GleambookMessages\n from GleambookMessages as GleambookMessages\n where (GleambookMessages.authorId = GleambookUsers.id)\n )",
+ "query_from_user": "use TinySocial;\n\nSELECT GleambookUsers.name, GleambookMessages.message\n FROM GleambookUsers,\n (\n SELECT VALUE GleambookMessages\n FROM GleambookMessages\n WHERE GleambookMessages.authorId = GleambookUsers.id\n );"
+</pre></div></div>
+
+<p>More information on implicit binding variables can be found in the appendix section on Variable Resolution.</p></div></div></div></div>
+<div class="section">
+<h2><a name="JOIN_Clauses"></a><a name="Join_clauses" id="Join_clauses">JOIN Clauses</a></h2>
+<p>The join clause in the query language supports both inner joins and left outer joins from standard SQL.</p>
+<div class="section">
+<h3><a name="Inner_joins" id="Inner_joins">Inner joins</a></h3>
+<p>Using a <tt>JOIN</tt> clause, the inner join intent from the preceding examples can also be expressed as follows:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Left_Outer_Joins"></a><a name="Left_outer_joins" id="Left_outer_joins">Left Outer Joins</a></h3>
+<p>The query language supports SQL’s notion of left outer join. The following query is an example:</p>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u LEFT OUTER JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+
+<p>Returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "uname": "MargaritaStoddard",
+ "message": " like ccast the 3G is awesome:)"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand product-w the touch-screen is terrible"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand acast its plan is terrible"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " dislike x-phone its touch-screen is horrible"
+}, {
+ "uname": "MargaritaStoddard",
+ "message": " can't stand acast the network is horrible:("
+}, {
+ "uname": "IsbelDull",
+ "message": " like product-y the plan is amazing"
+}, {
+ "uname": "IsbelDull",
+ "message": " like product-z its platform is mind-blowing"
+}, {
+ "uname": "EmoryUnk"
+} ]
+</pre></div></div>
+
+<p>For non-matching left-side tuples, the query language produces <tt>MISSING</tt> values for the right-side binding variables; that is why the last object in the above result doesn’t have a <tt>message</tt> field. Note that this is slightly different from standard SQL, which instead would fill in <tt>NULL</tt> values for the right-side fields. The reason for this difference is that, for non-matches in its join results, the query language views fields from the right-side as being “not there” (a.k.a. <tt>MISSING</tt>) instead of as being “there but unknown” (i.e., <tt>NULL</tt>).</p>
+<p>The left-outer join query can also be expressed using <tt>LEFT OUTER UNNEST</tt>:</p>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u
+LEFT OUTER UNNEST (
+ SELECT VALUE message
+ FROM GleambookMessages message
+ WHERE message.authorId = u.id
+ ) m;
+</pre></div></div>
+
+<p>In general, SQL-style join queries can also be expressed by <tt>UNNEST</tt> clauses and left outer join queries can be expressed by <tt>LEFT OUTER UNNESTs</tt>.</p></div>
+<div class="section">
+<h3><a name="Variable_scope_in_JOIN_clauses"></a><a name="Join_variable_scope" id="Join_variable_scope">Variable scope in JOIN clauses</a></h3>
+<p>Variables defined by <tt>JOIN</tt> subclauses are not visible to other subclauses in the same <tt>FROM</tt> clause. This also applies to the <tt>FROM</tt> variable that starts the <tt>JOIN</tt> subclause.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT * FROM GleambookUsers u
+JOIN (SELECT VALUE m
+ FROM GleambookMessages m
+ WHERE m.authorId = u.id) m
+ON u.id = m.authorId;
+</pre></div></div>
+
+<p>The variable <tt>u</tt> defined by the <tt>FROM</tt> clause is not visible inside the <tt>JOIN</tt> subclause, so this query returns no results.</p></div></div></div></div>
+<div class="section">
+<h2><a name="GROUP_BY_Clauses"></a><a name="Group_By_clauses" id="Group_By_clauses">GROUP BY Clauses</a></h2>
+<p>The <tt>GROUP BY</tt> clause generalizes standard SQL’s grouping and aggregation semantics, but it also retains backward compatibility with the standard (relational) SQL <tt>GROUP BY</tt> and aggregation features.</p>
+<div class="section">
+<h3><a name="Group_variables" id="Group_variables">Group variables</a></h3>
+<p>In a <tt>GROUP BY</tt> clause, in addition to the binding variable(s) defined for the grouping key(s), the query language allows a user to define a <i>group variable</i> by using the clause’s <tt>GROUP AS</tt> extension to denote the resulting group. After grouping, then, the query’s in-scope variables include the grouping key’s binding variables as well as this group variable which will be bound to one collection value for each group. This per-group collection (i.e., multiset) value will be a set of nested objects in which each field of the object is the result of a renamed variable defined in parentheses following the group variable’s name. The <tt>GROUP AS</tt> syntax is as follows:</p>
+
+<div>
+<div>
+<pre class="source"><GROUP> <AS> Variable ("(" VariableReference <AS> Identifier ("," VariableReference <AS> Identifier )* ")")?
+</pre></div></div>
+
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookMessages message
+GROUP BY message.authorId AS uid GROUP AS msgs(message AS msg);
+</pre></div></div>
+
+<p>This first example query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "msgs": [
+ {
+ "msg": {
+ "senderLocation": [
+ 38.97,
+ 77.49
+ ],
+ "inResponseTo": 1,
+ "messageId": 11,
+ "authorId": 1,
+ "message": " can't stand acast its plan is terrible"
+ }
+ },
+ {
+ "msg": {
+ "senderLocation": [
+ 41.66,
+ 80.87
+ ],
+ "inResponseTo": 4,
+ "messageId": 2,
+ "authorId": 1,
+ "message": " dislike x-phone its touch-screen is horrible"
+ }
+ },
+ {
+ "msg": {
+ "senderLocation": [
+ 37.73,
+ 97.04
+ ],
+ "inResponseTo": 2,
+ "messageId": 4,
+ "authorId": 1,
+ "message": " can't stand acast the network is horrible:("
+ }
+ },
+ {
+ "msg": {
+ "senderLocation": [
+ 40.33,
+ 80.87
+ ],
+ "inResponseTo": 11,
+ "messageId": 8,
+ "authorId": 1,
+ "message": " like ccast the 3G is awesome:)"
+ }
+ },
+ {
+ "msg": {
+ "senderLocation": [
+ 42.5,
+ 70.01
+ ],
+ "inResponseTo": 12,
+ "messageId": 10,
+ "authorId": 1,
+ "message": " can't stand product-w the touch-screen is terrible"
+ }
+ }
+ ],
+ "uid": 1
+}, {
+ "msgs": [
+ {
+ "msg": {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ }
+ },
+ {
+ "msg": {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ }
+ }
+ ],
+ "uid": 2
+} ]
+</pre></div></div>
+
+<p>As we can see from the above query result, each group in the example query’s output has an associated group variable value called <tt>msgs</tt> that appears in the <tt>SELECT *</tt>’s result. This variable contains a collection of objects associated with the group; each of the group’s <tt>message</tt> values appears in the <tt>msg</tt> field of the objects in the <tt>msgs</tt> collection.</p>
+<p>The group variable in the query language makes more complex, composable, nested subqueries over a group possible, which is important given the language’s more complex data model (relative to SQL). As a simple example of this, as we really just want the messages associated with each user, we might wish to avoid the “extra wrapping” of each message as the <tt>msg</tt> field of an object. (That wrapping is useful in more complex cases, but is essentially just in the way here.) We can use a subquery in the <tt>SELECT</tt> clause to tunnel through the extra nesting and produce the desired result.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid, (SELECT VALUE g.msg FROM g) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId AS uid
+GROUP AS g(gbm as msg);
+</pre></div></div>
+
+<p>This variant of the example query returns:</p>
+
+<div>
+<div>
+<pre class="source"> [ {
+ "msgs": [
+ {
+ "senderLocation": [
+ 38.97,
+ 77.49
+ ],
+ "inResponseTo": 1,
+ "messageId": 11,
+ "authorId": 1,
+ "message": " can't stand acast its plan is terrible"
+ },
+ {
+ "senderLocation": [
+ 41.66,
+ 80.87
+ ],
+ "inResponseTo": 4,
+ "messageId": 2,
+ "authorId": 1,
+ "message": " dislike x-phone its touch-screen is horrible"
+ },
+ {
+ "senderLocation": [
+ 37.73,
+ 97.04
+ ],
+ "inResponseTo": 2,
+ "messageId": 4,
+ "authorId": 1,
+ "message": " can't stand acast the network is horrible:("
+ },
+ {
+ "senderLocation": [
+ 40.33,
+ 80.87
+ ],
+ "inResponseTo": 11,
+ "messageId": 8,
+ "authorId": 1,
+ "message": " like ccast the 3G is awesome:)"
+ },
+ {
+ "senderLocation": [
+ 42.5,
+ 70.01
+ ],
+ "inResponseTo": 12,
+ "messageId": 10,
+ "authorId": 1,
+ "message": " can't stand product-w the touch-screen is terrible"
+ }
+ ],
+ "uid": 1
+ }, {
+ "msgs": [
+ {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ },
+ {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ }
+ ],
+ "uid": 2
+ } ]
+</pre></div></div>
+
+<p>The next example shows a more interesting case involving the use of a subquery in the <tt>SELECT</tt> list. Here the subquery further processes the groups. There is no renaming in the declaration of the group variable <tt>g</tt> such that <tt>g</tt> only has one field <tt>gbm</tt> which comes from the <tt>FROM</tt> clause.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid,
+ (SELECT VALUE g.gbm
+ FROM g
+ WHERE g.gbm.message LIKE '% like%'
+ ORDER BY g.gbm.messageId
+ LIMIT 2) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId AS uid
+GROUP AS g;
+</pre></div></div>
+
+<p>This example query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "msgs": [
+ {
+ "senderLocation": [
+ 40.33,
+ 80.87
+ ],
+ "inResponseTo": 11,
+ "messageId": 8,
+ "authorId": 1,
+ "message": " like ccast the 3G is awesome:)"
+ }
+ ],
+ "uid": 1
+}, {
+ "msgs": [
+ {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ },
+ {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ }
+ ],
+ "uid": 2
+} ]
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Implicit_Grouping_Key_Variables"></a><a name="Implicit_group_key_variables" id="Implicit_group_key_variables">Implicit Grouping Key Variables</a></h3>
+<p>In the query language syntax, providing named binding variables for <tt>GROUP BY</tt> key expressions is optional. If a grouping key is missing a user-provided binding variable, the underlying compiler will generate one. Automatic grouping key variable naming falls into three cases, much like the treatment of unnamed projections:</p>
+<ul>
+
+<li>If the grouping key expression is a variable reference expression, the generated variable gets the same name as the referred variable;</li>
+<li>If the grouping key expression is a field access expression, the generated variable gets the same name as the last identifier in the expression;</li>
+<li>For all other cases, the compiler generates a unique variable (but the user query is unable to refer to this generated variable).</li>
+</ul>
+<p>The next example illustrates a query that doesn’t provide binding variables for its grouping key expressions.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT authorId,
+ (SELECT VALUE g.gbm
+ FROM g
+ WHERE g.gbm.message LIKE '% like%'
+ ORDER BY g.gbm.messageId
+ LIMIT 2) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId
+GROUP AS g;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source"> [ {
+ "msgs": [
+ {
+ "senderLocation": [
+ 40.33,
+ 80.87
+ ],
+ "inResponseTo": 11,
+ "messageId": 8,
+ "authorId": 1,
+ "message": " like ccast the 3G is awesome:)"
+ }
+ ],
+ "authorId": 1
+}, {
+ "msgs": [
+ {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ },
+ {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ }
+ ],
+ "authorId": 2
+} ]
+</pre></div></div>
+
+<p>Based on the three variable generation rules, the generated variable for the grouping key expression <tt>message.authorId</tt> is <tt>authorId</tt> (which is how it is referred to in the example’s <tt>SELECT</tt> clause).</p></div></div></div>
+<div class="section">
+<h3><a name="Implicit_Group_Variables"></a><a name="Implicit_group_variables" id="Implicit_group_variables">Implicit Group Variables</a></h3>
+<p>The group variable itself is also optional in the <tt>GROUP BY</tt> syntax. If a user’s query does not declare the name and structure of the group variable using <tt>GROUP AS</tt>, the query compiler will generate a unique group variable whose fields include all of the binding variables defined in the <tt>FROM</tt> clause of the current enclosing <tt>SELECT</tt> statement. In this case the user’s query will not be able to refer to the generated group variable, but is able to call SQL-92 aggregation functions as in SQL-92.</p></div>
+<div class="section">
+<h3><a name="Aggregation_Functions"></a><a name="Aggregation_functions" id="Aggregation_functions">Aggregation Functions</a></h3>
+<p>In the traditional SQL, which doesn’t support nested data, grouping always also involves the use of aggregation to compute properties of the groups (for example, the average number of messages per user rather than the actual set of messages per user). Each aggregation function in the query language takes a collection (for example, the group of messages) as its input and produces a scalar value as its output. These aggregation functions, being truly functional in nature (unlike in SQL), can be used anywhere in a query where an expression is allowed. The following table catalogs the built-in aggregation functions of the query language and also indicates how each one handles <tt>NULL</tt>/<tt>MISSING</tt> values in the input collection or a completely empty input collection:</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Function </th>
+<th> NULL </th>
+<th> MISSING </th>
+<th> Empty Collection </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> STRICT_COUNT </td>
+<td> counted </td>
+<td> counted </td>
+<td> 0 </td></tr>
+<tr class="a">
+<td> STRICT_SUM </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> STRICT_MAX </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> STRICT_MIN </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> STRICT_AVG </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> STRICT_STDDEV_SAMP </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> STRICT_STDDEV_POP </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> STRICT_VAR_SAMP </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> STRICT_VAR_POP </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> STRICT_SKEWNESS </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> STRICT_KURTOSIS </td>
+<td> returns NULL </td>
+<td> returns NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_COUNT </td>
+<td> not counted </td>
+<td> not counted </td>
+<td> 0 </td></tr>
+<tr class="b">
+<td> ARRAY_SUM </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_MAX </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> ARRAY_MIN </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_AVG </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> ARRAY_STDDEV_SAMP </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_STDDEV_POP </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> ARRAY_VAR_SAMP </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_VAR_POP </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="b">
+<td> ARRAY_SKEWNESS </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+<tr class="a">
+<td> ARRAY_KURTOSIS </td>
+<td> ignores NULL </td>
+<td> ignores NULL </td>
+<td> returns NULL </td></tr>
+</tbody>
+</table>
+<p>Notice that the query language offers two versions for each of the aggregate functions listed above. For each function, the STRICT version handles <tt>UNKNOWN</tt> values in a semantically strict fashion, where unknown values in the input result in unknown values in the output; and the ARRAY version handles them in the ad hoc “just ignore the unknown values” fashion that the SQL standard chose to adopt.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">ARRAY_AVG(
+ (
+ SELECT VALUE ARRAY_COUNT(friendIds) FROM GleambookUsers
+ )
+);
+</pre></div></div>
+
+<p>This example returns:</p>
+
+<div>
+<div>
+<pre class="source">3.3333333333333335
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid AS uid, ARRAY_COUNT(grp) AS msgCnt
+FROM GleambookMessages message
+GROUP BY message.authorId AS uid
+GROUP AS grp(message AS msg);
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "uid": 1,
+ "msgCnt": 5
+}, {
+ "uid": 2,
+ "msgCnt": 2
+} ]
+</pre></div></div>
+
+<p>Notice how the query forms groups where each group involves a message author and their messages. (SQL cannot do this because the grouped intermediate result is non-1NF in nature.) The query then uses the collection aggregate function ARRAY_COUNT to get the cardinality of each group of messages.</p>
+<p>Each aggregation function in the query language supports the DISTINCT modifier that removes duplicate values from the input collection.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">ARRAY_SUM(DISTINCT [1, 1, 2, 2, 3])
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">6
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="SQL-92_Aggregation_Functions"></a><a name="SQL-92_aggregation_functions" id="SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a></h3>
+<p>For compatibility with the traditional SQL aggregation functions, the query language also offers SQL-92’s aggregation function symbols (<tt>COUNT</tt>, <tt>SUM</tt>, <tt>MAX</tt>, <tt>MIN</tt>, <tt>AVG</tt>, <tt>ARRAY_AGG</tt>, <tt>STDDEV_SAMP</tt>, <tt>STDDEV_POP</tt>, <tt>VAR_SAMP</tt>, <tt>VAR_POP</tt>) as supported syntactic sugar. The query compiler rewrites queries that utilize these function symbols into queries that only use the collection aggregate functions of the query language. The following example uses the SQL-92 syntax approach to compute a result that is identical to that of the more explicit example above:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid, COUNT(*) AS msgCnt
+FROM GleambookMessages msg
+GROUP BY msg.authorId AS uid;
+</pre></div></div>
+
+<p>It is important to realize that <tt>COUNT</tt> is actually <b>not</b> a built-in aggregation function. Rather, the <tt>COUNT</tt> query above is using a special “sugared” function symbol that the query compiler will rewrite as follows:</p>
+
+<div>
+<div>
+<pre class="source">SELECT uid AS uid, ARRAY_COUNT( (SELECT VALUE 1 FROM `$1` AS g) ) AS msgCnt
+FROM GleambookMessages msg
+GROUP BY msg.authorId AS uid
+GROUP AS `$1`(msg AS msg);
+</pre></div></div>
+
+<p>The same sort of rewritings apply to the function symbols <tt>SUM</tt>, <tt>MAX</tt>, <tt>MIN</tt>, <tt>AVG</tt>, <tt>ARRAY_AGG</tt>,<tt>STDDEV_SAMP</tt>, <tt>STDDEV_POP</tt>, <tt>VAR_SAMP</tt>, and <tt>VAR_POP</tt>. In contrast to the collection aggregate functions of the query language, these special SQL-92 function symbols can only be used in the same way they are in standard SQL (i.e., with the same restrictions).</p>
+<p>The DISTINCT modifier is also supported for these aggregate functions.</p>
+<p>The following table shows the SQL-92 functions supported by the query language, their aliases where available, and their corresponding built-in functions.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> SQL-92 Function </th>
+<th> Aliases </th>
+<th> Corresponding Built-in Function </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> COUNT </td>
+<td> </td>
+<td> ARRAY_COUNT </td></tr>
+<tr class="a">
+<td> SUM </td>
+<td> </td>
+<td> ARRAY_SUM </td></tr>
+<tr class="b">
+<td> MAX </td>
+<td> </td>
+<td> ARRAY_MAX </td></tr>
+<tr class="a">
+<td> MIN </td>
+<td> </td>
+<td> ARRAY_MIN </td></tr>
+<tr class="b">
+<td> AVG </td>
+<td> </td>
+<td> ARRAY_AVG </td></tr>
+<tr class="a">
+<td> ARRAY_AGG </td>
+<td> </td>
+<td> (none) </td></tr>
+<tr class="b">
+<td> STDDEV_SAMP </td>
+<td> STDDEV </td>
+<td> ARRAY_STDDEV_SAMP </td></tr>
+<tr class="a">
+<td> STDDEV_POP </td>
+<td> </td>
+<td> ARRAY_STDDEV_POP </td></tr>
+<tr class="b">
+<td> VAR_SAMP </td>
+<td> VARIANCE, VARIANCE_SAMP </td>
+<td> ARRAY_VAR_SAMP </td></tr>
+<tr class="a">
+<td> VAR_POP </td>
+<td> VARIANCE_POP </td>
+<td> ARRAY_VAR_POP </td></tr>
+</tbody>
+</table>
+<p>Note that the <tt>ARRAY_AGG</tt> function symbol is rewritten simply to return the result of the generated subquery, without applying any built-in function.</p>
+<p>SQL aggregate function calls optionally support a FILTER subclause.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid, COUNT(*) FILTER (WHERE msg.message LIKE "%awesome%") AS msgCnt
+FROM GleambookMessages msg
+GROUP BY msg.authorId AS uid;
+</pre></div></div>
+
+<p>The query compiler rewrites this query to use the built-in aggregate as follows:</p>
+
+<div>
+<div>
+<pre class="source">SELECT uid AS uid, ARRAY_COUNT( (SELECT VALUE 1 FROM `$1` AS g WHERE g.msg.message LIKE "%awesome%") ) AS msgCnt
+FROM GleambookMessages msg
+GROUP BY msg.authorId AS uid
+GROUP AS `$1`(msg AS msg);
+</pre></div></div>
+
+<p>Note that the FILTER subclause is not supported for built-in aggregate function calls.</p></div></div></div>
+<div class="section">
+<h3><a name="SQL-92_Compliant_GROUP_BY_Aggregations"></a><a name="SQL-92_compliant_gby" id="SQL-92_compliant_gby">SQL-92 Compliant GROUP BY Aggregations</a></h3>
+<p>The query language provides full support for SQL-92 <tt>GROUP BY</tt> aggregation queries. The following query is such an example:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT msg.authorId, COUNT(*)
+FROM GleambookMessages msg
+GROUP BY msg.authorId;
+</pre></div></div>
+
+<p>This query outputs:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "authorId": 1,
+ "$1": 5
+}, {
+ "authorId": 2,
+ "$1": 2
+} ]
+</pre></div></div>
+
+<p>In principle, a <tt>msg</tt> reference in the query’s <tt>SELECT</tt> clause would be “sugarized” as a collection (as described in <a href="#Implicit_group_variables">Implicit Group Variables</a>). However, since the SELECT expression <tt>msg.authorId</tt> is syntactically identical to a GROUP BY key expression, it will be internally replaced by the generated group key variable. The following is the equivalent rewritten query that will be generated by the compiler for the query above:</p>
+
+<div>
+<div>
+<pre class="source">SELECT authorId AS authorId, ARRAY_COUNT( (SELECT g.msg FROM `$1` AS g) )
+FROM GleambookMessages msg
+GROUP BY msg.authorId AS authorId
+GROUP AS `$1`(msg AS msg);
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Column_Aliases"></a><a name="Column_aliases" id="Column_aliases">Column Aliases</a></h3>
+<p>The query language also allows column aliases to be used as <tt>ORDER BY</tt> keys.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT msg.authorId AS aid, COUNT(*)
+FROM GleambookMessages msg
+GROUP BY msg.authorId;
+ORDER BY aid;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "$1": 5,
+ "aid": 1
+}, {
+ "$1": 2,
+ "aid": 2
+} ]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="WHERE_Clauses_and_HAVING_Clauses"></a><a name="Where_having_clauses" id="Where_having_clauses">WHERE Clauses and HAVING Clauses</a></h2>
+<p>Both <tt>WHERE</tt> clauses and <tt>HAVING</tt> clauses are used to filter input data based on a condition expression. Only tuples for which the condition expression evaluates to <tt>TRUE</tt> are propagated. Note that if the condition expression evaluates to <tt>NULL</tt> or <tt>MISSING</tt> the input tuple will be discarded.</p></div>
+<div class="section">
+<h2><a name="ORDER_BY_Clauses"></a><a name="Order_By_clauses" id="Order_By_clauses">ORDER BY Clauses</a></h2>
+<p>The <tt>ORDER BY</tt> clause is used to globally sort data in either ascending order (i.e., <tt>ASC</tt>) or descending order (i.e., <tt>DESC</tt>). During ordering, <tt>MISSING</tt> and <tt>NULL</tt> are treated as being smaller than any other value if they are encountered in the ordering key(s). <tt>MISSING</tt> is treated as smaller than <tt>NULL</tt> if both occur in the data being sorted. The ordering of values of a given type is consistent with its type’s <= ordering; the ordering of values across types is implementation-defined but stable. The following example returns all <tt>GleambookUsers</tt> in descending order by their number of friends.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source"> SELECT VALUE user
+ FROM GleambookUsers AS user
+ ORDER BY ARRAY_COUNT(user.friendIds) DESC;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source"> [ {
+ "userSince": "2012-08-20T10:10:00.000Z",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "gender": "F",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "alias": "Margarita",
+ "id": 1,
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "end-date": "2010-01-26",
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17"
+ }
+ ]
+ }, {
+ "userSince": "2012-07-10T10:10:00.000Z",
+ "friendIds": [
+ 1,
+ 5,
+ 8,
+ 9
+ ],
+ "name": "EmoryUnk",
+ "alias": "Emory",
+ "id": 3,
+ "employment": [
+ {
+ "organizationName": "geomedia",
+ "endDate": "2010-01-26",
+ "startDate": "2010-06-17"
+ }
+ ]
+ }, {
+ "userSince": "2011-01-22T10:10:00.000Z",
+ "friendIds": [
+ 1,
+ 4
+ ],
+ "name": "IsbelDull",
+ "nickname": "Izzy",
+ "alias": "Isbel",
+ "id": 2,
+ "employment": [
+ {
+ "organizationName": "Hexviafind",
+ "startDate": "2010-04-27"
+ }
+ ]
+ } ]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="LIMIT_Clauses"></a><a name="Limit_clauses" id="Limit_clauses">LIMIT Clauses</a></h2>
+<p>The <tt>LIMIT</tt> clause is used to limit the result set to a specified constant size. The use of the <tt>LIMIT</tt> clause is illustrated in the next example.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source"> SELECT VALUE user
+ FROM GleambookUsers AS user
+ ORDER BY len(user.friendIds) DESC
+ LIMIT 1;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source"> [ {
+ "userSince": "2012-08-20T10:10:00.000Z",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "gender": "F",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "alias": "Margarita",
+ "id": 1,
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "end-date": "2010-01-26",
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17"
+ }
+ ]
+ } ]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="WITH_Clauses"></a><a name="With_clauses" id="With_clauses">WITH Clauses</a></h2>
+<p>As in standard SQL, <tt>WITH</tt> clauses are available to improve the modularity of a query. The next query shows an example.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">WITH avgFriendCount AS (
+ SELECT VALUE AVG(ARRAY_COUNT(user.friendIds))
+ FROM GleambookUsers AS user
+)[0]
+SELECT VALUE user
+FROM GleambookUsers user
+WHERE ARRAY_COUNT(user.friendIds) > avgFriendCount;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "userSince": "2012-08-20T10:10:00.000Z",
+ "friendIds": [
+ 2,
+ 3,
+ 6,
+ 10
+ ],
+ "gender": "F",
+ "name": "MargaritaStoddard",
+ "nickname": "Mags",
+ "alias": "Margarita",
+ "id": 1,
+ "employment": [
+ {
+ "organizationName": "Codetechno",
+ "start-date": "2006-08-06"
+ },
+ {
+ "end-date": "2010-01-26",
+ "organizationName": "geomedia",
+ "start-date": "2010-06-17"
+ }
+ ]
+}, {
+ "userSince": "2012-07-10T10:10:00.000Z",
+ "friendIds": [
+ 1,
+ 5,
+ 8,
+ 9
+ ],
+ "name": "EmoryUnk",
+ "alias": "Emory",
+ "id": 3,
+ "employment": [
+ {
+ "organizationName": "geomedia",
+ "endDate": "2010-01-26",
+ "startDate": "2010-06-17"
+ }
+ ]
+} ]
+</pre></div></div>
+
+<p>The query is equivalent to the following, more complex, inlined form of the query:</p>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookUsers user
+WHERE ARRAY_COUNT(user.friendIds) >
+ ( SELECT VALUE AVG(ARRAY_COUNT(user.friendIds))
+ FROM GleambookUsers AS user
+ ) [0];
+</pre></div></div>
+
+<p>WITH can be particularly useful when a value needs to be used several times in a query.</p>
+<p>Before proceeding further, notice that both the WITH query and its equivalent inlined variant include the syntax “[0]” – this is due to a noteworthy difference between the query language and SQL-92. In SQL-92, whenever a scalar value is expected and it is being produced by a query expression, the SQL-92 query processor will evaluate the expression, check that there is only one row and column in the result at runtime, and then coerce the one-row/one-column tabular result into a scalar value. A JSON query language, being designed to deal with nested data and schema-less data, should not do this. Collection-valued data is perfectly legal in most contexts, and its data is schema-less, so the query processor rarely knows exactly what to expect where and such automatic conversion would often not be desirable. Thus, in the queries above, the use of “[0]” extracts the first (i.e., 0th) element of an array-valued query expression’s result; this is needed above, even though the result is an array of one element, to extract the only element in the singleton array and obtain the desired scalar for the comparison.</p></div></div></div></div>
+<div class="section">
+<h2><a name="LET_Clauses"></a><a name="Let_clauses" id="Let_clauses">LET Clauses</a></h2>
+<p>Similar to <tt>WITH</tt> clauses, <tt>LET</tt> clauses can be useful when a (complex) expression is used several times within a query, allowing it to be written once to make the query more concise. The next query shows an example.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, messages AS messages
+FROM GleambookUsers u
+LET messages = (SELECT VALUE m
+ FROM GleambookMessages m
+ WHERE m.authorId = u.id)
+WHERE EXISTS messages;
+</pre></div></div>
+
+<p>This query lists <tt>GleambookUsers</tt> that have posted <tt>GleambookMessages</tt> and shows all authored messages for each listed user. It returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "uname": "MargaritaStoddard",
+ "messages": [
+ {
+ "senderLocation": [
+ 38.97,
+ 77.49
+ ],
+ "inResponseTo": 1,
+ "messageId": 11,
+ "authorId": 1,
+ "message": " can't stand acast its plan is terrible"
+ },
+ {
+ "senderLocation": [
+ 41.66,
+ 80.87
+ ],
+ "inResponseTo": 4,
+ "messageId": 2,
+ "authorId": 1,
+ "message": " dislike x-phone its touch-screen is horrible"
+ },
+ {
+ "senderLocation": [
+ 37.73,
+ 97.04
+ ],
+ "inResponseTo": 2,
+ "messageId": 4,
+ "authorId": 1,
+ "message": " can't stand acast the network is horrible:("
+ },
+ {
+ "senderLocation": [
+ 40.33,
+ 80.87
+ ],
+ "inResponseTo": 11,
+ "messageId": 8,
+ "authorId": 1,
+ "message": " like ccast the 3G is awesome:)"
+ },
+ {
+ "senderLocation": [
+ 42.5,
+ 70.01
+ ],
+ "inResponseTo": 12,
+ "messageId": 10,
+ "authorId": 1,
+ "message": " can't stand product-w the touch-screen is terrible"
+ }
+ ]
+}, {
+ "uname": "IsbelDull",
+ "messages": [
+ {
+ "senderLocation": [
+ 31.5,
+ 75.56
+ ],
+ "inResponseTo": 1,
+ "messageId": 6,
+ "authorId": 2,
+ "message": " like product-z its platform is mind-blowing"
+ },
+ {
+ "senderLocation": [
+ 48.09,
+ 81.01
+ ],
+ "inResponseTo": 4,
+ "messageId": 3,
+ "authorId": 2,
+ "message": " like product-y the plan is amazing"
+ }
+ ]
+} ]
+</pre></div></div>
+
+<p>This query is equivalent to the following query that does not use the <tt>LET</tt> clause:</p>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname, ( SELECT VALUE m
+ FROM GleambookMessages m
+ WHERE m.authorId = u.id
+ ) AS messages
+FROM GleambookUsers u
+WHERE EXISTS ( SELECT VALUE m
+ FROM GleambookMessages m
+ WHERE m.authorId = u.id
+ );
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="UNION_ALL"></a><a name="Union_all" id="Union_all">UNION ALL</a></h2>
+<p>UNION ALL can be used to combine two input arrays or multisets into one. As in SQL, there is no ordering guarantee on the contents of the output stream. However, unlike SQL, the query language does not constrain what the data looks like on the input streams; in particular, it allows heterogeneity on the input and output streams. A type error will be raised if one of the inputs is not a collection. The following odd but legal query is an example:</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT u.name AS uname
+FROM GleambookUsers u
+WHERE u.id = 2
+ UNION ALL
+SELECT VALUE m.message
+FROM GleambookMessages m
+WHERE authorId=2;
+</pre></div></div>
+
+<p>This query returns:</p>
+
+<div>
+<div>
+<pre class="source">[
+ " like product-z its platform is mind-blowing"
+ , {
+ "uname": "IsbelDull"
+}, " like product-y the plan is amazing"
+ ]
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="OVER_Clauses"></a><a name="Over_clauses" id="Over_clauses">OVER Clauses</a></h2>
+<p>All window functions must have an OVER clause to define the window partitions, the order of tuples within those partitions, and the extent of the window frame. Some window functions take additional window options, which are specified by modifiers before the OVER clause.</p>
+<p>The query language has a dedicated set of window functions. Aggregate functions can also be used as window functions, when they are used with an OVER clause.</p>
+<div class="section">
+<h3><a name="Window_Function_Call"></a><a name="Window_function_call" id="Window_function_call">Window Function Call</a></h3>
+
+<div>
+<div>
+<pre class="source">WindowFunctionCall ::= WindowFunctionType "(" WindowFunctionArguments ")"
+(WindowFunctionOptions)? <OVER> (Variable <AS>)? "(" WindowDefinition ")"
+</pre></div></div>
+
+<div class="section">
+<h4><a name="Window_Function_Type"></a><a name="Window_function_type" id="Window_function_type">Window Function Type</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowFunctionType ::= AggregateFunction | WindowFunction
+</pre></div></div>
+
+<p>Refer to the <a href="builtins.html#AggregateFunctions">Aggregate Functions</a> section for a list of aggregate functions.</p>
+<p>Refer to the <a href="builtins.html#WindowFunctions">Window Functions</a> section for a list of window functions.</p></div>
+<div class="section">
+<h4><a name="Window_Function_Arguments"></a><a name="Window_function_arguments" id="Window_function_arguments">Window Function Arguments</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowFunctionArguments ::= ( (<DISTINCT>)? Expression |
+(Expression ("," Expression ("," Expression)? )? )? )
+</pre></div></div>
+
+<p>Refer to the <a href="builtins.html#AggregateFunctions">Aggregate Functions</a> section or the <a href="builtins.html#WindowFunctions">Window Functions</a> section for details of the arguments for individual functions.</p></div></div>
+<div class="section">
+<h3><a name="Window_Function_Options"></a><a name="Window_function_options" id="Window_function_options">Window Function Options</a></h3>
+
+<div>
+<div>
+<pre class="source">WindowFunctionOptions ::= (NthValFrom)? (NullsTreatment)?
+</pre></div></div>
+
+<p>Window function options cannot be used with <a href="builtins.html#AggregateFunctions">aggregate functions</a>.</p>
+<p>Window function options can only be used with some <a href="builtins.html#WindowFunctions">window functions</a>, as described below.</p>
+<div class="section">
+<h4><a name="Nth_Val_From"></a><a name="Nth_val_from" id="Nth_val_from">Nth Val From</a></h4>
+
+<div>
+<div>
+<pre class="source">NthValFrom ::= <FROM> ( <FIRST> | <LAST> )
+</pre></div></div>
+
+<p>The <b>nth val from</b> modifier determines whether the computation begins at the first or last tuple in the window.</p>
+<p>This modifier can only be used with the <tt>nth_value()</tt> function.</p>
+<p>This modifier is optional. If omitted, the default setting is <tt>FROM FIRST</tt>.</p></div>
+<div class="section">
+<h4><a name="Nulls_Treatment"></a><a name="Nulls_treatment" id="Nulls_treatment">Nulls Treatment</a></h4>
+
+<div>
+<div>
+<pre class="source">NullsTreatment ::= ( <RESPECT> | <IGNORE> ) <NULLS>
+</pre></div></div>
+
+<p>The <b>nulls treatment</b> modifier determines whether NULL values are included in the computation, or ignored. MISSING values are treated the same way as NULL values.</p>
+<p>This modifier can only be used with the <tt>first_value()</tt>, <tt>last_value()</tt>, <tt>nth_value()</tt>, <tt>lag()</tt>, and <tt>lead()</tt> functions.</p>
+<p>This modifier is optional. If omitted, the default setting is <tt>RESPECT NULLS</tt>.</p></div></div>
+<div class="section">
+<h3><a name="Window_Frame_Variable"></a><a name="Window_frame_variable" id="Window_frame_variable">Window Frame Variable</a></h3>
+<p>The AS keyword enables you to specify an alias for the window frame contents. It introduces a variable which will be bound to the contents of the frame. When using a built-in <a href="builtins.html#AggregateFunctions">aggregate function</a> as a window function, the function’s argument must be a subquery which refers to this alias, for example:</p>
+
+<div>
+<div>
+<pre class="source">SELECT ARRAY_COUNT(DISTINCT (FROM alias SELECT VALUE alias.src.field))
+OVER alias AS (PARTITION BY … ORDER BY …)
+FROM source AS src
+</pre></div></div>
+
+<p>The alias is not necessary when using a <a href="builtins.html#WindowFunctions">window function</a>, or when using a standard SQL aggregate function with the OVER clause.</p>
+<div class="section">
+<h4><a name="Standard_SQL_Aggregate_Functions_with_the_OVER_Clause"></a><a name="SQL-92_over_clause" id="SQL-92_over_clause">Standard SQL Aggregate Functions with the OVER Clause</a></h4>
+<p>A standard SQL aggregate function with an OVER clause is rewritten by the query compiler using a built-in aggregate function over a frame variable. For example, the following query with the <tt>sum()</tt> function:</p>
+
+<div>
+<div>
+<pre class="source">SELECT SUM(field) OVER (PARTITION BY … ORDER BY …)
+FROM source AS src
+</pre></div></div>
+
+<p>Is rewritten as the following query using the <tt>array_sum()</tt> function:</p>
+
+<div>
+<div>
+<pre class="source">SELECT ARRAY_SUM( (SELECT VALUE alias.src.field FROM alias) )
+ OVER alias AS (PARTITION BY … ORDER BY …)
+FROM source AS src
+</pre></div></div>
+
+<p>This is similar to the way that standard SQL aggregate functions are rewritten as built-in aggregate functions in the presence of the GROUP BY clause.</p></div></div>
+<div class="section">
+<h3><a name="Window_Definition"></a><a name="Window_definition" id="Window_definition">Window Definition</a></h3>
+
+<div>
+<div>
+<pre class="source">WindowDefinition ::= (WindowPartitionClause)? (WindowOrderClause
+(WindowFrameClause (WindowFrameExclusion)? )? )?
+</pre></div></div>
+
+<p>The <b>window definition</b> specifies the partitioning, ordering, and framing for window functions.</p>
+<div class="section">
+<h4><a name="Window_Partition_Clause"></a><a name="Window_partition_clause" id="Window_partition_clause">Window Partition Clause</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowPartitionClause ::= <PARTITION> <BY> Expression ("," Expression)*
+</pre></div></div>
+
+<p>The <b>window partition clause</b> divides the tuples into logical partitions using one or more expressions.</p>
+<p>This clause may be used with any <a href="builtins.html#WindowFunctions">window function</a>, or any <a href="builtins.html#AggregateFunctions">aggregate function</a> used as a window function.</p>
+<p>This clause is optional. If omitted, all tuples are united in a single partition.</p></div>
+<div class="section">
+<h4><a name="Window_Order_Clause"></a><a name="Window_order_clause" id="Window_order_clause">Window Order Clause</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowOrderClause ::= <ORDER> <BY> OrderingTerm ("," OrderingTerm)*
+</pre></div></div>
+
+<p>The <b>window order clause</b> determines how tuples are ordered within each partition. The window function works on tuples in the order specified by this clause.</p>
+<p>This clause may be used with any <a href="builtins.html#WindowFunctions">window function</a>, or any <a href="builtins.html#AggregateFunctions">aggregate function</a> used as a window function.</p>
+<p>This clause is optional. If omitted, all tuples are considered peers, i.e. their order is tied. When tuples in the window partition are tied, each window function behaves differently.</p>
+<ul>
+
+<li>
+
+<p>The <tt>row_number()</tt> function returns a distinct number for each tuple. If tuples are tied, the results may be unpredictable.</p>
+</li>
+<li>
+
+<p>The <tt>rank()</tt>, <tt>dense_rank()</tt>, <tt>percent_rank()</tt>, and <tt>cume_dist()</tt> functions return the same result for each tuple.</p>
+</li>
+<li>
+
+<p>For other functions, if the <a href="#Window_frame_clause">window frame</a> is defined by <tt>ROWS</tt>, the results may be unpredictable. If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, the results are same for each tuple.</p>
+</li>
+</ul>
+<p>This clause may have multiple <a href="#Ordering_term">ordering terms</a>. To reduce the number of ties, add additional <a href="#Ordering_term">ordering terms</a>.</p>
+<div class="section">
+<h5><a name="Note"></a>Note</h5>
+<p>This clause does not guarantee the overall order of the query results. To guarantee the order of the final results, use the query ORDER BY clause.</p></div></div>
+<div class="section">
+<h4><a name="Ordering_Term"></a><a name="Ordering_term" id="Ordering_term">Ordering Term</a></h4>
+
+<div>
+<div>
+<pre class="source">OrderingTerm ::= Expression ( <ASC> | <DESC> )?
+</pre></div></div>
+
+<p>The <b>ordering term</b> specifies an ordering expression and collation.</p>
+<p>This clause has the same syntax and semantics as the ordering term for queries. Refer to the <a href="#Order_By_clauses">ORDER BY Clauses</a> section for details.</p></div>
+<div class="section">
+<h4><a name="Window_Frame_Clause"></a><a name="Window_frame_clause" id="Window_frame_clause">Window Frame Clause</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowFrameClause ::= ( <ROWS> | <RANGE> | <GROUPS> ) WindowFrameExtent
+</pre></div></div>
+
+<p>The <b>window frame clause</b> defines the window frame.</p>
+<p>This clause can be used with all <a href="builtins.html#AggregateFunctions">aggregate functions</a> and some <a href="builtins.html#WindowFunctions">window functions</a> — refer to the descriptions of individual functions for more details.</p>
+<p>This clause is allowed only when the <a href="#Window_order_clause">window order clause</a> is present.</p>
+<p>This clause is optional.</p>
+<ul>
+
+<li>
+
+<p>If this clause is omitted and there is no <a href="#Window_order_clause">window order clause</a>, the window frame is the entire partition.</p>
+</li>
+<li>
+
+<p>If this clause is omitted but there is a <a href="#Window_order_clause">window order clause</a>, the window frame becomes all tuples in the partition preceding the current tuple and its peers — the same as <tt>RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW</tt>.</p>
+</li>
+</ul>
+<p>The window frame can be defined in the following ways:</p>
+<ul>
+
+<li>
+
+<p><tt>ROWS</tt>: Counts the exact number of tuples within the frame. If window ordering doesn’t result in unique ordering, the function may produce unpredictable results. You can add a unique expression or more window ordering expressions to produce unique ordering.</p>
+</li>
+<li>
+
+<p><tt>RANGE</tt>: Looks for a value offset within the frame. The function produces deterministic results.</p>
+</li>
+<li>
+
+<p><tt>GROUPS</tt>: Counts all groups of tied rows within the frame. The function produces deterministic results.</p>
+</li>
+</ul>
+<div class="section">
+<h5><a name="Note"></a>Note</h5>
+<p>If this clause uses <tt>RANGE</tt> with either <tt>Expression PRECEDING</tt> or <tt>Expression FOLLOWING</tt>, the <a href="#Window_order_clause">window order clause</a> must have only a single ordering term.</p>
+<p>The ordering term expression must evaluate to a number.</p><!--
+The ordering term expression must evaluate to a number, a date, a time, or a
+datetime.
+If the ordering term expression evaluates to a date, a time, or a datetime, the
+expression in `Expression PRECEDING` or `Expression FOLLOWING` must evaluate to
+a duration.
+-->
+
+<p>If these conditions are not met, the window frame will be empty, which means the window function will return its default value: in most cases this is NULL, except for <tt>strict_count()</tt> or <tt>array_count()</tt>, whose default value is 0.</p>
+<p>This restriction does not apply when the window frame uses <tt>ROWS</tt> or <tt>GROUPS</tt>.</p></div>
+<div class="section">
+<h5><a name="Tip"></a>Tip</h5>
+<p>The <tt>RANGE</tt> window frame is commonly used to define window frames based on date or time.</p>
+<p>If you want to use <tt>RANGE</tt> with either <tt>Expression PRECEDING</tt> or <tt>Expression FOLLOWING</tt>, and you want to use an ordering expression based on date or time, the expression in <tt>Expression PRECEDING</tt> or <tt>Expression FOLLOWING</tt> must use a data type that can be added to the ordering expression.</p></div></div>
+<div class="section">
+<h4><a name="Window_Frame_Extent"></a><a name="Window_frame_extent" id="Window_frame_extent">Window Frame Extent</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowFrameExtent ::= ( ( <UNBOUNDED> | Expression ) <PRECEDING> | <CURRENT> <ROW> ) |
+<BETWEEN>
+ ( <UNBOUNDED> <PRECEDING> | <CURRENT> <ROW> | Expression ( <PRECEDING> | <FOLLOWING> ) )
+<AND>
+ ( <UNBOUNDED> <FOLLOWING> | <CURRENT> <ROW> | Expression ( <PRECEDING> | <FOLLOWING> ) )
+</pre></div></div>
+
+<p>The <b>window frame extent clause</b> specifies the start point and end point of the window frame. The expression before <tt>AND</tt> is the start point and the expression after <tt>AND</tt> is the end point. If <tt>BETWEEN</tt> is omitted, you can only specify the start point; the end point becomes <tt>CURRENT ROW</tt>.</p>
+<p>The window frame end point can’t be before the start point. If this clause violates this restriction explicitly, an error will result. If it violates this restriction implicitly, the window frame will be empty, which means the window function will return its default value: in most cases this is NULL, except for <tt>strict_count()</tt> or <tt>array_count()</tt>, whose default value is 0.</p>
+<p>Window frame extents that result in an explicit violation are:</p>
+<ul>
+
+<li>
+
+<p><tt>BETWEEN CURRENT ROW AND Expression PRECEDING</tt></p>
+</li>
+<li>
+
+<p><tt>BETWEEN Expression FOLLOWING AND Expression PRECEDING</tt></p>
+</li>
+<li>
+
+<p><tt>BETWEEN Expression FOLLOWING AND CURRENT ROW</tt></p>
+</li>
+</ul>
+<p>Window frame extents that result in an implicit violation are:</p>
+<ul>
+
+<li>
+
+<p><tt>BETWEEN UNBOUNDED PRECEDING AND Expression PRECEDING</tt> — if <tt>Expression</tt> is too high, some tuples may generate an empty window frame.</p>
+</li>
+<li>
+
+<p><tt>BETWEEN Expression PRECEDING AND Expression PRECEDING</tt> — if the second <tt>Expression</tt> is greater than or equal to the first <tt>Expression</tt>, all result sets will generate an empty window frame.</p>
+</li>
+<li>
+
+<p><tt>BETWEEN Expression FOLLOWING AND Expression FOLLOWING</tt> — if the first <tt>Expression</tt> is greater than or equal to the second <tt>Expression</tt>, all result sets will generate an empty window frame.</p>
+</li>
+<li>
+
+<p><tt>BETWEEN Expression FOLLOWING AND UNBOUNDED FOLLOWING</tt> — if <tt>Expression</tt> is too high, some tuples may generate an empty window frame.</p>
+</li>
+<li>
+
+<p>If the <a href="#Window_frame_exclusion">window frame exclusion clause</a> is present, any window frame specification may result in empty window frame.</p>
+</li>
+</ul>
+<p>The <tt>Expression</tt> must be a positive constant or an expression that evaluates as a positive number. For <tt>ROWS</tt> or <tt>GROUPS</tt>, the <tt>Expression</tt> must be an integer.</p></div>
+<div class="section">
+<h4><a name="Window_Frame_Exclusion"></a><a name="Window_frame_exclusion" id="Window_frame_exclusion">Window Frame Exclusion</a></h4>
+
+<div>
+<div>
+<pre class="source">WindowFrameExclusion ::= <EXCLUDE> ( <CURRENT> <ROW> | <GROUP> | <TIES> |
+<NO> <OTHERS> )
+</pre></div></div>
+
+<p>The <b>window frame exclusion clause</b> enables you to exclude specified tuples from the window frame.</p>
+<p>This clause can be used with all <a href="builtins.html#AggregateFunctions">aggregate functions</a> and some <a href="builtins.html#WindowFunctions">window functions</a> — refer to the descriptions of individual functions for more details.</p>
+<p>This clause is allowed only when the <a href="#Window_frame_clause">window frame clause</a> is present.</p>
+<p>This clause is optional. If this clause is omitted, the default is no exclusion — the same as <tt>EXCLUDE NO OTHERS</tt>.</p>
+<ul>
+
+<li>
+
+<p><tt>EXCLUDE CURRENT ROW</tt>: If the current tuple is still part of the window frame, it is removed from the window frame.</p>
+</li>
+<li>
+
+<p><tt>EXCLUDE GROUP</tt>: The current tuple and any peers of the current tuple are removed from the window frame.</p>
+</li>
+<li>
+
+<p><tt>EXCLUDE TIES</tt>: Any peers of the current tuple, but not the current tuple itself, are removed from the window frame.</p>
+</li>
+<li>
+
+<p><tt>EXCLUDE NO OTHERS</tt>: No additional tuples are removed from the window frame.</p>
+</li>
+</ul>
+<p>If the current tuple is already removed from the window frame, then it remains removed from the window frame.</p></div></div></div>
+<div class="section">
+<h2><a name="Subqueries" id="Subqueries">Subqueries</a></h2>
+<p>In the query language, an arbitrary subquery can appear anywhere that an expression can appear. Unlike SQL-92, as was just alluded to, the subqueries in a SELECT list or a boolean predicate need not return singleton, single-column relations. Instead, they may return arbitrary collections. For example, the following query is a variant of the prior group-by query examples; it retrieves an array of up to two “dislike” messages per user.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT uid,
+ (SELECT VALUE m.msg
+ FROM msgs m
+ WHERE m.msg.message LIKE '%dislike%'
+ ORDER BY m.msg.messageId
+ LIMIT 2) AS msgs
+FROM GleambookMessages message
+GROUP BY message.authorId AS uid GROUP AS msgs(message AS msg);
+</pre></div></div>
+
+<p>For our sample data set, this query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ {
+ "msgs": [
+ {
+ "senderLocation": [
+ 41.66,
+ 80.87
+ ],
+ "inResponseTo": 4,
+ "messageId": 2,
+ "authorId": 1,
+ "message": " dislike x-phone its touch-screen is horrible"
+ }
+ ],
+ "uid": 1
+}, {
+ "msgs": [
+
+ ],
+ "uid": 2
+} ]
+</pre></div></div>
+
+<p>Note that a subquery, like a top-level <tt>SELECT</tt> statment, always returns a collection – regardless of where within a query the subquery occurs – and again, its result is never automatically cast into a scalar.</p></div></div></div></div>
+<div class="section">
+<h2><a name="Differences_from_SQL-92"></a><a name="Vs_SQL-92" id="Vs_SQL-92">Differences from SQL-92</a></h2>
+<p>The query language offers the following additional features beyond SQL-92:</p>
+<ul>
+
+<li>Fully composable and functional: A subquery can iterate over any intermediate collection and can appear anywhere in a query.</li>
+<li>Schema-free: The query language does not assume the existence of a static schema for any data that it processes.</li>
+<li>Correlated FROM terms: A right-side FROM term expression can refer to variables defined by FROM terms on its left.</li>
+<li>Powerful GROUP BY: In addition to a set of aggregate functions as in standard SQL, the groups created by the <tt>GROUP BY</tt> clause are directly usable in nested queries and/or to obtain nested results.</li>
+<li>Generalized SELECT clause: A SELECT clause can return any type of collection, while in SQL-92, a <tt>SELECT</tt> clause has to return a (homogeneous) collection of objects.</li>
+</ul>
+<p>The following matrix is a quick “SQL-92 compatibility cheat sheet” for the query language.</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> Feature </th>
+<th> The query language </th>
+<th> SQL-92 </th>
+<th> Why different? </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> SELECT * </td>
+<td> Returns nested objects </td>
+<td> Returns flattened concatenated objects </td>
+<td> Nested collections are 1st class citizens </td></tr>
+<tr class="a">
+<td> SELECT list </td>
+<td> order not preserved </td>
+<td> order preserved </td>
+<td> Fields in a JSON object are not ordered </td></tr>
+<tr class="b">
+<td> Subquery </td>
+<td> Returns a collection </td>
+<td> The returned collection is cast into a scalar value if the subquery appears in a SELECT list or on one side of a comparison or as input to a function </td>
+<td> Nested collections are 1st class citizens </td></tr>
+<tr class="a">
+<td> LEFT OUTER JOIN </td>
+<td> Fills in <tt>MISSING</tt>(s) for non-matches </td>
+<td> Fills in <tt>NULL</tt>(s) for non-matches </td>
+<td> “Absence” is more appropriate than “unknown” here </td></tr>
+<tr class="b">
+<td> UNION ALL </td>
+<td> Allows heterogeneous inputs and output </td>
+<td> Input streams must be UNION-compatible and output field names are drawn from the first input stream </td>
+<td> Heterogenity and nested collections are common </td></tr>
+<tr class="a">
+<td> IN constant_expr </td>
+<td> The constant expression has to be an array or multiset, i.e., [..,..,…] </td>
+<td> The constant collection can be represented as comma-separated items in a paren pair </td>
+<td> Nested collections are 1st class citizens </td></tr>
+<tr class="b">
+<td> String literal </td>
+<td> Double quotes or single quotes </td>
+<td> Single quotes only </td>
+<td> Double quoted strings are pervasive </td></tr>
+<tr class="a">
+<td> Delimited identifiers </td>
+<td> Backticks </td>
+<td> Double quotes </td>
+<td> Double quoted strings are pervasive </td></tr>
+</tbody>
+</table>
+<p>The following SQL-92 features are not implemented yet. However, the query language does not conflict with these features:</p>
+<ul>
+
+<li>CROSS JOIN, NATURAL JOIN, UNION JOIN</li>
+<li>RIGHT and FULL OUTER JOIN</li>
+<li>INTERSECT, EXCEPT, UNION with set semantics</li>
+<li>CAST expression</li>
+<li>COALESCE expression</li>
+<li>ALL and SOME predicates for linking to subqueries</li>
+<li>UNIQUE predicate (tests a collection for duplicates)</li>
+<li>MATCH predicate (tests for referential integrity)</li>
+<li>Row and Table constructors</li>
+<li>Preserved order for expressions in a SELECT list</li>
+</ul><!--
+ ! 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.
+ !-->
+
+<h1><a name="Errors" id="Errors">4. Errors</a></h1><!--
+ ! 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.
+ !-->
+
+<p>A query can potentially result in one of the following errors:</p>
+<ul>
+
+<li>syntax error,</li>
+<li>identifier resolution error,</li>
+<li>type error,</li>
+<li>resource error.</li>
+</ul>
+<p>If the query processor runs into any error, it will terminate the ongoing processing of the query and immediately return an error message to the client.</p></div>
+<div class="section">
+<h2><a name="Syntax_Errors"></a><a name="Syntax_errors" id="Syntax_errors">Syntax Errors</a></h2>
+<p>A valid query must satisfy the grammar rules of the query language. Otherwise, a syntax error will be raised.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+GleambookUsers user
+</pre></div></div>
+
+<p>Since the query misses a <tt>FROM</tt> keyword before the dataset <tt>GleambookUsers</tt>, we will get a syntax error as follows:</p>
+
+<div>
+<div>
+<pre class="source">Syntax error: In line 2 >>GleambookUsers user;<< Encountered <IDENTIFIER> \"GleambookUsers\" at column 1.
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookUsers user
+WHERE type="advertiser";
+</pre></div></div>
+
+<p>Since “type” is a reserved keyword in the query parser, we will get a syntax error as follows:</p>
+
+<div>
+<div>
+<pre class="source">Error: Syntax error: In line 3 >>WHERE type="advertiser";<< Encountered 'type' "type" at column 7.
+==> WHERE type="advertiser";
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Identifier_Resolution_Errors"></a><a name="Identifier_resolution_errors" id="Identifier_resolution_errors">Identifier Resolution Errors</a></h2>
+<p>Referring to an undefined identifier can cause an error if the identifier cannot be successfully resolved as a valid field access.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT *
+FROM GleambookUser user;
+</pre></div></div>
+
+<p>If we have a typo as above in “GleambookUsers” that misses the dataset name’s ending “s”, we will get an identifier resolution error as follows:</p>
+
+<div>
+<div>
+<pre class="source">Error: Cannot find dataset GleambookUser in dataverse Default nor an alias with name GleambookUser!
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SELECT name, message
+FROM GleambookUsers u JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+
+<p>If the compiler cannot figure out how to resolve an unqualified field name, which will occur if there is more than one variable in scope (e.g., <tt>GleambookUsers u</tt> and <tt>GleambookMessages m</tt> as above), we will get an identifier resolution error as follows:</p>
+
+<div>
+<div>
+<pre class="source">Error: Cannot resolve ambiguous alias reference for undefined identifier name
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Type_Errors"></a><a name="Type_errors" id="Type_errors">Type Errors</a></h2>
+<p>The query compiler does type checks based on its available type information. In addition, the query runtime also reports type errors if a data model instance it processes does not satisfy the type requirement.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">abs("123");
+</pre></div></div>
+
+<p>Since function <tt>abs</tt> can only process numeric input values, we will get a type error as follows:</p>
+
+<div>
+<div>
+<pre class="source">Error: Type mismatch: function abs expects its 1st input parameter to be of type tinyint, smallint, integer, bigint, float or double, but the actual input type is string
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Resource_Errors"></a><a name="Resource_errors" id="Resource_errors">Resource Errors</a></h2>
+<p>A query can potentially exhaust system resources, such as the number of open files and disk spaces. For instance, the following two resource errors could be potentially be seen when running the system:</p>
+
+<div>
+<div>
+<pre class="source">Error: no space left on device
+Error: too many open files
+</pre></div></div>
+
+<p>The “no space left on device” issue usually can be fixed by cleaning up disk spaces and reserving more disk spaces for the system. The “too many open files” issue usually can be fixed by a system administrator, following the instructions <a class="externalLink" href="https://easyengine.io/tutorials/linux/increase-open-files-limit/">here</a>.</p><!--
+ ! 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.
+ !-->
+
+<h1><a name="DDL_and_DML_statements" id="DDL_and_DML_statements">5. DDL and DML statements</a></h1>
+
+<div>
+<div>
+<pre class="source">Statement ::= ( ( SingleStatement )? ( ";" )+ )* <EOF>
+SingleStatement ::= DatabaseDeclaration
+ | FunctionDeclaration
+ | CreateStatement
+ | DropStatement
+ | LoadStatement
+ | SetStatement
+ | InsertStatement
+ | DeleteStatement
+ | Query
+</pre></div></div>
+
+<p>In addition to queries, an implementation of the query language needs to support statements for data definition and manipulation purposes as well as controlling the context to be used in evaluating query expressions. This section details the DDL and DML statements supported in the query language as realized today in Apache AsterixDB.</p><!--
+ ! 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.
+ !-->
+</div>
+<div class="section">
+<h2><a name="Lifecycle_Management_Statements"></a><a name="Lifecycle_management_statements" id="Lifecycle_management_statements">Lifecycle Management Statements</a></h2>
+
+<div>
+<div>
+<pre class="source">CreateStatement ::= "CREATE" ( DatabaseSpecification
+ | TypeSpecification
+ | DatasetSpecification
+ | IndexSpecification
+ | SynonymSpecification
+ | FunctionSpecification )
+
+QualifiedName ::= Identifier ( "." Identifier )?
+DoubleQualifiedName ::= Identifier "." Identifier ( "." Identifier )?
+</pre></div></div>
+
+<p>The CREATE statement is used for creating dataverses as well as other persistent artifacts in a dataverse. It can be used to create new dataverses, datatypes, datasets, indexes, and user-defined query functions.</p>
+<div class="section">
+<h3><a name="Dataverses" id="Dataverses"> Dataverses</a></h3>
+
+<div>
+<div>
+<pre class="source">DatabaseSpecification ::= "DATAVERSE" Identifier IfNotExists
+</pre></div></div>
+
+<p>The CREATE DATAVERSE statement is used to create new dataverses. To ease the authoring of reusable query scripts, an optional IF NOT EXISTS clause is included to allow creation to be requested either unconditionally or only if the dataverse does not already exist. If this clause is absent, an error is returned if a dataverse with the indicated name already exists.</p>
+<p>The following example creates a new dataverse named TinySocial if one does not already exist.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CREATE DATAVERSE TinySocial IF NOT EXISTS;
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Types" id="Types"> Types</a></h3>
+
+<div>
+<div>
+<pre class="source">TypeSpecification ::= "TYPE" FunctionOrTypeName IfNotExists "AS" ObjectTypeDef
+FunctionOrTypeName ::= QualifiedName
+IfNotExists ::= ( <IF> <NOT> <EXISTS> )?
+TypeExpr ::= ObjectTypeDef | TypeReference | ArrayTypeDef | MultisetTypeDef
+ObjectTypeDef ::= ( <CLOSED> | <OPEN> )? "{" ( ObjectField ( "," ObjectField )* )? "}"
+ObjectField ::= Identifier ":" ( TypeExpr ) ( "?" )?
+NestedField ::= Identifier ( "." Identifier )*
+IndexField ::= NestedField ( ":" TypeReference )?
+TypeReference ::= Identifier
+ArrayTypeDef ::= "[" ( TypeExpr ) "]"
+MultisetTypeDef ::= "{{" ( TypeExpr ) "}}"
+</pre></div></div>
+
+<p>The CREATE TYPE statement is used to create a new named datatype. This type can then be used to create stored collections or utilized when defining one or more other datatypes. Much more information about the data model is available in the <a href="../datamodel.html">data model reference guide</a>. A new type can be a object type, a renaming of another type, an array type, or a multiset type. A object type can be defined as being either open or closed. Instances of a closed object type are not permitted to contain fields other than those specified in the create type statement. Instances of an open object type may carry additional fields, and open is the default for new types if neither option is specified.</p>
+<p>The following example creates a new object type called GleambookUser type. Since it is defined as (defaulting to) being an open type, instances will be permitted to contain more than what is specified in the type definition. The first four fields are essentially traditional typed name/value pairs (much like SQL fields). The friendIds field is a multiset of integers. The employment field is an array of instances of another named object type, EmploymentType.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CREATE TYPE GleambookUserType AS {
+ id: int,
+ alias: string,
+ name: string,
+ userSince: datetime,
+ friendIds: {{ int }},
+ employment: [ EmploymentType ]
+};
+</pre></div></div>
+
+<p>The next example creates a new object type, closed this time, called MyUserTupleType. Instances of this closed type will not be permitted to have extra fields, although the alias field is marked as optional and may thus be NULL or MISSING in legal instances of the type. Note that the type of the id field in the example is UUID. This field type can be used if you want to have this field be an autogenerated-PK field. (Refer to the Datasets section later for more details on such fields.)</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CREATE TYPE MyUserTupleType AS CLOSED {
+ id: uuid,
+ alias: string?,
+ name: string
+};
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Datasets" id="Datasets"> Datasets</a></h3>
+
+<div>
+<div>
+<pre class="source">DatasetSpecification ::= ( <INTERNAL> )? <DATASET> QualifiedName "(" QualifiedName ")" IfNotExists
+ PrimaryKey ( <ON> Identifier )? ( <HINTS> Properties )?
+ ( "USING" "COMPACTION" "POLICY" CompactionPolicy ( Configuration )? )?
+ ( <WITH> <FILTER> <ON> Identifier )?
+ |
+ <EXTERNAL> <DATASET> QualifiedName "(" QualifiedName ")" IfNotExists <USING> AdapterName
+ Configuration ( <HINTS> Properties )?
+ ( <USING> <COMPACTION> <POLICY> CompactionPolicy ( Configuration )? )?
+AdapterName ::= Identifier
+Configuration ::= "(" ( KeyValuePair ( "," KeyValuePair )* )? ")"
+KeyValuePair ::= "(" StringLiteral "=" StringLiteral ")"
+Properties ::= ( "(" Property ( "," Property )* ")" )?
+Property ::= Identifier "=" ( StringLiteral | IntegerLiteral )
+FunctionSignature ::= FunctionOrTypeName "@" IntegerLiteral
+PrimaryKey ::= <PRIMARY> <KEY> NestedField ( "," NestedField )* ( <AUTOGENERATED> )?
+CompactionPolicy ::= Identifier
+</pre></div></div>
+
+<p>The CREATE DATASET statement is used to create a new dataset. Datasets are named, multisets of object type instances; they are where data lives persistently and are the usual targets for queries. Datasets are typed, and the system ensures that their contents conform to their type definitions. An Internal dataset (the default kind) is a dataset whose content lives within and is managed by the system. It is required to have a specified unique primary key field which uniquely identifies the contained objects. (The primary key is also used in secondary indexes to identify the indexed primary data objects.)</p>
+<p>Internal datasets contain several advanced options that can be specified when appropriate. One such option is that random primary key (UUID) values can be auto-generated by declaring the field to be UUID and putting “AUTOGENERATED” after the “PRIMARY KEY” identifier. In this case, unlike other non-optional fields, a value for the auto-generated PK field should not be provided at insertion time by the user since each object’s primary key field value will be auto-generated by the system.</p>
+<p>Another advanced option, when creating an Internal dataset, is to specify the merge policy to control which of the underlying LSM storage components to be merged. (The system supports Log-Structured Merge tree based physical storage for Internal datasets.) Currently the system supports four different component merging policies that can be chosen per dataset: no-merge, constant, prefix, and correlated-prefix. The no-merge policy simply never merges disk components. The constant policy merges disk components when the number of components reaches a constant number k that can be configured by the user. The prefix policy relies on both component sizes and the number of components to decide which components to merge. It works by first trying to identify the smallest ordered (oldest to newest) sequence of components such that the sequence does not contain a single component that exceeds some threshold size M and that either the sum of the component’s sizes exceeds M or the number of components in the sequence exceeds another threshold C. If such a sequence exists, the components in the sequence are merged together to form a single component. Finally, the correlated-prefix policy is similar to the prefix policy, but it delegates the decision of merging the disk components of all the indexes in a dataset to the primary index. When the correlated-prefix policy decides that the primary index needs to be merged (using the same decision criteria as for the prefix policy), then it will issue successive merge requests on behalf of all other indexes associated with the same dataset. The system’s default policy is the prefix policy except when there is a filter on a dataset, where the preferred policy for filters is the correlated-prefix.</p>
+<p>Another advanced option shown in the syntax above, related to performance and mentioned above, is that a <b>filter</b> can optionally be created on a field to further optimize range queries with predicates on the filter’s field. Filters allow some range queries to avoid searching all LSM components when the query conditions match the filter. (Refer to <a href="../filters.html">Filter-Based LSM Index Acceleration</a> for more information about filters.)</p>
+<p>An External dataset, in contrast to an Internal dataset, has data stored outside of the system’s control. Files living in HDFS or in the local filesystem(s) of a cluster’s nodes are currently supported. External dataset support allows queries to treat foreign data as though it were stored in the system, making it possible to query “legacy” file data (for example, Hive data) without having to physically import it. When defining an External dataset, an appropriate adapter type must be selected for the desired external data. (See the <a href="../externaldata.html">Guide to External Data</a> for more information on the available adapters.)</p>
+<p>The following example creates an Internal dataset for storing FacefookUserType objects. It specifies that their id field is their primary key.</p>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INTERNAL DATASET GleambookUsers(GleambookUserType) PRIMARY KEY id;
+</pre></div></div>
+
+<p>The next example creates another Internal dataset (the default kind when no dataset kind is specified) for storing MyUserTupleType objects. It specifies that the id field should be used as the primary key for the dataset. It also specifies that the id field is an auto-generated field, meaning that a randomly generated UUID value should be assigned to each incoming object by the system. (A user should therefore not attempt to provide a value for this field.) Note that the id field’s declared type must be UUID in this case.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE DATASET MyUsers(MyUserTupleType) PRIMARY KEY id AUTOGENERATED;
+</pre></div></div>
+
+<p>The next example creates an External dataset for querying LineItemType objects. The choice of the <tt>hdfs</tt> adapter means that this dataset’s data actually resides in HDFS. The example CREATE statement also provides parameters used by the hdfs adapter: the URL and path needed to locate the data in HDFS and a description of the data format.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE EXTERNAL DATASET LineItem(LineItemType) USING hdfs (
+ ("hdfs"="hdfs://HOST:PORT"),
+ ("path"="HDFS_PATH"),
+ ("input-format"="text-input-format"),
+ ("format"="delimited-text"),
+ ("delimiter"="|"));
+</pre></div></div>
+</div></div>
+<div class="section">
+<h3><a name="Indices" id="Indices">Indices</a></h3>
+
+<div>
+<div>
+<pre class="source">IndexSpecification ::= (<INDEX> Identifier IfNotExists <ON> QualifiedName
+ "(" ( IndexField ) ( "," IndexField )* ")" (<TYPE> IndexType)? (<ENFORCED>)?)
+ |
+ <PRIMARY> <INDEX> Identifier? IfNotExists <ON> QualifiedName (<TYPE> <BTREE>)?
+IndexType ::= <BTREE> | <RTREE> | <KEYWORD> | <NGRAM> "(" IntegerLiteral ")"
+</pre></div></div>
+
+<p>The CREATE INDEX statement creates a secondary index on one or more fields of a specified dataset. Supported index types include <tt>BTREE</tt> for totally ordered datatypes, <tt>RTREE</tt> for spatial data, and <tt>KEYWORD</tt> and <tt>NGRAM</tt> for textual (string) data. An index can be created on a nested field (or fields) by providing a valid path expression as an index field identifier.</p>
+<p>An indexed field is not required to be part of the datatype associated with a dataset if the dataset’s datatype is declared as open <b>and</b> if the field’s type is provided along with its name and if the <tt>ENFORCED</tt> keyword is specified at the end of the index definition. <tt>ENFORCING</tt> an open field introduces a check that makes sure that the actual type of the indexed field (if the optional field exists in the object) always matches this specified (open) field type.</p>
+<p>The following example creates a btree index called gbAuthorIdx on the authorId field of the GleambookMessages dataset. This index can be useful for accelerating exact-match queries, range search queries, and joins involving the author-id field.</p>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX gbAuthorIdx ON GleambookMessages(authorId) TYPE BTREE;
+</pre></div></div>
+
+<p>The following example creates an open btree index called gbSendTimeIdx on the (non-declared) <tt>sendTime</tt> field of the GleambookMessages dataset having datetime type. This index can be useful for accelerating exact-match queries, range search queries, and joins involving the <tt>sendTime</tt> field. The index is enforced so that records that do not have the <tt>sendTime</tt> field or have a mismatched type on the field cannot be inserted into the dataset.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX gbSendTimeIdx ON GleambookMessages(sendTime: datetime?) TYPE BTREE ENFORCED;
+</pre></div></div>
+
+<p>The following example creates an open btree index called gbReadTimeIdx on the (non-declared) <tt>readTime</tt> field of the GleambookMessages dataset having datetime type. This index can be useful for accelerating exact-match queries, range search queries, and joins involving the <tt>readTime</tt> field. The index is not enforced so that records that do not have the <tt>readTime</tt> field or have a mismatched type on the field can still be inserted into the dataset.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX gbReadTimeIdx ON GleambookMessages(readTime: datetime?);
+</pre></div></div>
+
+<p>The following example creates a btree index called crpUserScrNameIdx on screenName, a nested field residing within a object-valued user field in the ChirpMessages dataset. This index can be useful for accelerating exact-match queries, range search queries, and joins involving the nested screenName field. Such nested fields must be singular, i.e., one cannot index through (or on) an array-valued field.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX crpUserScrNameIdx ON ChirpMessages(user.screenName) TYPE BTREE;
+</pre></div></div>
+
+<p>The following example creates an rtree index called gbSenderLocIdx on the sender-location field of the GleambookMessages dataset. This index can be useful for accelerating queries that use the <a href="functions.html#spatial-intersect"><tt>spatial-intersect</tt> function</a> in a predicate involving the sender-location field.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX gbSenderLocIndex ON GleambookMessages("sender-location") TYPE RTREE;
+</pre></div></div>
+
+<p>The following example creates a 3-gram index called fbUserIdx on the name field of the GleambookUsers dataset. This index can be used to accelerate some similarity or substring maching queries on the name field. For details refer to the document on <a href="similarity.html#NGram_Index">similarity queries</a>.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX fbUserIdx ON GleambookUsers(name) TYPE NGRAM(3);
+</pre></div></div>
+
+<p>The following example creates a keyword index called fbMessageIdx on the message field of the GleambookMessages dataset. This keyword index can be used to optimize queries with token-based similarity predicates on the message field. For details refer to the document on <a href="similarity.html#Keyword_Index">similarity queries</a>.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE INDEX fbMessageIdx ON GleambookMessages(message) TYPE KEYWORD;
+</pre></div></div>
+
+<p>The following example creates a special secondary index which holds only the primary keys. This index is useful for speeding up aggregation queries which involve only primary keys. The name of the index is optional. If the name is not specified, the system will generate one. When the user would like to drop this index, the metadata can be queried to find the system-generated name.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div>
+<div>
+<pre class="source">CREATE PRIMARY INDEX gb_pk_idx ON GleambookMessages;
+</pre></div></div>
+
+<p>An example query that can be accelerated using the primary-key index:</p>
+
+<div>
+<div>
+<pre class="source">SELECT COUNT(*) FROM GleambookMessages;
+</pre></div></div>
+
+<p>To look up the the above primary-key index, issue the following query:</p>
+
+<div>
+<div>
+<pre class="source">SELECT VALUE i
+FROM Metadata.`Index` i
+WHERE i.DataverseName = "TinySocial" AND i.DatasetName = "GleambookMessages";
+</pre></div></div>
+
+<p>The query returns:</p>
+
+<div>
+<div>
+<pre class="source">[ { "DataverseName": "TinySocial", "DatasetName": "GleambookMessages", "IndexName": "GleambookMessages", "IndexStructure": "BTREE", "SearchKey": [ [ "messageId" ] ], "IsPrimary": true, "Timestamp": "Wed Nov 07 17:25:11 PST 2018", "PendingOp": 0 }
+, { "DataverseName": "TinySocial", "DatasetName": "GleambookMessages", "IndexName": "gb_pk_idx", "IndexStructure": "BTREE", "SearchKey": [ ], "IsPrimary": false, "Timestamp": "Wed Nov 07 17:25:11 PST 2018", "PendingOp": 0 }
+ ]
+</pre></div></div>
+
+<p>Remember that <tt>CREATE PRIMARY INDEX</tt> creates a secondary index. That is the reason the <tt>IsPrimary</tt> field is false. The primary-key index can be identified by the fact that the <tt>SearchKey</tt> field is empty since it only contains primary key fields.<!--
+! 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.
+!--></p></div></div>
+<div class="section">
+<h3><a name="Functions" id="Functions"> Functions</a></h3>
+<p>The CREATE FUNCTION statement creates a <b>named</b> function that can then be used and reused in queries. The body of a function can be any query expression involving the function’s parameters.</p>
+
+<div>
+<div>
+<pre class="source">FunctionSpecification ::= "FUNCTION" FunctionOrTypeName IfNotExists ParameterList "{" Expression "}"
+</pre></div></div>
+
+<p>The following is an example of a CREATE FUNCTION statement which is similar to our earlier DECLARE FUNCTION example. It differs from that example in that it results in a function that is persistently registered by name in the specified dataverse (the current dataverse being used, if not otherwise specified).</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CREATE FUNCTION friendInfo(userId) {
+ (SELECT u.id, u.name, len(u.friendIds) AS friendCount
+ FROM GleambookUsers u
+ WHERE u.id = userId)[0]
+ };
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="Synonyms" id="Synonyms"> Synonyms</a></h3>
+
+<div>
+<div>
+<pre class="source">SynonymSpecification ::= "SYNONYM" QualifiedName "FOR" QualifiedName IfNotExists
+</pre></div></div>
+
+<p>The CREATE SYNONYM statement creates a synonym for a given dataset. This synonym may be used used instead of the dataset name in SELECT, INSERT, UPSERT, DELETE, and LOAD statements. The target dataset does not need to exist when the synonym is created.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">CREATE DATASET GleambookUsers(GleambookUserType) PRIMARY KEY id;
+
+CREATE SYNONYM GleambookUsersSynonym FOR GleambookUsers;
+
+SELECT * FROM GleambookUsersSynonym;
+</pre></div></div>
+
+<p>More information on how synonyms are resolved can be found in the appendix section on Variable Resolution.</p></div></div></div>
+<div class="section">
+<h3><a name="Removal" id="Removal"> Removal</a></h3>
+
+<div>
+<div>
+<pre class="source">DropStatement ::= "DROP" ( "DATAVERSE" Identifier IfExists
+ | "TYPE" FunctionOrTypeName IfExists
+ | "DATASET" QualifiedName IfExists
+ | "INDEX" DoubleQualifiedName IfExists
+ | "SYNONYM" QualifiedName IfExists
+ | "FUNCTION" FunctionSignature IfExists )
+IfExists ::= ( "IF" "EXISTS" )?
+</pre></div></div>
+
+<p>The DROP statement is the inverse of the CREATE statement. It can be used to drop dataverses, datatypes, datasets, indexes, functions, and synonyms.</p>
+<p>The following examples illustrate some uses of the DROP statement.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">DROP DATASET GleambookUsers IF EXISTS;
+
+DROP INDEX GleambookMessages.gbSenderLocIndex;
+
+DROP TYPE TinySocial2.GleambookUserType;
+
+DROP FUNCTION friendInfo@1;
+
+DROP SYNONYM GleambookUsersSynonym;
+
+DROP DATAVERSE TinySocial;
+</pre></div></div>
+
+<p>When an artifact is dropped, it will be droppped from the current dataverse if none is specified (see the DROP DATASET example above) or from the specified dataverse (see the DROP TYPE example above) if one is specified by fully qualifying the artifact name in the DROP statement. When specifying an index to drop, the index name must be qualified by the dataset that it indexes. When specifying a function to drop, since the query language allows functions to be overloaded by their number of arguments, the identifying name of the function to be dropped must explicitly include that information. (<tt>friendInfo@1</tt> above denotes the 1-argument function named friendInfo in the current dataverse.)</p></div></div></div>
+<div class="section">
+<h3><a name="Load_Statement"></a><a name="Load_statement" id="Load_statement">Load Statement</a></h3>
+
+<div>
+<div>
+<pre class="source">LoadStatement ::= <LOAD> <DATASET> QualifiedName <USING> AdapterName Configuration ( <PRE-SORTED> )?
+</pre></div></div>
+
+<p>The LOAD statement is used to initially populate a dataset via bulk loading of data from an external file. An appropriate adapter must be selected to handle the nature of the desired external data. The LOAD statement accepts the same adapters and the same parameters as discussed earlier for External datasets. (See the <a href="externaldata.html">guide to external data</a> for more information on the available adapters.) If a dataset has an auto-generated primary key field, the file to be imported should not include that field in it.</p>
+<p>The target dataset name may be a synonym introduced by CREATE SYNONYM statement.</p>
+<p>The following example shows how to bulk load the GleambookUsers dataset from an external file containing data that has been prepared in ADM (Asterix Data Model) format.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source"> LOAD DATASET GleambookUsers USING localfs
+ (("path"="127.0.0.1:///Users/bignosqlfan/tinysocialnew/gbu.adm"),("format"="adm"));
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Modification_statements" id="Modification_statements">Modification statements</a></h2>
+<div class="section">
+<h3><a name="INSERTs"></a><a name="Inserts" id="Inserts">INSERTs</a></h3>
+
+<div>
+<div>
+<pre class="source">InsertStatement ::= <INSERT> <INTO> QualifiedName Query
+</pre></div></div>
+
+<p>The INSERT statement is used to insert new data into a dataset. The data to be inserted comes from a query expression. This expression can be as simple as a constant expression, or in general it can be any legal query. In case the dataset has an auto-generated primary key, when performing an INSERT operation, the system allows the user to manually add the auto-generated key field in the INSERT statement, or skip that field and the system will automatically generate it and add it. However, it is important to note that if the a record already exists in the dataset with the auto-generated key provided by the user, then that operation is going to fail. As a general rule, insertion will fail if the dataset already has data with the primary key value(s) being inserted.</p>
+<p>Inserts are processed transactionally by the system. The transactional scope of each insert transaction is the insertion of a single object plus its affiliated secondary index entries (if any). If the query part of an insert returns a single object, then the INSERT statement will be a single, atomic transaction. If the query part returns multiple objects, each object being inserted will be treated as a separate tranaction.</p>
+<p>The target dataset name may be a synonym introduced by CREATE SYNONYM statement.</p>
+<p>The following example illustrates a query-based insertion.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">INSERT INTO UsersCopy (SELECT VALUE user FROM GleambookUsers user)
+</pre></div></div>
+</div></div></div>
+<div class="section">
+<h3><a name="UPSERTs"></a><a name="Upserts" id="Upserts">UPSERTs</a></h3>
+
+<div>
+<div>
+<pre class="source">UpsertStatement ::= <UPSERT> <INTO> QualifiedName Query
+</pre></div></div>
+
+<p>The UPSERT statement syntactically mirrors the INSERT statement discussed above. The difference lies in its semantics, which for UPSERT are “add or replace” instead of the INSERT “add if not present, else error” semantics. Whereas an INSERT can fail if another object already exists with the specified key, the analogous UPSERT will replace the previous object’s value with that of the new object in such cases. Like the INSERT statement, the system allows the user to manually provide the auto-generated key for datasets with an auto-generated key as its primary key. This operation will insert the record if no record with that key already exists, but if a record with the key already exists, then the operation will be converted to a replace/update operation.</p>
+<p>The target dataset name may be a synonym introduced by CREATE SYNONYM statement.</p>
+<p>The following example illustrates a query-based upsert operation.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">UPSERT INTO UsersCopy (SELECT VALUE user FROM GleambookUsers user)
+</pre></div></div>
+
+<p>*Editor’s note: Upserts currently work in AQL but are not yet enabled (at the moment) in the current query language.</p></div></div></div>
+<div class="section">
+<h3><a name="DELETEs"></a><a name="Deletes" id="Deletes">DELETEs</a></h3>
+
+<div>
+<div>
+<pre class="source">DeleteStatement ::= <DELETE> <FROM> QualifiedName ( ( <AS> )? Variable )? ( <WHERE> Expression )?
+</pre></div></div>
+
+<p>The DELETE statement is used to delete data from a target dataset. The data to be deleted is identified by a boolean expression involving the variable bound to the target dataset in the DELETE statement.</p>
+<p>Deletes are processed transactionally by the system. The transactional scope of each delete transaction is the deletion of a single object plus its affiliated secondary index entries (if any). If the boolean expression for a delete identifies a single object, then the DELETE statement itself will be a single, atomic transaction. If the expression identifies multiple objects, then each object deleted will be handled as a separate transaction.</p>
+<p>The target dataset name may be a synonym introduced by CREATE SYNONYM statement.</p>
+<p>The following examples illustrate single-object deletions.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">DELETE FROM GleambookUsers user WHERE user.id = 8;
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">DELETE FROM GleambookUsers WHERE id = 5;
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+
+<h1><a name="Reserved_keywords" id="Reserved_keywords">Appendix 1. Reserved keywords</a></h1><!--
+ ! 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.
+ !-->
+
+<p>All reserved keywords are listed in the following table:</p>
+<table border="0" class="table table-striped">
+<thead>
+
+<tr class="a">
+<th> </th>
+<th> </th>
+<th> </th>
+<th> </th>
+<th> </th>
+<th> </th></tr>
+</thead><tbody>
+
+<tr class="b">
+<td> AND </td>
+<td> ANY </td>
+<td> APPLY </td>
+<td> AS </td>
+<td> ASC </td>
+<td> AT </td></tr>
+<tr class="a">
+<td> AUTOGENERATED </td>
+<td> BETWEEN </td>
+<td> BTREE </td>
+<td> BY </td>
+<td> CASE </td>
+<td> CLOSED </td></tr>
+<tr class="b">
+<td> CREATE </td>
+<td> COMPACTION </td>
+<td> COMPACT </td>
+<td> CONNECT </td>
+<td> CORRELATE </td>
+<td> DATASET </td></tr>
+<tr class="a">
+<td> COLLECTION </td>
+<td> DATAVERSE </td>
+<td> DECLARE </td>
+<td> DEFINITION </td>
+<td> DECLARE </td>
+<td> DEFINITION </td></tr>
+<tr class="b">
+<td> DELETE </td>
+<td> DESC </td>
+<td> DISCONNECT </td>
+<td> DISTINCT </td>
+<td> DROP </td>
+<td> ELEMENT </td></tr>
+<tr class="a">
+<td> ELEMENT </td>
+<td> EXPLAIN </td>
+<td> ELSE </td>
+<td> ENFORCED </td>
+<td> END </td>
+<td> EVERY </td></tr>
+<tr class="b">
+<td> EXCEPT </td>
+<td> EXIST </td>
+<td> EXTERNAL </td>
+<td> FEED </td>
+<td> FILTER </td>
+<td> FLATTEN </td></tr>
+<tr class="a">
+<td> FOR </td>
+<td> FROM </td>
+<td> FULL </td>
+<td> FUNCTION </td>
+<td> GROUP </td>
+<td> HAVING </td></tr>
+<tr class="b">
+<td> HINTS </td>
+<td> IF </td>
+<td> INTO </td>
+<td> IN </td>
+<td> INDEX </td>
+<td> INGESTION </td></tr>
+<tr class="a">
+<td> INNER </td>
+<td> INSERT </td>
+<td> INTERNAL </td>
+<td> INTERSECT </td>
+<td> IS </td>
+<td> JOIN </td></tr>
+<tr class="b">
+<td> KEYWORD </td>
+<td> LEFT </td>
+<td> LETTING </td>
+<td> LET </td>
+<td> LIKE </td>
+<td> LIMIT </td></tr>
+<tr class="a">
+<td> LOAD </td>
+<td> NODEGROUP </td>
+<td> NGRAM </td>
+<td> NOT </td>
+<td> OFFSET </td>
+<td> ON </td></tr>
+<tr class="b">
+<td> OPEN </td>
+<td> OR </td>
+<td> ORDER </td>
+<td> OUTER </td>
+<td> OUTPUT </td>
+<td> OVER </td></tr>
+<tr class="a">
+<td> PATH </td>
+<td> POLICY </td>
+<td> PRE-SORTED </td>
+<td> PRIMARY </td>
+<td> RAW </td>
+<td> REFRESH </td></tr>
+<tr class="b">
+<td> RETURN </td>
+<td> RTREE </td>
+<td> RUN </td>
+<td> SATISFIES </td>
+<td> SECONDARY </td>
+<td> SELECT </td></tr>
+<tr class="a">
+<td> SET </td>
+<td> SOME </td>
+<td> TEMPORARY </td>
+<td> THEN </td>
+<td> TYPE </td>
+<td> UNKNOWN </td></tr>
+<tr class="b">
+<td> UNNEST </td>
+<td> UPDATE </td>
+<td> USE </td>
+<td> USING </td>
+<td> VALUE </td>
+<td> WHEN </td></tr>
+<tr class="a">
+<td> WHERE </td>
+<td> WITH </td>
+<td> WRITE </td>
+<td> </td>
+<td> </td>
+<td> </td></tr>
+</tbody>
+</table><!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Appendix_2._Performance_Tuning"></a><a name="Performance_tuning" id="Performance_tuning">Appendix 2. Performance Tuning</a></h2><!--
+ ! 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.
+ !-->
+
+<p>The SET statement can be used to override some cluster-wide configuration parameters for a specific request:</p>
+
+<div>
+<div>
+<pre class="source">SET <IDENTIFIER> <STRING_LITERAL>
+</pre></div></div>
+
+<p>As parameter identifiers are qualified names (containing a ‘.’) they have to be escaped using backticks (``). Note that changing query parameters will not affect query correctness but only impact performance characteristics, such as response time and throughput.</p></div>
+<div class="section">
+<h2><a name="Parallelism_Parameter"></a><a name="Parallelism_parameter" id="Parallelism_parameter">Parallelism Parameter</a></h2>
+<p>The system can execute each request using multiple cores on multiple machines (a.k.a., partitioned parallelism) in a cluster. A user can manually specify the maximum execution parallelism for a request to scale it up and down using the following parameter:</p>
+<ul>
+
+<li><b>compiler.parallelism</b>: the maximum number of CPU cores can be used to process a query. There are three cases of the value <i>p</i> for compiler.parallelism:
+<ul>
+
+<li>
+
+<p><i>p</i> < 0 or <i>p</i> > the total number of cores in a cluster: the system will use all available cores in the cluster;</p>
+</li>
+<li>
+
+<p><i>p</i> = 0 (the default): the system will use the storage parallelism (the number of partitions of stored datasets) as the maximum parallelism for query processing;</p>
+</li>
+<li>
+
+<p>all other cases: the system will use the user-specified number as the maximum number of CPU cores to use for executing the query.</p>
+</li>
+</ul>
+</li>
+</ul>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SET `compiler.parallelism` "16";
+
+SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+</div></div></div></div>
+<div class="section">
+<h2><a name="Memory_Parameters"></a><a name="Memory_parameters" id="Memory_parameters">Memory Parameters</a></h2>
+<p>In the system, each blocking runtime operator such as join, group-by and order-by works within a fixed memory budget, and can gracefully spill to disks if the memory budget is smaller than the amount of data they have to hold. A user can manually configure the memory budget of those operators within a query. The supported configurable memory parameters are:</p>
+<ul>
+
+<li>
+
+<p><b>compiler.groupmemory</b>: the memory budget that each parallel group-by operator instance can use; 32MB is the default budget.</p>
+</li>
+<li>
+
+<p><b>compiler.sortmemory</b>: the memory budget that each parallel sort operator instance can use; 32MB is the default budget.</p>
+</li>
+<li>
+
+<p><b>compiler.joinmemory</b>: the memory budget that each parallel hash join operator instance can use; 32MB is the default budget.</p>
+</li>
+<li>
+
+<p><b>compiler.windowmemory</b>: the memory budget that each parallel window aggregate operator instance can use; 32MB is the default budget.</p>
+</li>
+</ul>
+<p>For each memory budget value, you can use a 64-bit integer value with a 1024-based binary unit suffix (for example, B, KB, MB, GB). If there is no user-provided suffix, “B” is the default suffix. See the following examples.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SET `compiler.groupmemory` "64MB";
+
+SELECT msg.authorId, COUNT(*)
+FROM GleambookMessages msg
+GROUP BY msg.authorId;
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SET `compiler.sortmemory` "67108864";
+
+SELECT VALUE user
+FROM GleambookUsers AS user
+ORDER BY ARRAY_LENGTH(user.friendIds) DESC;
+</pre></div></div>
+</div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SET `compiler.joinmemory` "132000KB";
+
+SELECT u.name AS uname, m.message AS message
+FROM GleambookUsers u JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Parallel_Sort_Parameter"></a><a name="Parallel_sort_parameter" id="Parallel_sort_parameter">Parallel Sort Parameter</a></h2>
+<p>The following parameter enables you to activate or deactivate full parallel sort for order-by operations.</p>
+<p>When full parallel sort is inactive (<tt>false</tt>), each existing data partition is sorted (in parallel), and then all data partitions are merged into a single node.</p>
+<p>When full parallel sort is active (<tt>true</tt>), the data is first sampled, and then repartitioned so that each partition contains data that is greater than the previous partition. The data in each partition is then sorted (in parallel), but the sorted partitions are not merged into a single node.</p>
+<ul>
+
+<li><b>compiler.sort.parallel</b>: A boolean specifying whether full parallel sort is active (<tt>true</tt>) or inactive (<tt>false</tt>). The default value is <tt>true</tt>.</li>
+</ul>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">SET `compiler.sort.parallel` "true";
+
+SELECT VALUE user
+FROM GleambookUsers AS user
+ORDER BY ARRAY_LENGTH(user.friendIds) DESC;
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Controlling_Index-Only-Plan_Parameter"></a><a name="Index_Only" id="Index_Only">Controlling Index-Only-Plan Parameter</a></h2>
+<p>By default, the system tries to build an index-only plan whenever utilizing a secondary index is possible. For example, if a SELECT or JOIN query can utilize an enforced B+Tree or R-Tree index on a field, the optimizer checks whether a secondary-index search alone can generate the result that the query asks for. It mainly checks two conditions: (1) predicates used in WHERE only uses the primary key field and/or secondary key field and (2) the result does not return any other fields. If these two conditions hold, it builds an index-only plan. Since an index-only plan only searches a secondary-index to answer a query, it is faster than a non-index-only plan that needs to search the primary index. However, this index-only plan can be turned off per query by setting the following parameter.</p>
+<ul>
+
+<li><b>compiler.indexonly</b>: if this is set to false, the index-only-plan will not be applied; the default value is true.</li>
+</ul>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div>
+<div>
+<pre class="source">set `compiler.indexonly` "false";
+
+SELECT m.message AS message
+FROM GleambookMessages m where m.message = " love product-b its shortcut-menu is awesome:)";
+</pre></div></div>
+<!--
+ ! 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.
+ !-->
+</div></div></div></div>
+<div class="section">
+<h2><a name="Appendix_3._Variable_Bindings_and_Name_Resolution"></a><a name="Variable_bindings_and_name_resolution" id="Variable_bindings_and_name_resolution">Appendix 3. Variable Bindings and Name Resolution</a></h2><!--
+ ! 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.
+ !-->
+
+<p>In this Appendix, we’ll look at how variables are bound and how names are resolved. Names can appear in every clause of a query. Sometimes a name consists of just a single identifier, e.g., <tt>region</tt> or <tt>revenue</tt>. More often a name will consist of two identifiers separated by a dot, e.g., <tt>customer.address</tt>. Occasionally a name may have more than two identifiers, e.g., <tt>policy.owner.address.zipcode</tt>. <i>Resolving</i> a name means determining exactly what the (possibly multi-part) name refers to. It is necessary to have well-defined rules for how to resolve a name in cases of ambiguity. (In the absence of schemas, such cases arise more commonly, and also differently, than they do in SQL.)</p>
+<p>The basic job of each clause in a query block is to bind variables. Each clause sees the variables bound by previous clauses and may bind additional variables. Names are always resolved with respect to the variables that are bound (“in scope”) at the place where the name use in question occurs. It is possible that the name resolution process will fail, which may lead to an empty result or an error message.</p>
+<p>One important bit of background: When the system is reading a query and resolving its names, it has a list of all the available dataverses and datasets. As a result, it knows whether <tt>a.b</tt> is a valid name for dataset <tt>b</tt> in dataverse <tt>a</tt>. However, the system does not in general have knowledge of the schemas of the data inside the datasets; remember that this is a much more open world. As a result, in general the system cannot know whether any object in a particular dataset will have a field named <tt>c</tt>. These assumptions affect how errors are handled. If you try to access dataset <tt>a.b</tt> and no dataset by that name exists, you will get an error and your query will not run. However, if you try to access a field <tt>c</tt> in a collection of objects, your query will run and return <tt>missing</tt> for each object that doesn’t have a field named <tt>c</tt> – this is because it’s possible that some object (someday) could have such a field.</p></div>
+<div class="section">
+<h2><a name="Binding_Variables"></a><a name="Binding_variables" id="Binding_variables">Binding Variables</a></h2>
+<p>Variables can be bound in the following ways:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>WITH and LET clauses bind a variable to the result of an expression in a straightforward way</p>
+<p>Examples:</p>
+<p><tt>WITH cheap_parts AS (SELECT partno FROM parts WHERE price < 100)</tt> binds the variable <tt>cheap_parts</tt> to the result of the subquery.</p>
+<p><tt>LET pay = salary + bonus</tt> binds the variable <tt>pay</tt> to the result of evaluating the expression <tt>salary + bonus</tt>.</p>
+</li>
+<li>
+
+<p>FROM, GROUP BY, and SELECT clauses have optional AS subclauses that contain an expression and a name (called an <i>iteration variable</i> in a FROM clause, or an alias in GROUP BY or SELECT.)</p>
+<p>Examples:</p>
+<p><tt>FROM customer AS c, order AS o</tt></p>
+<p><tt>GROUP BY salary + bonus AS total_pay</tt></p>
+<p><tt>SELECT MAX(price) AS highest_price</tt></p>
+<p>An AS subclause always binds the name (as a variable) to the result of the expression (or, in the case of a FROM clause, to the <i>individual members</i> of the collection identified by the expression.)</p>
+<p>It’s always a good practice to use the keyword AS when defining an alias or iteration variable. However, as in SQL, the syntax allows the keyword AS to be omitted. For example, the FROM clause above could have been written like this:</p>
+<p><tt>FROM customer c, order o</tt></p>
+<p>Omitting the keyword AS does not affect the binding of variables. The FROM clause in this example binds variables c and o whether the keyword AS is used or not.</p>
+<p>In certain cases, a variable is automatically bound even if no alias or variable-name is specified. Whenever an expression could have been followed by an AS subclause, if the expression consists of a simple name or a path expression, that expression binds a variable whose name is the same as the simple name or the last step in the path expression. Here are some examples:</p>
+<p><tt>FROM customer, order</tt> binds iteration variables named <tt>customer</tt> and <tt>order</tt></p>
+<p><tt>GROUP BY address.zipcode</tt> binds a variable named <tt>zipcode</tt></p>
+<p><tt>SELECT item[0].price</tt> binds a variable named <tt>price</tt></p>
+<p>Note that a FROM clause iterates over a collection (usually a dataset), binding a variable to each member of the collection in turn. The name of the collection remains in scope, but it is not a variable. For example, consider this FROM clause used in a self-join:</p>
+<p><tt>FROM customer AS c1, customer AS c2</tt></p>
+<p>This FROM clause joins the customer dataset to itself, binding the iteration variables c1 and c2 to objects in the left-hand-side and right-hand-side of the join, respectively. After the FROM clause, c1 and c2 are in scope as variables, and customer remains accessible as a dataset name but not as a variable.</p>
+</li>
+<li>
+
+<p>Special rules for GROUP BY:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>If a GROUP BY clause specifies an expression that has no explicit alias, it binds a pseudo-variable that is lexicographically identical to the expression itself. For example:</p>
+<p><tt>GROUP BY salary + bonus</tt> binds a pseudo-variable named <tt>salary + bonus</tt>.</p>
+<p>This rule allows subsequent clauses to refer to the grouping expression (salary + bonus) even though its constituent variables (salary and bonus) are no longer in scope. For example, the following query is valid:</p>
+
+<div>
+<div>
+<pre class="source">FROM employee
+GROUP BY salary + bonus
+HAVING salary + bonus > 1000
+SELECT salary + bonus, COUNT(*) AS how_many
+</pre></div></div>
+
+<p>While it might have been more elegant to explicitly require an alias in cases like this, the pseudo-variable rule is retained for SQL compatibility. Note that the expression <tt>salary + bonus</tt> is not <i>actually</i> evaluated in the HAVING and SELECT clauses (and could not be since <tt>salary</tt> and <tt>bonus</tt> are no longer individually in scope). Instead, the expression <tt>salary + bonus</tt> is treated as a reference to the pseudo-variable defined in the GROUP BY clause.</p>
+</li>
+<li>
+
+<p>A GROUP BY clause may be followed by a GROUP AS clause that binds a variable to the group. The purpose of this variable is to make the individual objects inside the group visible to subqueries that may need to iterate over them.</p>
+<p>The GROUP AS variable is bound to a multiset of objects. Each object represents one of the members of the group. Since the group may have been formed from a join, each of the member-objects contains a nested object for each variable bound by the nearest FROM clause (and its LET subclause, if any). These nested objects, in turn, contain the actual fields of the group-member. To understand this process, consider the following query fragment:</p>
+
+<div>
+<div>
+<pre class="source">FROM parts AS p, suppliers AS s
+WHERE p.suppno = s.suppno
+GROUP BY p.color GROUP AS g
+</pre></div></div>
+
+<p>Suppose that the objects in <tt>parts</tt> have fields <tt>partno</tt>, <tt>color</tt>, and <tt>suppno</tt>. Suppose that the objects in suppliers have fields <tt>suppno</tt> and <tt>location</tt>.</p>
+<p>Then, for each group formed by the GROUP BY, the variable g will be bound to a multiset with the following structure:</p>
+
+<div>
+<div>
+<pre class="source">[ { "p": { "partno": "p1", "color": "red", "suppno": "s1" },
+ "s": { "suppno": "s1", "location": "Denver" } },
+ { "p": { "partno": "p2", "color": "red", "suppno": "s2" },
+ "s": { "suppno": "s2", "location": "Atlanta" } },
+ ...
+]
+</pre></div></div>
+</li>
+</ol>
+</li>
+</ol></div>
+<div class="section">
+<h2><a name="Scoping" id="Scoping">Scoping</a></h2>
+<p>In general, the variables that are in scope at a particular position are those variables that were bound earlier in the current query block, in outer (enclosing) query blocks, or in a WITH clause at the beginning of the query. More specific rules follow.</p>
+<p>The clauses in a query block are conceptually processed in the following order:</p>
+<ul>
+
+<li>FROM (followed by LET subclause, if any)</li>
+<li>WHERE</li>
+<li>GROUP BY (followed by LET subclause, if any)</li>
+<li>HAVING</li>
+<li>SELECT or SELECT VALUE</li>
+<li>ORDER BY</li>
+<li>OFFSET</li>
+<li>LIMIT</li>
+</ul>
+<p>During processing of each clause, the variables that are in scope are those variables that are bound in the following places:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>In earlier clauses of the same query block (as defined by the ordering given above).</p>
+<p>Example: <tt>FROM orders AS o SELECT o.date</tt> The variable <tt>o</tt> in the SELECT clause is bound, in turn, to each object in the dataset <tt>orders</tt>.</p>
+</li>
+<li>
+
+<p>In outer query blocks in which the current query block is nested. In case of duplication, the innermost binding wins.</p>
+</li>
+<li>
+
+<p>In the WITH clause (if any) at the beginning of the query.</p>
+</li>
+</ol>
+<p>However, in a query block where a GROUP BY clause is present:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>In clauses processed before GROUP BY, scoping rules are the same as though no GROUP BY were present.</p>
+</li>
+<li>
+
+<p>In clauses processed after GROUP BY, the variables bound in the nearest FROM-clause (and its LET subclause, if any) are removed from scope and replaced by the variables bound in the GROUP BY clause (and its LET subclause, if any). However, this replacement does not apply inside the arguments of the five SQL special aggregating functions (MIN, MAX, AVG, SUM, and COUNT). These functions still need to see the individual data items over which they are computing an aggregation. For example, after <tt>FROM employee AS e GROUP BY deptno</tt>, it would not be valid to reference <tt>e.salary</tt>, but <tt>AVG(e.salary)</tt> would be valid.</p>
+</li>
+</ol>
+<p>Special case: In an expression inside a FROM clause, a variable is in scope if it was bound in an earlier expression in the same FROM clause. Example:</p>
+
+<div>
+<div>
+<pre class="source">FROM orders AS o, o.items AS i
+</pre></div></div>
+
+<p>The reason for this special case is to support iteration over nested collections.</p>
+<p>Note that, since the SELECT clause comes <i>after</i> the WHERE and GROUP BY clauses in conceptual processing order, any variables defined in SELECT are not visible in WHERE or GROUP BY. Therefore the following query will not return what might be the expected result (since in the WHERE clause, <tt>pay</tt> will be interpreted as a field in the <tt>emp</tt> object rather than as the computed value <tt>salary + bonus</tt>):</p>
+
+<div>
+<div>
+<pre class="source">SELECT name, salary + bonus AS pay
+FROM emp
+WHERE pay > 1000
+ORDER BY pay
+</pre></div></div>
+
+<p>The likely intent of the query above can be accomplished as follows:</p>
+
+<div>
+<div>
+<pre class="source">FROM emp AS e
+LET pay = e.salary + e.bonus
+WHERE pay > 1000
+SELECT e.name, pay
+ORDER BY pay
+</pre></div></div>
+
+<p>Note that variables defined by <tt>JOIN</tt> subclauses are not visible to other subclauses in the same <tt>FROM</tt> clause. This also applies to the <tt>FROM</tt> variable that starts the <tt>JOIN</tt> subclause.</p></div>
+<div class="section">
+<h2><a name="Resolving_Names"></a><a name="Resolving_names" id="Resolving_names">Resolving Names</a></h2>
+<p>The process of name resolution begins with the leftmost identifier in the name. The rules for resolving the leftmost identifier are:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p><i>In a FROM clause</i>: Names in a FROM clause identify the collections over which the query block will iterate. These collections may be stored datasets or may be the results of nested query blocks. A stored dataset may be in a named dataverse or in the default dataverse. Thus, if the two-part name <tt>a.b</tt> is in a FROM clause, a might represent a dataverse and <tt>b</tt> might represent a dataset in that dataverse. Another example of a two-part name in a FROM clause is <tt>FROM orders AS o, o.items AS i</tt>. In <tt>o.items</tt>, <tt>o</tt> represents an order object bound earlier in the FROM clause, and items represents the items object inside that order.</p>
+<p>The rules for resolving the leftmost identifier in a FROM clause (including a JOIN subclause), or in the expression following IN in a quantified predicate, are as follows:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>If the identifier matches a variable-name that is in scope, it resolves to the binding of that variable. (Note that in the case of a subquery, an in-scope variable might have been bound in an outer query block; this is called a correlated subquery.)</p>
+</li>
+<li>
+
+<p>Otherwise, if the identifier is the first part of a two-part name like <tt>a.b</tt>, the name is treated as <tt>dataverse.dataset</tt>. If the identifier stands alone as a one-part name, it is treated as the name of a dataset in the default dataverse. If the designated dataset exists then the identifier is resolved to that dataset, otherwise if a synonym with given name exists then the identifier is resolved to the target dataset of that synonym (potentially recursively if this synonym points to another synonym). An error will result if the designated dataset or a synonym with this name does not exist.</p>
+<p>Datasets take precedence over synonyms, so if both a dataset and a synonym have the same name then the resolution is to the dataset.</p>
+</li>
+</ol>
+</li>
+<li>
+
+<p><i>Elsewhere in a query block</i>: In clauses other than FROM, a name typically identifies a field of some object. For example, if the expression <tt>a.b</tt> is in a SELECT or WHERE clause, it’s likely that <tt>a</tt> represents an object and <tt>b</tt> represents a field in that object.</p>
+<p>The rules for resolving the leftmost identifier in clauses other than the ones listed in Rule 1 are:</p>
+<ol style="list-style-type: decimal">
+
+<li>
+
+<p>If the identifier matches a variable-name that is in scope, it resolves to the binding of that variable. (In the case of a correlated subquery, the in-scope variable might have been bound in an outer query block.)</p>
+</li>
+<li>
+
+<p>(The “Single Variable Rule”): Otherwise, if the FROM clause in the current query block binds exactly one variable, the identifier is treated as a field access on the object bound to that variable. For example, in the query <tt>FROM customer SELECT address</tt>, the identifier address is treated as a field in the object bound to the variable customer. At runtime, if the object bound to customer has no <tt>address</tt> field, the <tt>address</tt> expression will return <tt>missing</tt>. If the FROM clause in the current query block binds multiple variables, name resolution fails with an “ambiguous name” error. If there’s no FROM clause in the current query block, name resolution fails with an “undefined identifier” error. Note that the Single Variable Rule searches for bound variables only in the current query block, not in outer (containing) blocks. The purpose of this rule is to permit the compiler to resolve field-references unambiguously without relying on any schema information. Also note that variables defined by LET clauses do not participate in the resolution process performed by this rule.</p>
+<p>Exception: In a query that has a GROUP BY clause, the Single Variable Rule does not apply in any clauses that occur after the GROUP BY because, in these clauses, the variables bound by the FROM clause are no longer in scope. In clauses after GROUP BY, only Rule 2.1 applies.</p>
+</li>
+</ol>
+</li>
+<li>
+
+<p>In an ORDER BY clause following a UNION ALL expression:</p>
+<p>The leftmost identifier is treated as a field-access on the objects that are generated by the UNION ALL. For example:</p>
+
+<div>
+<div>
+<pre class="source">query-block-1
+UNION ALL
+query-block-2
+ORDER BY salary
+</pre></div></div>
+
+<p>In the result of this query, objects that have a foo field will be ordered by the value of this field; objects that have no foo field will appear at at the beginning of the query result (in ascending order) or at the end (in descending order.)</p>
+</li>
+<li>
+
+<p><i>In a standalone expression</i>: If a query consists of a standalone expression then identifiers inside that expression are resolved according to Rule 1. For example, if the whole query is <tt>ARRAY_COUNT(a.b)</tt> then <tt>a.b</tt> will be treated as dataset <tt>b</tt> contained in dataverse <tt>a</tt>. Note that this rule only applies to identifiers which are located directly inside a standalone expression. Identifiers inside SELECT statements in a standalone expression are still resolved according to Rules 1-3. For example, if the whole query is <tt>ARRAY_SUM( (FROM employee AS e SELECT VALUE salary) )</tt> then <tt>salary</tt> is resolved as <tt>e.salary</tt> following the “Single Variable Rule” (Rule 2.2).</p>
+</li>
+<li>
+
+<p>Once the leftmost identifier has been resolved, the following dots and identifiers in the name (if any) are treated as a path expression that navigates to a field nested inside that object. The name resolves to the field at the end of the path. If this field does not exist, the value <tt>missing</tt> is returned.</p>
+</li>
+</ol></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/docs/0.9.5/sqlpp/primer-sqlpp.html b/docs/0.9.5/sqlpp/primer-sqlpp.html
new file mode 100644
index 0000000..693269f
--- /dev/null
+++ b/docs/0.9.5/sqlpp/primer-sqlpp.html
@@ -0,0 +1,852 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/sqlpp/primer-sqlpp.md at 2020-07-30
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200730" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – AsterixDB 101: An ADM and SQL++ Primer</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-07-30</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5-SNAPSHOT</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li class="active"><a href="#"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>AsterixDB 101: An ADM and SQL++ Primer</h1>
+<div class="section">
+<h2><a name="Welcome_to_AsterixDB.21"></a>Welcome to AsterixDB!</h2>
+<p>This document introduces the main features of AsterixDB’s data model (ADM) and its new SQL-like query language (SQL++) by example. The example is a simple scenario involving (synthetic) sample data modeled after data from the social domain. This document describes a set of sample datasets, together with a set of illustrative queries, to introduce you to the “AsterixDB user experience”. The complete set of steps required to create and load a handful of sample datasets, along with runnable queries and the expected results for each query, are included.</p>
+<p>This document assumes that you are at least vaguely familiar with AsterixDB and why you might want to use it. Most importantly, it assumes you already have a running instance of AsterixDB and that you know how to query it using AsterixDB’s basic web interface. For more information on these topics, you should go through the steps in <a href="../install.html">Installing Asterix Using Managix</a> before reading this document and make sure that you have a running AsterixDB instance ready to go. To get your feet wet, you should probably start with a simple local installation of AsterixDB on your favorite machine, accepting all of the default settings that Managix offers. Later you can graduate to trying AsterixDB on a cluster, its real intended home (since it targets Big Data). (Note: With the exception of specifying the correct locations where you put the source data for this example, there should no changes needed in the SQL++ statements to run the examples locally and/or to run them on a cluster when you are ready to take that step.)</p>
+<p>As you read through this document, you should try each step for yourself on your own AsterixDB instance. You will use the AsterixDB web interface to do this, and for SQL++ you will need to select SQL++ instead of AQL as your language of choice in the Query Language box that sits underneath the UI’s query entry area. Once you have reached the end of this tutorial, you will be fully armed and dangerous, with all the basic AsterixDB knowledge that you’ll need to start down the path of modeling, storing, and querying your own semistructured data.</p></div>
+<div class="section">
+<h2><a name="ADM:_Modeling_Semistructured_Data_in_AsterixDB"></a>ADM: Modeling Semistructured Data in AsterixDB</h2>
+<p>In this section you will learn all about modeling Big Data using ADM, the data model of the AsterixDB BDMS.</p>
+<div class="section">
+<h3><a name="Dataverses.2C_Datatypes.2C_and_Datasets"></a>Dataverses, Datatypes, and Datasets</h3>
+<p>The top-level organizing concept in the AsterixDB world is the <i>dataverse</i>. A dataverse—short for “data universe”—is a place (similar to a database in a relational DBMS) in which to create and manage the types, datasets, functions, and other artifacts for a given AsterixDB application. When you start using an AsterixDB instance for the first time, it starts out “empty”; it contains no data other than the AsterixDB system catalogs (which live in a special dataverse called the Metadata dataverse). To store your data in AsterixDB, you will first create a dataverse and then you use it for the <i>datatypes</i> and <i>datasets</i> for managing your own data. A datatype tells AsterixDB what you know (or more accurately, what you want it to know) a priori about one of the kinds of data instances that you want AsterixDB to hold for you. A dataset is a collection of data instances of a datatype, and AsterixDB makes sure that the data instances that you put in it conform to its specified type. Since AsterixDB targets semistructured data, you can use <i>open</i> datatypes and tell it as little or as much as you wish about your data up front; the more you tell it up front, the less information it will have to store repeatedly in the individual data instances that you give it. Instances of open datatypes are permitted to have additional content, beyond what the datatype says, as long as they at least contain the information prescribed by the datatype definition. Open typing allows data to vary from one instance to another and it leaves wiggle room for application evolution in terms of what might need to be stored in the future. If you want to restrict data instances in a dataset to have only what the datatype says, and nothing extra, you can define a <i>closed</i> datatype for that dataset and AsterixDB will keep users from storing objects that have extra data in them. Datatypes are open by default unless you tell AsterixDB otherwise. Let’s put these concepts to work.</p>
+<p>Our little sample scenario involves information about users of two hypothetical social networks, Gleambook and Chirp, and their messages. We’ll start by defining a dataverse called “TinySocial” to hold our datatypes and datasets. The AsterixDB data model (ADM) is essentially a superset of JSON—it’s what you get by extending JSON with more data types and additional data modeling constructs borrowed from object databases. The following shows how we can create the TinySocial dataverse plus a set of ADM types for modeling Chirp users, their Chirps, Gleambook users, their users’ employment information, and their messages. (Note: Keep in mind that this is just a tiny and somewhat silly example intended for illustrating some of the key features of AsterixDB. :-)) As a point of information, SQL++ is case-insensitive for both keywords and built-in type names, so the exact style of the examples below is just one of a number of possibilities.</p>
+
+<div>
+<div>
+<pre class="source"> DROP DATAVERSE TinySocial IF EXISTS;
+ CREATE DATAVERSE TinySocial;
+ USE TinySocial;
+
+ CREATE TYPE ChirpUserType AS {
+ screenName: string,
+ lang: string,
+ friendsCount: int,
+ statusesCount: int,
+ name: string,
+ followersCount: int
+ };
+
+ CREATE TYPE ChirpMessageType AS closed {
+ chirpId: string,
+ user: ChirpUserType,
+ senderLocation: point?,
+ sendTime: datetime,
+ referredTopics: {{ string }},
+ messageText: string
+ };
+
+ CREATE TYPE EmploymentType AS {
+ organizationName: string,
+ startDate: date,
+ endDate: date?
+ };
+
+ CREATE TYPE GleambookUserType AS {
+ id: int,
+ alias: string,
+ name: string,
+ userSince: datetime,
+ friendIds: {{ int }},
+ employment: [EmploymentType]
+ };
+
+ CREATE TYPE GleambookMessageType AS {
+ messageId: int,
+ authorId: int,
+ inResponseTo: int?,
+ senderLocation: point?,
+ message: string
+ };
+</pre></div></div>
+
+<p>The first three lines above tell AsterixDB to drop the old TinySocial dataverse, if one already exists, and then to create a brand new one and make it the focus of the statements that follow. The first <i>CREATE TYPE</i> statement creates a datatype for holding information about Chirp users. It is a object type with a mix of integer and string data, very much like a (flat) relational tuple. The indicated fields are all mandatory, but because the type is open, additional fields are welcome. The second statement creates a datatype for Chirp messages; this shows how to specify a closed type. Interestingly (based on one of Chirp’s APIs), each Chirp message actually embeds an instance of the sending user’s information (current as of when the message was sent), so this is an example of a nested object in ADM. Chirp messages can optionally contain the sender’s location, which is modeled via the senderLocation field of spatial type <i>point</i>; the question mark following the field type indicates its optionality. An optional field is like a nullable field in SQL—it may be present or missing, but when it’s present, its value’s data type will conform to the datatype’s specification. The sendTime field illustrates the use of a temporal primitive type, <i>datetime</i>. Lastly, the referredTopics field illustrates another way that ADM is richer than the relational model; this field holds a bag (<i>a.k.a.</i> an unordered list) of strings. Since the overall datatype definition for Chirp messages says “closed”, the fields that it lists are the only fields that instances of this type will be allowed to contain. The next two <i>CREATE TYPE</i> statements create a object type for holding information about one component of the employment history of a Gleambook user and then a object type for holding the user information itself. The Gleambook user type highlights a few additional ADM data model features. Its friendIds field is a bag of integers, presumably the Gleambook user ids for this user’s friends, and its employment field is an ordered list of employment objects. The final <i>CREATE TYPE</i> statement defines a type for handling the content of a Gleambook message in our hypothetical social data storage scenario.</p>
+<p>Before going on, we need to once again emphasize the idea that AsterixDB is aimed at storing and querying not just Big Data, but Big <i>Semistructured</i> Data. This means that most of the fields listed in the <i>CREATE TYPE</i> statements above could have been omitted without changing anything other than the resulting size of stored data instances on disk. AsterixDB stores its information about the fields defined a priori as separate metadata, whereas the information about other fields that are “just there” in instances of open datatypes is stored with each instance—making for more bits on disk and longer times for operations affected by data size (e.g., dataset scans). The only fields that <i>must</i> be specified a priori are the primary key fields of each dataset.</p></div>
+<div class="section">
+<h3><a name="Creating_Datasets_and_Indexes"></a>Creating Datasets and Indexes</h3>
+<p>Now that we have defined our datatypes, we can move on and create datasets to store the actual data. (If we wanted to, we could even have several named datasets based on any one of these datatypes.) We can do this as follows, utilizing the SQL++ DDL capabilities of AsterixDB.</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ CREATE DATASET GleambookUsers(GleambookUserType)
+ PRIMARY KEY id;
+
+ CREATE DATASET GleambookMessages(GleambookMessageType)
+ PRIMARY KEY messageId;
+
+ CREATE DATASET ChirpUsers(ChirpUserType)
+ PRIMARY KEY screenName;
+
+ CREATE DATASET ChirpMessages(ChirpMessageType)
+ PRIMARY KEY chirpId
+ hints(cardinality=100);
+
+ CREATE INDEX gbUserSinceIdx on GleambookUsers(userSince);
+ CREATE INDEX gbAuthorIdx on GleambookMessages(authorId) TYPE btree;
+ CREATE INDEX gbSenderLocIndex on GleambookMessages(senderLocation) TYPE rtree;
+ CREATE INDEX gbMessageIdx on GleambookMessages(message) TYPE keyword;
+
+ SELECT VALUE ds FROM Metadata.`Dataset` ds;
+ SELECT VALUE ix FROM Metadata.`Index` ix;
+</pre></div></div>
+
+<p>The SQL++ DDL statements above create four datasets for holding our social data in the TinySocial dataverse: GleambookUsers, GleambookMessages, ChirpUsers, and ChirpMessages. The first <i>CREATE DATASET</i> statement creates the GleambookUsers data set. It specifies that this dataset will store data instances conforming to GleambookUserType and that it has a primary key which is the id field of each instance. The primary key information is used by AsterixDB to uniquely identify instances for the purpose of later lookup and for use in secondary indexes. Each AsterixDB dataset is stored (and indexed) in the form of a B+ tree on primary key; secondary indexes point to their indexed data by primary key. In AsterixDB clusters, the primary key is also used to hash-partition (<i>a.k.a.</i> shard) the dataset across the nodes of the cluster. The next three <i>CREATE DATASET</i> statements are similar. The last one illustrates an optional clause for providing useful hints to AsterixDB. In this case, the hint tells AsterixDB that the dataset definer is anticipating that the ChirpMessages dataset will contain roughly 100 objects; knowing this can help AsterixDB to more efficiently manage and query this dataset. (AsterixDB does not yet gather and maintain data statistics; it will currently, abitrarily, assume a cardinality of one million objects per dataset in the absence of such an optional definition-time hint.)</p>
+<p>The <i>CREATE DATASET</i> statements above are followed by four more DDL statements, each of which creates a secondary index on a field of one of the datasets. The first one indexes the GleambookUsers dataset on its user-since field. This index will be a B+ tree index; its type is unspecified and <i>btree</i> is the default type. The other three illustrate how you can explicitly specify the desired type of index. In addition to btree, <i>rtree</i> and inverted <i>keyword</i> indexes are supported by AsterixDB. Indexes can also have composite keys, and more advanced text indexing is available as well (ngram(k), where k is the desired gram length).</p></div>
+<div class="section">
+<h3><a name="Querying_the_Metadata_Dataverse"></a>Querying the Metadata Dataverse</h3>
+<p>The last two statements above show how you can use queries in SQL++ to examine the AsterixDB system catalogs and tell what artifacts you have created. Just as relational DBMSs use their own tables to store their catalogs, AsterixDB uses its own datasets to persist descriptions of its datasets, datatypes, indexes, and so on. Running the first of the two queries above will list all of your newly created datasets, and it will also show you a full list of all the metadata datasets. (You can then explore from there on your own if you are curious) These last two queries also illustrate a few other factoids worth knowing: First, AsterixDB allows queries to span dataverses via the use of fully-qualified dataset names (i.e., <i>dataversename.datasetname</i>) to reference datasets that live in a dataverse other than the one referenced in the most recently executed <i>USE</i> directive. Second, they show how to escape SQL++ keywords (or other special names) in object names by using backquotes. Last but not least, they show that SQL++ supports a <i>SELECT VALUE</i> variation of SQL’s traditional <i>SELECT</i> statement that returns a single value (or element) from a query instead of constructing a new object as the query’s result like <i>SELECT</i> does; here, the returned value is an entire object from the dataset being queried (e.g., <i>SELECT VALUE ds</i> in the first statement returns the entire object from the metadata dataset containing the descriptions of all datasets.</p></div></div>
+<div class="section">
+<h2><a name="Loading_Data_Into_AsterixDB"></a>Loading Data Into AsterixDB</h2>
+<p>Okay, so far so good—AsterixDB is now ready for data, so let’s give it some data to store. Our next task will be to insert some sample data into the four datasets that we just defined. Here we will load a tiny set of objects, defined in ADM format (a superset of JSON), into each dataset. In the boxes below you can see insert statements with a list of the objects to be inserted. The files themselves are also linked. Take a few minutes to look carefully at each of the sample data sets. This will give you a better sense of the nature of the data that we are about to load and query. We should note that ADM format is a textual serialization of what AsterixDB will actually store; when persisted in AsterixDB, the data format will be binary and the data in the predefined fields of the data instances will be stored separately from their associated field name and type metadata.</p>
+<p><a href="../data/chu.adm">Chirp Users</a></p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ INSERT INTO ChirpUsers
+ ([
+ {"screenName":"NathanGiesen@211","lang":"en","friendsCount":18,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},
+ {"screenName":"ColineGeyer@63","lang":"en","friendsCount":121,"statusesCount":362,"name":"Coline Geyer","followersCount":17159},
+ {"screenName":"NilaMilliron_tw","lang":"en","friendsCount":445,"statusesCount":164,"name":"Nila Milliron","followersCount":22649},
+ {"screenName":"ChangEwing_573","lang":"en","friendsCount":182,"statusesCount":394,"name":"Chang Ewing","followersCount":32136}
+ ]);
+</pre></div></div>
+
+<p><a href="../data/chm.adm">Chirp Messages</a></p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ INSERT INTO ChirpMessages
+ ([
+ {"chirpId":"1","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("47.44,80.65"),"sendTime":datetime("2008-04-26T10:10:00"),"referredTopics":{{"product-z","customization"}},"messageText":" love product-z its customization is good:)"},
+ {"chirpId":"2","user":{"screenName":"ColineGeyer@63","lang":"en","friendsCount":121,"statusesCount":362,"name":"Coline Geyer","followersCount":17159},"senderLocation":point("32.84,67.14"),"sendTime":datetime("2010-05-13T10:10:00"),"referredTopics":{{"ccast","shortcut-menu"}},"messageText":" like ccast its shortcut-menu is awesome:)"},
+ {"chirpId":"3","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("29.72,75.8"),"sendTime":datetime("2006-11-04T10:10:00"),"referredTopics":{{"product-w","speed"}},"messageText":" like product-w the speed is good:)"},
+ {"chirpId":"4","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("39.28,70.48"),"sendTime":datetime("2011-12-26T10:10:00"),"referredTopics":{{"product-b","voice-command"}},"messageText":" like product-b the voice-command is mind-blowing:)"},
+ {"chirpId":"5","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("40.09,92.69"),"sendTime":datetime("2006-08-04T10:10:00"),"referredTopics":{{"product-w","speed"}},"messageText":" can't stand product-w its speed is terrible:("},
+ {"chirpId":"6","user":{"screenName":"ColineGeyer@63","lang":"en","friendsCount":121,"statusesCount":362,"name":"Coline Geyer","followersCount":17159},"senderLocation":point("47.51,83.99"),"sendTime":datetime("2010-05-07T10:10:00"),"referredTopics":{{"x-phone","voice-clarity"}},"messageText":" like x-phone the voice-clarity is good:)"},
+ {"chirpId":"7","user":{"screenName":"ChangEwing_573","lang":"en","friendsCount":182,"statusesCount":394,"name":"Chang Ewing","followersCount":32136},"senderLocation":point("36.21,72.6"),"sendTime":datetime("2011-08-25T10:10:00"),"referredTopics":{{"product-y","platform"}},"messageText":" like product-y the platform is good"},
+ {"chirpId":"8","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("46.05,93.34"),"sendTime":datetime("2005-10-14T10:10:00"),"referredTopics":{{"product-z","shortcut-menu"}},"messageText":" like product-z the shortcut-menu is awesome:)"},
+ {"chirpId":"9","user":{"screenName":"NathanGiesen@211","lang":"en","friendsCount":39339,"statusesCount":473,"name":"Nathan Giesen","followersCount":49416},"senderLocation":point("36.86,74.62"),"sendTime":datetime("2012-07-21T10:10:00"),"referredTopics":{{"ccast","voicemail-service"}},"messageText":" love ccast its voicemail-service is awesome"},
+ {"chirpId":"10","user":{"screenName":"ColineGeyer@63","lang":"en","friendsCount":121,"statusesCount":362,"name":"Coline Geyer","followersCount":17159},"senderLocation":point("29.15,76.53"),"sendTime":datetime("2008-01-26T10:10:00"),"referredTopics":{{"ccast","voice-clarity"}},"messageText":" hate ccast its voice-clarity is OMG:("},
+ {"chirpId":"11","user":{"screenName":"NilaMilliron_tw","lang":"en","friendsCount":445,"statusesCount":164,"name":"Nila Milliron","followersCount":22649},"senderLocation":point("37.59,68.42"),"sendTime":datetime("2008-03-09T10:10:00"),"referredTopics":{{"x-phone","platform"}},"messageText":" can't stand x-phone its platform is terrible"},
+ {"chirpId":"12","user":{"screenName":"OliJackson_512","lang":"en","friendsCount":445,"statusesCount":164,"name":"Oli Jackson","followersCount":22649},"senderLocation":point("24.82,94.63"),"sendTime":datetime("2010-02-13T10:10:00"),"referredTopics":{{"product-y","voice-command"}},"messageText":" like product-y the voice-command is amazing:)"}
+ ]);
+</pre></div></div>
+
+<p><a href="../data/gbu.adm">Gleambook Users</a></p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ INSERT INTO GleambookUsers
+ ([
+ {"id":1,"alias":"Margarita","name":"MargaritaStoddard","nickname":"Mags","userSince":datetime("2012-08-20T10:10:00"),"friendIds":{{2,3,6,10}},"employment":[{"organizationName":"Codetechno","startDate":date("2006-08-06")},{"organizationName":"geomedia","startDate":date("2010-06-17"),"endDate":date("2010-01-26")}],"gender":"F"},
+ {"id":2,"alias":"Isbel","name":"IsbelDull","nickname":"Izzy","userSince":datetime("2011-01-22T10:10:00"),"friendIds":{{1,4}},"employment":[{"organizationName":"Hexviafind","startDate":date("2010-04-27")}]},
+ {"id":3,"alias":"Emory","name":"EmoryUnk","userSince":datetime("2012-07-10T10:10:00"),"friendIds":{{1,5,8,9}},"employment":[{"organizationName":"geomedia","startDate":date("2010-06-17"),"endDate":date("2010-01-26")}]},
+ {"id":4,"alias":"Nicholas","name":"NicholasStroh","userSince":datetime("2010-12-27T10:10:00"),"friendIds":{{2}},"employment":[{"organizationName":"Zamcorporation","startDate":date("2010-06-08")}]},
+ {"id":5,"alias":"Von","name":"VonKemble","userSince":datetime("2010-01-05T10:10:00"),"friendIds":{{3,6,10}},"employment":[{"organizationName":"Kongreen","startDate":date("2010-11-27")}]},
+ {"id":6,"alias":"Willis","name":"WillisWynne","userSince":datetime("2005-01-17T10:10:00"),"friendIds":{{1,3,7}},"employment":[{"organizationName":"jaydax","startDate":date("2009-05-15")}]},
+ {"id":7,"alias":"Suzanna","name":"SuzannaTillson","userSince":datetime("2012-08-07T10:10:00"),"friendIds":{{6}},"employment":[{"organizationName":"Labzatron","startDate":date("2011-04-19")}]},
+ {"id":8,"alias":"Nila","name":"NilaMilliron","userSince":datetime("2008-01-01T10:10:00"),"friendIds":{{3}},"employment":[{"organizationName":"Plexlane","startDate":date("2010-02-28")}]},
+ {"id":9,"alias":"Woodrow","name":"WoodrowNehling","nickname":"Woody","userSince":datetime("2005-09-20T10:10:00"),"friendIds":{{3,10}},"employment":[{"organizationName":"Zuncan","startDate":date("2003-04-22"),"endDate":date("2009-12-13")}]},
+ {"id":10,"alias":"Bram","name":"BramHatch","userSince":datetime("2010-10-16T10:10:00"),"friendIds":{{1,5,9}},"employment":[{"organizationName":"physcane","startDate":date("2007-06-05"),"endDate":date("2011-11-05")}]}
+ ]);
+</pre></div></div>
+
+<p><a href="../data/gbm.adm">Gleambook Messages</a></p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ INSERT INTO GleambookMessages
+ ([
+ {"messageId":1,"authorId":3,"inResponseTo":2,"senderLocation":point("47.16,77.75"),"message":" love product-b its shortcut-menu is awesome:)"},
+ {"messageId":2,"authorId":1,"inResponseTo":4,"senderLocation":point("41.66,80.87"),"message":" dislike x-phone its touch-screen is horrible"},
+ {"messageId":3,"authorId":2,"inResponseTo":4,"senderLocation":point("48.09,81.01"),"message":" like product-y the plan is amazing"},
+ {"messageId":4,"authorId":1,"inResponseTo":2,"senderLocation":point("37.73,97.04"),"message":" can't stand acast the network is horrible:("},
+ {"messageId":5,"authorId":6,"inResponseTo":2,"senderLocation":point("34.7,90.76"),"message":" love product-b the customization is mind-blowing"},
+ {"messageId":6,"authorId":2,"inResponseTo":1,"senderLocation":point("31.5,75.56"),"message":" like product-z its platform is mind-blowing"},
+ {"messageId":7,"authorId":5,"inResponseTo":15,"senderLocation":point("32.91,85.05"),"message":" dislike product-b the speed is horrible"},
+ {"messageId":8,"authorId":1,"inResponseTo":11,"senderLocation":point("40.33,80.87"),"message":" like ccast the 3G is awesome:)"},
+ {"messageId":9,"authorId":3,"inResponseTo":12,"senderLocation":point("34.45,96.48"),"message":" love ccast its wireless is good"},
+ {"messageId":10,"authorId":1,"inResponseTo":12,"senderLocation":point("42.5,70.01"),"message":" can't stand product-w the touch-screen is terrible"},
+ {"messageId":11,"authorId":1,"inResponseTo":1,"senderLocation":point("38.97,77.49"),"message":" can't stand acast its plan is terrible"},
+ {"messageId":12,"authorId":10,"inResponseTo":6,"senderLocation":point("42.26,77.76"),"message":" can't stand product-z its voicemail-service is OMG:("},
+ {"messageId":13,"authorId":10,"inResponseTo":4,"senderLocation":point("42.77,78.92"),"message":" dislike x-phone the voice-command is bad:("},
+ {"messageId":14,"authorId":9,"inResponseTo":12,"senderLocation":point("41.33,85.28"),"message":" love acast its 3G is good:)"},
+ {"messageId":15,"authorId":7,"inResponseTo":11,"senderLocation":point("44.47,67.11"),"message":" like x-phone the voicemail-service is awesome"}
+ ]);
+</pre></div></div>
+</div>
+<div class="section">
+<h2><a name="SQL.2B.2B:_Querying_Your_AsterixDB_Data"></a>SQL++: Querying Your AsterixDB Data</h2>
+<p>Congratulations! You now have sample social data stored (and indexed) in AsterixDB. (You are part of an elite and adventurous group of individuals. :-)) Now that you have successfully loaded the provided sample data into the datasets that we defined, you can start running queries against them.</p>
+<p>AsterixDB currently supports two query languages. The first—AsterixDB’s original query language—is AQL (the Asterix Query Language). The AQL language was inspired by XQuery, the W3C standard language for querying XML data. (There is a version of this tutorial for AQL if you would like to learn more about it.) The query language described in the remainder of this tutorial is SQL++, a SQL-inspired language designed (as AQL was) for working with semistructured data. SQL++ has much in common with SQL, but there are differences due to the data model that SQL++ is designed to serve. SQL was designed in the 1970’s to interact with the flat, schema-ified world of relational databases. SQL++ is designed for the nested, schema-less (or schema-optional, in AsterixDB) world of NoSQL systems. While SQL++ has the same expressive power as AQL, it offers a more familar paradigm for experienced SQL users to use to query and manipulate data in AsterixDB.</p>
+<p>In this section we introduce SQL++ via a set of example queries, along with their expected results, based on the data above, to help you get started. Many of the most important features of SQL++ are presented in this set of representative queries. You can find more details in the document on the <a href="datamodel.html">Asterix Data Model (ADM)</a>, in the <a href="manual-sqlpp.html">SQL++ Reference Manual</a>, and a complete list of built-in functions is available in the <a href="functions-sqlpp.html">SQL++ Functions</a> document.</p>
+<p>SQL++ is an expression language. Even the simple expression 1+1 is a valid SQL++ query that evaluates to 2. (Try it for yourself! Okay, maybe that’s <i>not</i> the best use of a 512-node shared-nothing compute cluster.) But enough talk! Let’s go ahead and try writing some queries and see about learning SQL++ by example. (Again, don’t forget to choose SQL++ as the query language in the web interface!)</p>
+<div class="section">
+<h3><a name="Query_0-A_-_Exact-Match_Lookup"></a>Query 0-A - Exact-Match Lookup</h3>
+<p>For our first query, let’s find a Gleambook user based on his or her user id. Suppose the user we want is the user whose id is 8:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE user
+ FROM GleambookUsers user
+ WHERE user.id = 8;
+</pre></div></div>
+
+<p>As in SQL, the query’s <i>FROM</i> clause binds the variable <tt>user</tt> incrementally to the data instances residing in the dataset named GleambookUsers. Its <i>WHERE</i> clause selects only those bindings having a user id of interest, filtering out the rest. The <i>SELECT</i> <i>VALUE</i> clause returns the (entire) data value (a Gleambook user object in this case) for each binding that satisfies the predicate. Since this dataset is indexed on user id (its primary key), this query will be done via a quick index lookup.</p>
+<p>The expected result for our sample data is as follows:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 8, "alias": "Nila", "name": "NilaMilliron", "userSince": datetime("2008-01-01T10:10:00.000Z"), "friendIds": {{ 3 }}, "employment": [ { "organizationName": "Plexlane", "startDate": date("2010-02-28") } ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_0-B_-_Range_Scan"></a>Query 0-B - Range Scan</h3>
+<p>SQL++, like SQL, supports a variety of different predicates. For example, for our next query, let’s find the Gleambook users whose ids are in the range between 2 and 4:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE user
+ FROM GleambookUsers user
+ WHERE user.id >= 2 AND user.id <= 4;
+</pre></div></div>
+
+<p>This query’s expected result, also evaluable using the primary index on user id, is:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 2, "alias": "Isbel", "name": "IsbelDull", "userSince": datetime("2011-01-22T10:10:00.000Z"), "friendIds": {{ 1, 4 }}, "employment": [ { "organizationName": "Hexviafind", "startDate": date("2010-04-27") } ], "nickname": "Izzy" }
+ { "id": 3, "alias": "Emory", "name": "EmoryUnk", "userSince": datetime("2012-07-10T10:10:00.000Z"), "friendIds": {{ 1, 5, 8, 9 }}, "employment": [ { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ] }
+ { "id": 4, "alias": "Nicholas", "name": "NicholasStroh", "userSince": datetime("2010-12-27T10:10:00.000Z"), "friendIds": {{ 2 }}, "employment": [ { "organizationName": "Zamcorporation", "startDate": date("2010-06-08") } ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_1_-_Other_Query_Filters"></a>Query 1 - Other Query Filters</h3>
+<p>SQL++ can do range queries on any data type that supports the appropriate set of comparators. As an example, this next query retrieves the Gleambook users who joined between July 22, 2010 and July 29, 2012:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE user
+ FROM GleambookUsers user
+ WHERE user.userSince >= datetime('2010-07-22T00:00:00')
+ AND user.userSince <= datetime('2012-07-29T23:59:59');
+</pre></div></div>
+
+<p>The expected result for this query, also an indexable query, is as follows:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 10, "alias": "Bram", "name": "BramHatch", "userSince": datetime("2010-10-16T10:10:00.000Z"), "friendIds": {{ 1, 5, 9 }}, "employment": [ { "organizationName": "physcane", "startDate": date("2007-06-05"), "endDate": date("2011-11-05") } ] }
+ { "id": 2, "alias": "Isbel", "name": "IsbelDull", "userSince": datetime("2011-01-22T10:10:00.000Z"), "friendIds": {{ 1, 4 }}, "employment": [ { "organizationName": "Hexviafind", "startDate": date("2010-04-27") } ], "nickname": "Izzy" }
+ { "id": 3, "alias": "Emory", "name": "EmoryUnk", "userSince": datetime("2012-07-10T10:10:00.000Z"), "friendIds": {{ 1, 5, 8, 9 }}, "employment": [ { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ] }
+ { "id": 4, "alias": "Nicholas", "name": "NicholasStroh", "userSince": datetime("2010-12-27T10:10:00.000Z"), "friendIds": {{ 2 }}, "employment": [ { "organizationName": "Zamcorporation", "startDate": date("2010-06-08") } ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_2-A_-_Equijoin"></a>Query 2-A - Equijoin</h3>
+<p>In addition to simply binding variables to data instances and returning them “whole”, an SQL++ query can construct new ADM instances to return based on combinations of its variable bindings. This gives SQL++ the power to do projections and joins much like those done using multi-table <i>FROM</i> clauses in SQL. For example, suppose we wanted a list of all Gleambook users paired with their associated messages, with the list enumerating the author name and the message text associated with each Gleambook message. We could do this as follows in SQL++:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT user.name AS uname, msg.message AS message
+ FROM GleambookUsers user, GleambookMessages msg
+ WHERE msg.authorId = user.id;
+</pre></div></div>
+
+<p>The result of this query is a sequence of new ADM instances, one for each author/message pair. Each instance in the result will be an ADM object containing two fields, “uname” and “message”, containing the user’s name and the message text, respectively, for each author/message pair. Notice how the use of a traditional SQL-style <i>SELECT</i> clause, as opposed to the new SQL++ <i>SELECT VALUE</i> clause, automatically results in the construction of a new object value for each result.</p>
+<p>The expected result of this example SQL++ join query for our sample data set is:</p>
+
+<div>
+<div>
+<pre class="source"> { "uname": "WillisWynne", "message": " love product-b the customization is mind-blowing" }
+ { "uname": "WoodrowNehling", "message": " love acast its 3G is good:)" }
+ { "uname": "BramHatch", "message": " can't stand product-z its voicemail-service is OMG:(" }
+ { "uname": "BramHatch", "message": " dislike x-phone the voice-command is bad:(" }
+ { "uname": "MargaritaStoddard", "message": " like ccast the 3G is awesome:)" }
+ { "uname": "MargaritaStoddard", "message": " can't stand product-w the touch-screen is terrible" }
+ { "uname": "MargaritaStoddard", "message": " can't stand acast its plan is terrible" }
+ { "uname": "MargaritaStoddard", "message": " dislike x-phone its touch-screen is horrible" }
+ { "uname": "MargaritaStoddard", "message": " can't stand acast the network is horrible:(" }
+ { "uname": "IsbelDull", "message": " like product-z its platform is mind-blowing" }
+ { "uname": "IsbelDull", "message": " like product-y the plan is amazing" }
+ { "uname": "EmoryUnk", "message": " love ccast its wireless is good" }
+ { "uname": "EmoryUnk", "message": " love product-b its shortcut-menu is awesome:)" }
+ { "uname": "VonKemble", "message": " dislike product-b the speed is horrible" }
+ { "uname": "SuzannaTillson", "message": " like x-phone the voicemail-service is awesome" }
+</pre></div></div>
+
+<p>If we were feeling lazy, we might use <i>SELECT *</i> in SQL++ to return all of the matching user/message data:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT *
+ FROM GleambookUsers user, GleambookMessages msg
+ WHERE msg.authorId = user.id;
+</pre></div></div>
+
+<p>In SQL++, this <i>SELECT *</i> query will produce a new nested object for each user/message pair. Each result object contains one field (named after the “user” variable) to hold the user object and another field (named after the “msg” variable) to hold the matching message object. Note that the nested nature of this SQL++ <i>SELECT *</i> result is different than traditional SQL, as SQL was not designed to handle the richer, nested data model that underlies the design of SQL++.</p>
+<p>The expected result of this version of the SQL++ join query for our sample data set is:</p>
+
+<div>
+<div>
+<pre class="source"> { "user": { "id": 6, "alias": "Willis", "name": "WillisWynne", "userSince": datetime("2005-01-17T10:10:00.000Z"), "friendIds": {{ 1, 3, 7 }}, "employment": [ { "organizationName": "jaydax", "startDate": date("2009-05-15") } ] }, "msg": { "messageId": 5, "authorId": 6, "inResponseTo": 2, "senderLocation": point("34.7,90.76"), "message": " love product-b the customization is mind-blowing" } }
+ { "user": { "id": 9, "alias": "Woodrow", "name": "WoodrowNehling", "userSince": datetime("2005-09-20T10:10:00.000Z"), "friendIds": {{ 3, 10 }}, "employment": [ { "organizationName": "Zuncan", "startDate": date("2003-04-22"), "endDate": date("2009-12-13") } ], "nickname": "Woody" }, "msg": { "messageId": 14, "authorId": 9, "inResponseTo": 12, "senderLocation": point("41.33,85.28"), "message": " love acast its 3G is good:)" } }
+ { "user": { "id": 10, "alias": "Bram", "name": "BramHatch", "userSince": datetime("2010-10-16T10:10:00.000Z"), "friendIds": {{ 1, 5, 9 }}, "employment": [ { "organizationName": "physcane", "startDate": date("2007-06-05"), "endDate": date("2011-11-05") } ] }, "msg": { "messageId": 12, "authorId": 10, "inResponseTo": 6, "senderLocation": point("42.26,77.76"), "message": " can't stand product-z its voicemail-service is OMG:(" } }
+ { "user": { "id": 10, "alias": "Bram", "name": "BramHatch", "userSince": datetime("2010-10-16T10:10:00.000Z"), "friendIds": {{ 1, 5, 9 }}, "employment": [ { "organizationName": "physcane", "startDate": date("2007-06-05"), "endDate": date("2011-11-05") } ] }, "msg": { "messageId": 13, "authorId": 10, "inResponseTo": 4, "senderLocation": point("42.77,78.92"), "message": " dislike x-phone the voice-command is bad:(" } }
+ { "user": { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }, "msg": { "messageId": 8, "authorId": 1, "inResponseTo": 11, "senderLocation": point("40.33,80.87"), "message": " like ccast the 3G is awesome:)" } }
+ { "user": { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }, "msg": { "messageId": 10, "authorId": 1, "inResponseTo": 12, "senderLocation": point("42.5,70.01"), "message": " can't stand product-w the touch-screen is terrible" } }
+ { "user": { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }, "msg": { "messageId": 11, "authorId": 1, "inResponseTo": 1, "senderLocation": point("38.97,77.49"), "message": " can't stand acast its plan is terrible" } }
+ { "user": { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }, "msg": { "messageId": 2, "authorId": 1, "inResponseTo": 4, "senderLocation": point("41.66,80.87"), "message": " dislike x-phone its touch-screen is horrible" } }
+ { "user": { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }, "msg": { "messageId": 4, "authorId": 1, "inResponseTo": 2, "senderLocation": point("37.73,97.04"), "message": " can't stand acast the network is horrible:(" } }
+ { "user": { "id": 2, "alias": "Isbel", "name": "IsbelDull", "userSince": datetime("2011-01-22T10:10:00.000Z"), "friendIds": {{ 1, 4 }}, "employment": [ { "organizationName": "Hexviafind", "startDate": date("2010-04-27") } ], "nickname": "Izzy" }, "msg": { "messageId": 6, "authorId": 2, "inResponseTo": 1, "senderLocation": point("31.5,75.56"), "message": " like product-z its platform is mind-blowing" } }
+ { "user": { "id": 2, "alias": "Isbel", "name": "IsbelDull", "userSince": datetime("2011-01-22T10:10:00.000Z"), "friendIds": {{ 1, 4 }}, "employment": [ { "organizationName": "Hexviafind", "startDate": date("2010-04-27") } ], "nickname": "Izzy" }, "msg": { "messageId": 3, "authorId": 2, "inResponseTo": 4, "senderLocation": point("48.09,81.01"), "message": " like product-y the plan is amazing" } }
+ { "user": { "id": 3, "alias": "Emory", "name": "EmoryUnk", "userSince": datetime("2012-07-10T10:10:00.000Z"), "friendIds": {{ 1, 5, 8, 9 }}, "employment": [ { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ] }, "msg": { "messageId": 9, "authorId": 3, "inResponseTo": 12, "senderLocation": point("34.45,96.48"), "message": " love ccast its wireless is good" } }
+ { "user": { "id": 3, "alias": "Emory", "name": "EmoryUnk", "userSince": datetime("2012-07-10T10:10:00.000Z"), "friendIds": {{ 1, 5, 8, 9 }}, "employment": [ { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ] }, "msg": { "messageId": 1, "authorId": 3, "inResponseTo": 2, "senderLocation": point("47.16,77.75"), "message": " love product-b its shortcut-menu is awesome:)" } }
+ { "user": { "id": 5, "alias": "Von", "name": "VonKemble", "userSince": datetime("2010-01-05T10:10:00.000Z"), "friendIds": {{ 3, 6, 10 }}, "employment": [ { "organizationName": "Kongreen", "startDate": date("2010-11-27") } ] }, "msg": { "messageId": 7, "authorId": 5, "inResponseTo": 15, "senderLocation": point("32.91,85.05"), "message": " dislike product-b the speed is horrible" } }
+ { "user": { "id": 7, "alias": "Suzanna", "name": "SuzannaTillson", "userSince": datetime("2012-08-07T10:10:00.000Z"), "friendIds": {{ 6 }}, "employment": [ { "organizationName": "Labzatron", "startDate": date("2011-04-19") } ] }, "msg": { "messageId": 15, "authorId": 7, "inResponseTo": 11, "senderLocation": point("44.47,67.11"), "message": " like x-phone the voicemail-service is awesome" } }
+</pre></div></div>
+
+<p>Finally (for now :-)), another less lazy and more explicit SQL++ way of achieving the result shown above is:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE {"user": user, "message": msg}
+ FROM GleambookUsers user, GleambookMessages msg
+ WHERE msg.authorId = user.id;
+</pre></div></div>
+
+<p>This version of the query uses an explicit object constructor to build each result object. (Note that “uname” and “message” are both simple SQL++ expressions themselves—so in the most general case, even the resulting field names can be computed as part of the query, making SQL++ a very powerful tool for slicing and dicing semistructured data.)</p></div>
+<div class="section">
+<h3><a name="Query_2-B_-_Index_join"></a>Query 2-B - Index join</h3>
+<p>By default, AsterixDB evaluates equijoin queries using hash-based join methods that work well for doing ad hoc joins of very large data sets (<a class="externalLink" href="http://en.wikipedia.org/wiki/Hash_join">http://en.wikipedia.org/wiki/Hash_join</a>). On a cluster, hash partitioning is employed as AsterixDB’s divide-and-conquer strategy for computing large parallel joins. AsterixDB includes other join methods, but in the absence of data statistics and selectivity estimates, it doesn’t (yet) have the know-how to intelligently choose among its alternatives. We therefore asked ourselves the classic question—WWOD?—What Would Oracle Do?—and in the interim, SQL++ includes a clunky (but useful) hint-based mechanism for addressing the occasional need to suggest to AsterixDB which join method it should use for a particular SQL++ query.</p>
+<p>The following query is similar to the first version of Query 2-A but includes a suggestion to AsterixDB that it should consider employing an index-based nested-loop join technique to process the query:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT user.name AS uname, msg.message AS message
+ FROM GleambookUsers user, GleambookMessages msg
+ WHERE msg.authorId /*+ indexnl */ = user.id;
+</pre></div></div>
+
+<p>In addition to illustrating the use of a hint, the query also shows how to achieve the same result object format using <i>SELECT</i> and <i>AS</i> instead of using an explicit object constructor. The expected result is (of course) the same as before, modulo the order of the instances. Result ordering is (intentionally) undefined in SQL++ in the absence of an <i>ORDER BY</i> clause. The query result for our sample data in this case is:</p>
+
+<div>
+<div>
+<pre class="source"> { "uname": "IsbelDull", "message": " like product-z its platform is mind-blowing" }
+ { "uname": "MargaritaStoddard", "message": " like ccast the 3G is awesome:)" }
+ { "uname": "EmoryUnk", "message": " love ccast its wireless is good" }
+ { "uname": "MargaritaStoddard", "message": " can't stand product-w the touch-screen is terrible" }
+ { "uname": "MargaritaStoddard", "message": " can't stand acast its plan is terrible" }
+ { "uname": "BramHatch", "message": " can't stand product-z its voicemail-service is OMG:(" }
+ { "uname": "WoodrowNehling", "message": " love acast its 3G is good:)" }
+ { "uname": "EmoryUnk", "message": " love product-b its shortcut-menu is awesome:)" }
+ { "uname": "MargaritaStoddard", "message": " dislike x-phone its touch-screen is horrible" }
+ { "uname": "IsbelDull", "message": " like product-y the plan is amazing" }
+ { "uname": "MargaritaStoddard", "message": " can't stand acast the network is horrible:(" }
+ { "uname": "WillisWynne", "message": " love product-b the customization is mind-blowing" }
+ { "uname": "VonKemble", "message": " dislike product-b the speed is horrible" }
+ { "uname": "BramHatch", "message": " dislike x-phone the voice-command is bad:(" }
+ { "uname": "SuzannaTillson", "message": " like x-phone the voicemail-service is awesome" }
+</pre></div></div>
+
+<p>(It is worth knowing, with respect to influencing AsterixDB’s query evaluation, that <i>FROM</i> clauses—<i>a.k.a.</i> joins— are currently evaluated in order, with the “left” clause probing the data of the “right” clause. SQL++ also supports SQL-style <i>JOIN</i> clauses, and the same is true for those.)</p></div>
+<div class="section">
+<h3><a name="Query_3_-_Nested_Outer_Join"></a>Query 3 - Nested Outer Join</h3>
+<p>In order to support joins between tables with missing/dangling join tuples, the designers of SQL ended up shoe-horning a subset of the relational algebra into SQL’s <i>FROM</i> clause syntax—and providing a variety of join types there for users to choose from (which SQL++ supports for SQL compatibility). Left outer joins are particularly important in SQL, e.g., to print a summary of customers and orders, grouped by customer, without omitting those customers who haven’t placed any orders yet.</p>
+<p>The SQL++ language supports nesting, both of queries and of query results, and the combination allows for an arguably cleaner/more natural approach to such queries. As an example, supposed we wanted, for each Gleambook user, to produce a object that has his/her name plus a list of the messages written by that user. In SQL, this would involve a left outer join between users and messages, grouping by user, and having the user name repeated along side each message. In SQL++, this sort of use case can be handled (more naturally) as follows:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT user.name AS uname,
+ (SELECT VALUE msg.message
+ FROM GleambookMessages msg
+ WHERE msg.authorId = user.id) AS messages
+ FROM GleambookUsers user;
+</pre></div></div>
+
+<p>This SQL++ query binds the variable <tt>user</tt> to the data instances in GleambookUsers; for each user, it constructs a result object containing a “uname” field with the user’s name and a “messages” field with a nested collection of all messages for that user. The nested collection for each user is specified by using a correlated subquery. (Note: While it looks like nested loops could be involved in computing the result, AsterixDB recognizes the equivalence of such a query to an outerjoin, and it will use an efficient hash-based strategy when actually computing the query’s result.)</p>
+<p>Here is this example query’s expected output:</p>
+
+<div>
+<div>
+<pre class="source"> { "uname": "WillisWynne", "messages": [ " love product-b the customization is mind-blowing" ] }
+ { "uname": "NilaMilliron", "messages": [ ] }
+ { "uname": "WoodrowNehling", "messages": [ " love acast its 3G is good:)" ] }
+ { "uname": "BramHatch", "messages": [ " dislike x-phone the voice-command is bad:(", " can't stand product-z its voicemail-service is OMG:(" ] }
+ { "uname": "MargaritaStoddard", "messages": [ " dislike x-phone its touch-screen is horrible", " can't stand acast the network is horrible:(", " like ccast the 3G is awesome:)", " can't stand product-w the touch-screen is terrible", " can't stand acast its plan is terrible" ] }
+ { "uname": "IsbelDull", "messages": [ " like product-y the plan is amazing", " like product-z its platform is mind-blowing" ] }
+ { "uname": "EmoryUnk", "messages": [ " love product-b its shortcut-menu is awesome:)", " love ccast its wireless is good" ] }
+ { "uname": "NicholasStroh", "messages": [ ] }
+ { "uname": "VonKemble", "messages": [ " dislike product-b the speed is horrible" ] }
+ { "uname": "SuzannaTillson", "messages": [ " like x-phone the voicemail-service is awesome" ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_4_-_Theta_Join"></a>Query 4 - Theta Join</h3>
+<p>Not all joins are expressible as equijoins and computable using equijoin-oriented algorithms. The join predicates for some use cases involve predicates with functions; AsterixDB supports the expression of such queries and will still evaluate them as best it can using nested loop based techniques (and broadcast joins in the parallel case).</p>
+<p>As an example of such a use case, suppose that we wanted, for each chirp message C, to find all of the other chirp messages that originated from within a circle of radius of 1 surrounding chirp C’s location. In SQL++, this can be specified in a manner similar to the previous query using one of the built-in functions on the spatial data type instead of id equality in the correlated query’s <i>WHERE</i> clause:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT cm1.messageText AS message,
+ (SELECT VALUE cm2.messageText
+ FROM ChirpMessages cm2
+ WHERE `spatial-distance`(cm1.senderLocation, cm2.senderLocation) <= 1
+ AND cm2.chirpId < cm1.chirpId) AS nearbyMessages
+ FROM ChirpMessages cm1;
+</pre></div></div>
+
+<p>Here is the expected result for this query:</p>
+
+<div>
+<div>
+<pre class="source"> { "message": " can't stand x-phone its platform is terrible", "nearbyMessages": [ ] }
+ { "message": " like ccast its shortcut-menu is awesome:)", "nearbyMessages": [ ] }
+ { "message": " like product-w the speed is good:)", "nearbyMessages": [ " hate ccast its voice-clarity is OMG:(" ] }
+ { "message": " like product-b the voice-command is mind-blowing:)", "nearbyMessages": [ ] }
+ { "message": " like x-phone the voice-clarity is good:)", "nearbyMessages": [ ] }
+ { "message": " like product-y the platform is good", "nearbyMessages": [ ] }
+ { "message": " love ccast its voicemail-service is awesome", "nearbyMessages": [ ] }
+ { "message": " love product-z its customization is good:)", "nearbyMessages": [ ] }
+ { "message": " hate ccast its voice-clarity is OMG:(", "nearbyMessages": [ ] }
+ { "message": " like product-y the voice-command is amazing:)", "nearbyMessages": [ ] }
+ { "message": " can't stand product-w its speed is terrible:(", "nearbyMessages": [ ] }
+ { "message": " like product-z the shortcut-menu is awesome:)", "nearbyMessages": [ ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_5_-_Fuzzy_Join"></a>Query 5 - Fuzzy Join</h3>
+<p>As another example of a non-equijoin use case, we could ask AsterixDB to find, for each Gleambook user, all Chirp users with names “similar” to their name. AsterixDB supports a variety of “fuzzy match” functions for use with textual and set-based data. As one example, we could choose to use edit distance with a threshold of 3 as the definition of name similarity, in which case we could write the following query using SQL++’s operator-based syntax (~=) for testing whether or not two values are similar:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+ SET simfunction "edit-distance";
+ SET simthreshold "3";
+
+ SELECT gbu.id AS id, gbu.name AS name,
+ (SELECT cm.user.screenName AS chirpScreenname,
+ cm.user.name AS chirpName
+ FROM ChirpMessages cm
+ WHERE cm.user.name ~= gbu.name) AS similarUsers
+ FROM GleambookUsers gbu;
+</pre></div></div>
+
+<p>The expected result for this query against our sample data is:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 6, "name": "WillisWynne", "similarUsers": [ ] }
+ { "id": 8, "name": "NilaMilliron", "similarUsers": [ { "chirpScreenname": "NilaMilliron_tw", "chirpName": "Nila Milliron" } ] }
+ { "id": 9, "name": "WoodrowNehling", "similarUsers": [ ] }
+ { "id": 10, "name": "BramHatch", "similarUsers": [ ] }
+ { "id": 1, "name": "MargaritaStoddard", "similarUsers": [ ] }
+ { "id": 2, "name": "IsbelDull", "similarUsers": [ ] }
+ { "id": 3, "name": "EmoryUnk", "similarUsers": [ ] }
+ { "id": 4, "name": "NicholasStroh", "similarUsers": [ ] }
+ { "id": 5, "name": "VonKemble", "similarUsers": [ ] }
+ { "id": 7, "name": "SuzannaTillson", "similarUsers": [ ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_6_-_Existential_Quantification"></a>Query 6 - Existential Quantification</h3>
+<p>The expressive power of SQL++ includes support for queries involving “some” (existentially quantified) and “all” (universally quantified) query semantics. As an example of an existential SQL++ query, here we show a query to list the Gleambook users who are currently employed. Such employees will have an employment history containing a object in which the end-date field is <i>MISSING</i> (or it could be there but have the value <i>NULL</i>, as JSON unfortunately provides two ways to represent unknown values). This leads us to the following SQL++ query:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE gbu
+ FROM GleambookUsers gbu
+ WHERE (SOME e IN gbu.employment SATISFIES e.endDate IS UNKNOWN);
+</pre></div></div>
+
+<p>The expected result in this case is:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 6, "alias": "Willis", "name": "WillisWynne", "userSince": datetime("2005-01-17T10:10:00.000Z"), "friendIds": {{ 1, 3, 7 }}, "employment": [ { "organizationName": "jaydax", "startDate": date("2009-05-15") } ] }
+ { "id": 8, "alias": "Nila", "name": "NilaMilliron", "userSince": datetime("2008-01-01T10:10:00.000Z"), "friendIds": {{ 3 }}, "employment": [ { "organizationName": "Plexlane", "startDate": date("2010-02-28") } ] }
+ { "id": 1, "alias": "Margarita", "name": "MargaritaStoddard", "userSince": datetime("2012-08-20T10:10:00.000Z"), "friendIds": {{ 2, 3, 6, 10 }}, "employment": [ { "organizationName": "Codetechno", "startDate": date("2006-08-06") }, { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ], "nickname": "Mags", "gender": "F" }
+ { "id": 2, "alias": "Isbel", "name": "IsbelDull", "userSince": datetime("2011-01-22T10:10:00.000Z"), "friendIds": {{ 1, 4 }}, "employment": [ { "organizationName": "Hexviafind", "startDate": date("2010-04-27") } ], "nickname": "Izzy" }
+ { "id": 4, "alias": "Nicholas", "name": "NicholasStroh", "userSince": datetime("2010-12-27T10:10:00.000Z"), "friendIds": {{ 2 }}, "employment": [ { "organizationName": "Zamcorporation", "startDate": date("2010-06-08") } ] }
+ { "id": 5, "alias": "Von", "name": "VonKemble", "userSince": datetime("2010-01-05T10:10:00.000Z"), "friendIds": {{ 3, 6, 10 }}, "employment": [ { "organizationName": "Kongreen", "startDate": date("2010-11-27") } ] }
+ { "id": 7, "alias": "Suzanna", "name": "SuzannaTillson", "userSince": datetime("2012-08-07T10:10:00.000Z"), "friendIds": {{ 6 }}, "employment": [ { "organizationName": "Labzatron", "startDate": date("2011-04-19") } ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_7_-_Universal_Quantification"></a>Query 7 - Universal Quantification</h3>
+<p>As an example of a universal SQL++ query, here we show a query to list the Gleambook users who are currently unemployed. Such employees will have an employment history containing no objects with unknown end-date field values, leading us to the following SQL++ query:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT VALUE gbu
+ FROM GleambookUsers gbu
+ WHERE (EVERY e IN gbu.employment SATISFIES e.endDate IS NOT UNKNOWN);
+</pre></div></div>
+
+<p>Here is the expected result for our sample data:</p>
+
+<div>
+<div>
+<pre class="source"> { "id": 9, "alias": "Woodrow", "name": "WoodrowNehling", "userSince": datetime("2005-09-20T10:10:00.000Z"), "friendIds": {{ 3, 10 }}, "employment": [ { "organizationName": "Zuncan", "startDate": date("2003-04-22"), "endDate": date("2009-12-13") } ], "nickname": "Woody" }
+ { "id": 10, "alias": "Bram", "name": "BramHatch", "userSince": datetime("2010-10-16T10:10:00.000Z"), "friendIds": {{ 1, 5, 9 }}, "employment": [ { "organizationName": "physcane", "startDate": date("2007-06-05"), "endDate": date("2011-11-05") } ] }
+ { "id": 3, "alias": "Emory", "name": "EmoryUnk", "userSince": datetime("2012-07-10T10:10:00.000Z"), "friendIds": {{ 1, 5, 8, 9 }}, "employment": [ { "organizationName": "geomedia", "startDate": date("2010-06-17"), "endDate": date("2010-01-26") } ] }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_8_-_Simple_Aggregation"></a>Query 8 - Simple Aggregation</h3>
+<p>Like SQL, the SQL++ language of AsterixDB provides support for computing aggregates over large amounts of data. As a very simple example, the following SQL++ query computes the total number of Gleambook users in a SQL-like way:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT COUNT(gbu) AS numUsers FROM GleambookUsers gbu;
+</pre></div></div>
+
+<p>This query’s result will be:</p>
+
+<div>
+<div>
+<pre class="source"> { "numUsers": 10 }
+</pre></div></div>
+
+<p>If an “unwrapped” value is preferred, the following variant could be used instead:</p>
+
+<div>
+<div>
+<pre class="source"> SELECT VALUE COUNT(gbu) FROM GleambookUsers gbu;
+</pre></div></div>
+
+<p>This time the result will simply be:</p>
+
+<div>
+<div>
+<pre class="source"> 10
+</pre></div></div>
+
+<p>In SQL++, aggregate functions can be applied to arbitrary collections, including subquery results. To illustrate, here is a less SQL-like—and also more explicit—way to express the query above:</p>
+
+<div>
+<div>
+<pre class="source"> SELECT VALUE ARRAY_COUNT((SELECT gbu FROM GleambookUsers gbu));
+</pre></div></div>
+
+<p>For each traditional SQL aggregate function <i>F</i>, SQL++ has a corresponding function <i>ARRAY_F</i> that can be used to perform the desired aggregate calculation. Each such function is a regular function that takes a collection-valued argument to aggregate over. Thus, the query above counts the results produced by the GleambookUsers subquery, and the previous, more SQL-like versions are just syntactic sugar for SQL++ queries that use <i>ARRAY_COUNT</i>. (Note: Subqueries in SQL++ must always be parenthesized.)</p></div>
+<div class="section">
+<h3><a name="Query_9-A_-_Grouping_and_Aggregation"></a>Query 9-A - Grouping and Aggregation</h3>
+<p>Also like SQL, SQL++ supports grouped aggregation. For every Chirp user, the following group-by/aggregate query counts the number of chirps sent by that user:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT uid AS user, COUNT(cm) AS count
+ FROM ChirpMessages cm
+ GROUP BY cm.user.screenName AS uid;
+</pre></div></div>
+
+<p>The <i>FROM</i> clause incrementally binds the variable <i>cm</i> to chirps, and the <i>GROUP BY</i> clause groups the chirps by their issuer’s Chirp screen-name. Unlike SQL, where data is tabular—flat—the data model underlying SQL++ allows for nesting. Thus, due to the <i>GROUP BY</i> clause, the <i>SELECT</i> clause in this query sees a sequence of <i>cm</i> groups, with each such group having an associated <i>uid</i> variable value (i.e., the chirping user’s screen name). In the context of the <i>SELECT</i> clause, <i>uid</i> is bound to the chirper’s id and <i>cm</i> is now re-bound (due to grouping) to the <i>set</i> of chirps issued by that chirper. The <i>SELECT</i> clause yields a result object containing the chirper’s user id and the count of the items in the associated chirp set. The query result will contain one such object per screen name. This query also illustrates another feature of SQL++; notice how each user’s screen name is accessed via a path syntax that traverses each chirp’s nested object structure.</p>
+<p>Here is the expected result for this query over the sample data:</p>
+
+<div>
+<div>
+<pre class="source"> { "user": "ChangEwing_573", "count": 1 }
+ { "user": "OliJackson_512", "count": 1 }
+ { "user": "ColineGeyer@63", "count": 3 }
+ { "user": "NathanGiesen@211", "count": 6 }
+ { "user": "NilaMilliron_tw", "count": 1 }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_9-B_-_.28Hash-Based.29_Grouping_and_Aggregation"></a>Query 9-B - (Hash-Based) Grouping and Aggregation</h3>
+<p>As for joins, AsterixDB has multiple evaluation strategies available for processing grouped aggregate queries. For grouped aggregation, the system knows how to employ both sort-based and hash-based aggregation methods, with sort-based methods being used by default and a hint being available to suggest that a different approach be used in processing a particular SQL++ query.</p>
+<p>The following query is similar to Query 9-A, but adds a hash-based aggregation hint:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT uid AS user, COUNT(cm) AS count
+ FROM ChirpMessages cm
+ /*+ hash */
+ GROUP BY cm.user.screenName AS uid;
+</pre></div></div>
+
+<p>Here is the expected result (the same result, but in a slightly different order):</p>
+
+<div>
+<div>
+<pre class="source"> { "user": "OliJackson_512", "count": 1 }
+ { "user": "ChangEwing_573", "count": 1 }
+ { "user": "ColineGeyer@63", "count": 3 }
+ { "user": "NathanGiesen@211", "count": 6 }
+ { "user": "NilaMilliron_tw", "count": 1 }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_10_-_Grouping_and_Limits"></a>Query 10 - Grouping and Limits</h3>
+<p>In some use cases it is not necessary to compute the entire answer to a query. In some cases, just having the first <i>N</i> or top <i>N</i> results is sufficient. This is expressible in SQL++ using the <i>LIMIT</i> clause combined with the <i>ORDER BY</i> clause.</p>
+<p>The following SQL++ query returns the top 3 Chirp users based on who has issued the most chirps:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ SELECT uid AS user, c AS count
+ FROM ChirpMessages cm
+ GROUP BY cm.user.screenName AS uid WITH c AS count(cm)
+ ORDER BY c DESC
+ LIMIT 3;
+</pre></div></div>
+
+<p>The expected result for this query is:</p>
+
+<div>
+<div>
+<pre class="source"> { "user": "NathanGiesen@211", "count": 6 }
+ { "user": "ColineGeyer@63", "count": 3 }
+ { "user": "ChangEwing_573", "count": 1 }
+</pre></div></div>
+</div>
+<div class="section">
+<h3><a name="Query_11_-_Left_Outer_Fuzzy_Join"></a>Query 11 - Left Outer Fuzzy Join</h3>
+<p>As a last example of SQL++ and its query power, the following query, for each chirp, finds all of the chirps that are similar based on the topics that they refer to:</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+ SET simfunction "jaccard";
+ SET simthreshold "0.3";
+
+ SELECT cm1 AS chirp,
+ (SELECT VALUE cm2.chirpId
+ FROM ChirpMessages cm2
+ WHERE cm2.referredTopics ~= cm1.referredTopics
+ AND cm2.chirpId > cm1.chirpId) AS similarChirps
+ FROM ChirpMessages cm1;
+</pre></div></div>
+
+<p>This query illustrates several things worth knowing in order to write fuzzy queries in SQL++. First, as mentioned earlier, SQL++ offers an operator-based syntax (as well as a functional approach, not shown) for seeing whether two values are “similar” to one another or not. Second, recall that the referredTopics field of objects of datatype ChirpMessageType is a bag of strings. This query sets the context for its similarity join by requesting that Jaccard-based similarity semantics (<a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">http://en.wikipedia.org/wiki/Jaccard_index</a>) be used for the query’s similarity operator and that a similarity index of 0.3 be used as its similarity threshold.</p>
+<p>The expected result for this fuzzy join query is:</p>
+
+<div>
+<div>
+<pre class="source"> { "chirp": { "chirpId": "11", "user": { "screenName": "NilaMilliron_tw", "lang": "en", "friendsCount": 445, "statusesCount": 164, "name": "Nila Milliron", "followersCount": 22649 }, "senderLocation": point("37.59,68.42"), "sendTime": datetime("2008-03-09T10:10:00.000Z"), "referredTopics": {{ "x-phone", "platform" }}, "messageText": " can't stand x-phone its platform is terrible" }, "similarChirps": [ "6", "7" ] }
+ { "chirp": { "chirpId": "2", "user": { "screenName": "ColineGeyer@63", "lang": "en", "friendsCount": 121, "statusesCount": 362, "name": "Coline Geyer", "followersCount": 17159 }, "senderLocation": point("32.84,67.14"), "sendTime": datetime("2010-05-13T10:10:00.000Z"), "referredTopics": {{ "ccast", "shortcut-menu" }}, "messageText": " like ccast its shortcut-menu is awesome:)" }, "similarChirps": [ "9", "8" ] }
+ { "chirp": { "chirpId": "3", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("29.72,75.8"), "sendTime": datetime("2006-11-04T10:10:00.000Z"), "referredTopics": {{ "product-w", "speed" }}, "messageText": " like product-w the speed is good:)" }, "similarChirps": [ "5" ] }
+ { "chirp": { "chirpId": "4", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("39.28,70.48"), "sendTime": datetime("2011-12-26T10:10:00.000Z"), "referredTopics": {{ "product-b", "voice-command" }}, "messageText": " like product-b the voice-command is mind-blowing:)" }, "similarChirps": [ ] }
+ { "chirp": { "chirpId": "6", "user": { "screenName": "ColineGeyer@63", "lang": "en", "friendsCount": 121, "statusesCount": 362, "name": "Coline Geyer", "followersCount": 17159 }, "senderLocation": point("47.51,83.99"), "sendTime": datetime("2010-05-07T10:10:00.000Z"), "referredTopics": {{ "x-phone", "voice-clarity" }}, "messageText": " like x-phone the voice-clarity is good:)" }, "similarChirps": [ ] }
+ { "chirp": { "chirpId": "7", "user": { "screenName": "ChangEwing_573", "lang": "en", "friendsCount": 182, "statusesCount": 394, "name": "Chang Ewing", "followersCount": 32136 }, "senderLocation": point("36.21,72.6"), "sendTime": datetime("2011-08-25T10:10:00.000Z"), "referredTopics": {{ "product-y", "platform" }}, "messageText": " like product-y the platform is good" }, "similarChirps": [ ] }
+ { "chirp": { "chirpId": "9", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("36.86,74.62"), "sendTime": datetime("2012-07-21T10:10:00.000Z"), "referredTopics": {{ "ccast", "voicemail-service" }}, "messageText": " love ccast its voicemail-service is awesome" }, "similarChirps": [ ] }
+ { "chirp": { "chirpId": "1", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("47.44,80.65"), "sendTime": datetime("2008-04-26T10:10:00.000Z"), "referredTopics": {{ "product-z", "customization" }}, "messageText": " love product-z its customization is good:)" }, "similarChirps": [ "8" ] }
+ { "chirp": { "chirpId": "10", "user": { "screenName": "ColineGeyer@63", "lang": "en", "friendsCount": 121, "statusesCount": 362, "name": "Coline Geyer", "followersCount": 17159 }, "senderLocation": point("29.15,76.53"), "sendTime": datetime("2008-01-26T10:10:00.000Z"), "referredTopics": {{ "ccast", "voice-clarity" }}, "messageText": " hate ccast its voice-clarity is OMG:(" }, "similarChirps": [ "2", "6", "9" ] }
+ { "chirp": { "chirpId": "12", "user": { "screenName": "OliJackson_512", "lang": "en", "friendsCount": 445, "statusesCount": 164, "name": "Oli Jackson", "followersCount": 22649 }, "senderLocation": point("24.82,94.63"), "sendTime": datetime("2010-02-13T10:10:00.000Z"), "referredTopics": {{ "product-y", "voice-command" }}, "messageText": " like product-y the voice-command is amazing:)" }, "similarChirps": [ "4", "7" ] }
+ { "chirp": { "chirpId": "5", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("40.09,92.69"), "sendTime": datetime("2006-08-04T10:10:00.000Z"), "referredTopics": {{ "product-w", "speed" }}, "messageText": " can't stand product-w its speed is terrible:(" }, "similarChirps": [ ] }
+ { "chirp": { "chirpId": "8", "user": { "screenName": "NathanGiesen@211", "lang": "en", "friendsCount": 39339, "statusesCount": 473, "name": "Nathan Giesen", "followersCount": 49416 }, "senderLocation": point("46.05,93.34"), "sendTime": datetime("2005-10-14T10:10:00.000Z"), "referredTopics": {{ "product-z", "shortcut-menu" }}, "messageText": " like product-z the shortcut-menu is awesome:)" }, "similarChirps": [ ] }
+</pre></div></div>
+</div></div>
+<div class="section">
+<h2><a name="Inserting_New_Data"></a>Inserting New Data</h2>
+<p>In addition to loading and querying data, AsterixDB supports incremental additions to datasets via the SQL++ <i>INSERT</i> statement.</p>
+<p>The following example adds a new chirp by user “NathanGiesen@211” to the ChirpMessages dataset. (An astute reader may notice that this chirp was issued a half an hour after his last chirp, so his counts have all gone up in the interim, although he appears not to have moved in the last half hour.)</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+
+ INSERT INTO ChirpMessages
+ (
+ {"chirpId": "13",
+ "user":
+ {"screenName": "NathanGiesen@211",
+ "lang": "en",
+ "friendsCount": 39345,
+ "statusesCount": 479,
+ "name": "Nathan Giesen",
+ "followersCount": 49420
+ },
+ "senderLocation": point("47.44,80.65"),
+ "sendTime": datetime("2008-04-26T10:10:35"),
+ "referredTopics": {{"chirping"}},
+ "messageText": "chirpy chirp, my fellow chirpers!"
+ }
+ );
+</pre></div></div>
+
+<p>In general, the data to be inserted may be specified using any valid SQL++ query expression. The insertion of a single object instance, as in this example, is just a special case where the query expression happens to be a object constructor involving only constants.</p>
+<div class="section">
+<h3><a name="Deleting_Existing_Data"></a>Deleting Existing Data</h3>
+<p>In addition to inserting new data, AsterixDB supports deletion from datasets via the SQL++ <i>DELETE</i> statement. The statement supports “searched delete” semantics, and its <i>WHERE</i> clause can involve any valid XQuery expression.</p>
+<p>The following example deletes the chirp that we just added from user “NathanGiesen@211”. (Easy come, easy go. :-))</p>
+
+<div>
+<div>
+<pre class="source"> USE TinySocial;
+ DELETE FROM ChirpMessages cm WHERE cm.chirpId = "13";
+</pre></div></div>
+
+<p>It should be noted that one form of data change not yet supported by AsterixDB is in-place data modification (<i>update</i>). Currently, only insert and delete operations are supported in SQL++; updates are not. To achieve the effect of an update, two SQL++ statements are currently needed—one to delete the old object from the dataset where it resides, and another to insert the new replacement object (with the same primary key but with different field values for some of the associated data content). AQL additionally supports an upsert operation to either insert a object, if no object with its primary key is currently present in the dataset, or to replace the existing object if one already exists with the primary key value being upserted. SQL++ will soon have <i>UPSERT</i> as well.</p></div>
+<div class="section">
+<h3><a name="Transaction_Support"></a>Transaction Support</h3>
+<p>AsterixDB supports object-level ACID transactions that begin and terminate implicitly for each object inserted, deleted, or searched while a given SQL++ statement is being executed. This is quite similar to the level of transaction support found in today’s NoSQL stores. AsterixDB does not support multi-statement transactions, and in fact an SQL++ statement that involves multiple objects can itself involve multiple independent object-level transactions. An example consequence of this is that, when an SQL++ statement attempts to insert 1000 objects, it is possible that the first 800 objects could end up being committed while the remaining 200 objects fail to be inserted. This situation could happen, for example, if a duplicate key exception occurs as the 801st insertion is attempted. If this happens, AsterixDB will report the error (e.g., a duplicate key exception) as the result of the offending SQL++ <i>INSERT</i> statement, and the application logic above will need to take the appropriate action(s) needed to assess the resulting state and to clean up and/or continue as appropriate.</p></div>
+<div class="section">
+<h3><a name="Loading_New_Data_in_Bulk"></a>Loading New Data in Bulk</h3>
+<p>In addition to incremental additions to datasets via the SQL++ <i>insert</i> statement, the <i>load</i> statement can be used to take a file from a given node and load it in a more efficient fashion. Note however that a dataset can currently only be loaded if it is empty.</p>
+<p>The following example loads a file in ADM format from “/home/user/gbm.adm” from the node named “nc1” into the GleambookUsers dataset.</p>
+
+<div>
+<div>
+<pre class="source">USE TinySocial;
+
+LOAD DATASET GleambookUsers USING localfs
+ (("path"="nc1://home/user/gbu.adm"),("format"="adm"));
+</pre></div></div>
+</div></div>
+<div class="section">
+<h2><a name="Further_Help"></a>Further Help</h2>
+<p>That’s it! You are now armed and dangerous with respect to semistructured data management using AsterixDB via SQL++. More information about SQL++ is available in the SQL++ Query Language (SQL++) reference document as well as in its companion SQL++ Functions document.</p>
+<p>AsterixDB is a powerful new BDMS—Big Data Management System—that we hope may usher in a new era of much more declarative Big Data management. AsterixDB is powerful, so use it wisely, and remember: “With great power comes great responsibility…” :-)</p>
+<p>Please e-mail the AsterixDB user group (users (at) asterixdb.apache.org) if you run into any problems or simply have further questions about the AsterixDB system, its features, or their proper use.</p></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>
diff --git a/docs/0.9.5/sqlpp/similarity.html b/docs/0.9.5/sqlpp/similarity.html
new file mode 100644
index 0000000..f0963b3
--- /dev/null
+++ b/docs/0.9.5/sqlpp/similarity.html
@@ -0,0 +1,293 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/sqlpp/similarity.md at 2020-07-30
+ | Rendered using Apache Maven Fluido Skin 1.7
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="Date-Revision-yyyymmdd" content="20200730" />
+ <meta http-equiv="Content-Language" content="en" />
+ <title>AsterixDB – AsterixDB Support of Similarity Queries</title>
+ <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
+ <link rel="stylesheet" href="../css/site.css" />
+ <link rel="stylesheet" href="../css/print.css" media="print" />
+ <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
+
+ </head>
+ <body class="topBarDisabled">
+ <div class="container-fluid">
+ <div id="banner">
+ <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
+ <div class="pull-right"></div>
+ <div class="clear"><hr/></div>
+ </div>
+
+ <div id="breadcrumbs">
+ <ul class="breadcrumb">
+ <li id="publishDate">Last Published: 2020-07-30</li>
+ <li id="projectVersion" class="pull-right">Version: 0.9.5-SNAPSHOT</li>
+ <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
+ </ul>
+ </div>
+ <div class="row-fluid">
+ <div id="leftColumn" class="span2">
+ <div class="well sidebar-nav">
+ <ul class="nav nav-list">
+ <li class="nav-header">Get Started - Installation</li>
+ <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
+ <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
+ <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
+ <li class="nav-header">AsterixDB Primer</li>
+ <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
+ <li class="nav-header">Data Model</li>
+ <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
+ <li class="nav-header">Queries</li>
+ <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
+ <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
+ <li class="nav-header">API/SDK</li>
+ <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
+ <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
+ <li class="nav-header">Advanced Features</li>
+ <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
+ <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
+ <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
+ <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
+ <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
+ <li class="active"><a href="#"><span class="none"></span>Support of Similarity Queries</a></li>
+ <li class="nav-header">Deprecated</li>
+ <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
+ <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
+ <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
+</ul>
+ <hr />
+ <div id="poweredBy">
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+ <div class="clear"></div>
+<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
+ </div>
+ </div>
+ </div>
+ <div id="bodyColumn" class="span10" >
+<!--
+ ! 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.
+ !-->
+<h1>AsterixDB Support of Similarity Queries</h1>
+<div class="section">
+<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
+<ul>
+
+<li><a href="#Motivation">Motivation</a></li>
+<li><a href="#DataTypesAndSimilarityFunctions">Data Types and Similarity Functions</a></li>
+<li><a href="#SimilaritySelectionQueries">Similarity Selection Queries</a></li>
+<li><a href="#SimilarityJoinQueries">Similarity Join Queries</a></li>
+<li><a href="#UsingIndexesToSupportSimilarityQueries">Using Indexes to Support Similarity Queries</a></li>
+</ul></div>
+<div class="section">
+<h2><a name="Motivation_.5BBack_to_TOC.5D"></a><a name="Motivation" id="Motivation">Motivation</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>Similarity queries are widely used in applications where users need to find objects that satisfy a similarity predicate, while exact matching is not sufficient. These queries are especially important for social and Web applications, where errors, abbreviations, and inconsistencies are common. As an example, we may want to find all the movies starring Schwarzenegger, while we don’t know the exact spelling of his last name (despite his popularity in both the movie industry and politics :-)). As another example, we want to find all the Facebook users who have similar friends. To meet this type of needs, AsterixDB supports similarity queries using efficient indexes and algorithms.</p></div>
+<div class="section">
+<h2><a name="Data_Types_and_Similarity_Functions_.5BBack_to_TOC.5D"></a><a name="DataTypesAndSimilarityFunctions" id="DataTypesAndSimilarityFunctions">Data Types and Similarity Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>AsterixDB supports <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> (on strings) and <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard</a> (on sets). For instance, in our <a href="../sqlpp/primer-sqlpp.html#ADM:_Modeling_Semistructured_Data_in_AsterixDB">TinySocial</a> example, the <tt>friendIds</tt> of a Gleambook user forms a set of friends, and we can define a similarity between the sets of friends of two users. We can also convert a string to a set of grams of a length “n” (called “n-grams”) and define the Jaccard similarity between the two gram sets of the two strings. Formally, the “n-grams” of a string are its substrings of length “n”. For instance, the 3-grams of the string <tt>schwarzenegger</tt> are <tt>sch</tt>, <tt>chw</tt>, <tt>hwa</tt>, …, <tt>ger</tt>.</p>
+<p>AsterixDB provides <a href="../sqlpp/builtins.html#Tokenizing_Functions">tokenization functions</a> to convert strings to sets, and the <a href="../sqlpp/builtins.html#Similarity_Functions">similarity functions</a>.</p></div>
+<div class="section">
+<h2><a name="Similarity_Selection_Queries_.5BBack_to_TOC.5D"></a><a name="SimilaritySelectionQueries" id="SimilaritySelectionQueries">Similarity Selection Queries</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>The following query asks for all the Gleambook users whose name is similar to <tt>Suzanna Tilson</tt>, i.e., their edit distance is at most 2.</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where edit_distance(u.name, "Suzanna Tilson") <= 2;
+</pre></div></div>
+
+<p>The following query asks for all the Gleambook users whose set of friend ids is similar to <tt>[1,5,9,10]</tt>, i.e., their Jaccard similarity is at least 0.6.</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where similarity_jaccard(u.friendIds, [1,5,9,10]) >= 0.6f;
+</pre></div></div>
+
+<p>AsterixDB allows a user to use a similarity operator <tt>~=</tt> to express a condition by defining the similarity function and threshold using “set” statements earlier. For instance, the above query can be equivalently written as:</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ set simfunction "jaccard";
+ set simthreshold "0.6f";
+
+ select u
+ from GleambookUsers u
+ where u.friendIds ~= [1,5,9,10];
+</pre></div></div>
+
+<p>In this query, we first declare Jaccard as the similarity function using <tt>simfunction</tt> and then specify the threshold <tt>0.6f</tt> using <tt>simthreshold</tt>.</p></div>
+<div class="section">
+<h2><a name="Similarity_Join_Queries_.5BBack_to_TOC.5D"></a><a name="SimilarityJoinQueries" id="SimilarityJoinQueries">Similarity Join Queries</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>AsterixDB supports fuzzy joins between two sets. The following <a href="../sqlpp/primer-sqlpp.html#Query_5_-_Fuzzy_Join">query</a> finds, for each Gleambook user, all Chirp users with names similar to their name based on the edit distance.</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ set simfunction "edit-distance";
+ set simthreshold "3";
+
+ select gbu.id, gbu.name, (select cu.screenName, cu.name
+ from ChirpUsers cu
+ where cu.name ~= gbu.name) as similar_users
+ from GleambookUsers gbu;
+</pre></div></div>
+</div>
+<div class="section">
+<h2><a name="Using_Indexes_to_Support_Similarity_Queries_.5BBack_to_TOC.5D"></a><a name="UsingIndexesToSupportSimilarityQueries" id="UsingIndexesToSupportSimilarityQueries">Using Indexes to Support Similarity Queries</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<p>AsterixDB uses two types of indexes to support similarity queries, namely “ngram index” and “keyword index”.</p>
+<div class="section">
+<h3><a name="NGram_Index"></a>NGram Index</h3>
+<p>An “ngram index” is constructed on a set of strings. We generate n-grams for each string, and build an inverted list for each n-gram that includes the ids of the strings with this gram. A similarity query can be answered efficiently by accessing the inverted lists of the grams in the query and counting the number of occurrences of the string ids on these inverted lists. The similar idea can be used to answer queries with Jaccard similarity. A detailed description of these techniques is available at this <a class="externalLink" href="http://www.ics.uci.edu/~chenli/pub/icde2009-memreducer.pdf">paper</a>.</p>
+<p>For instance, the following DDL statements create an ngram index on the <tt>GleambookUsers.name</tt> attribute using an inverted index of 3-grams.</p>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ create index gbUserIdx on GleambookUsers(name) type ngram(3);
+</pre></div></div>
+
+<p>The number “3” in “ngram(3)” is the length “n” in the grams. This index can be used to optimize similarity queries on this attribute using <a href="../sqlpp/builtins.html#edit_distance">edit_distance</a>, <a href="../sqlpp/builtins.html#edit_distance_check">edit_distance_check</a>, <a href="../sqlpp/builtins.html#similarity_jaccard">similarity_jaccard</a>, or <a href="../sqlpp/builtins.html#similarity_jaccard_check">similarity_jaccard_check</a> queries on this attribute where the similarity is defined on sets of 3-grams. This index can also be used to optimize queries with the “<a href="(../sqlpp/builtins.html#contains">contains()</a>” predicate (i.e., substring matching) since it can be also be solved by counting on the inverted lists of the grams in the query string.</p>
+<div class="section">
+<h4><a name="NGram_Index_usage_case_-_edit_distance"></a>NGram Index usage case - <a href="../sqlpp/builtins.html#edit-distance">edit_distance</a></h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where edit_distance(u.name, "Suzanna Tilson") <= 2;
+</pre></div></div>
+</div>
+<div class="section">
+<h4><a name="NGram_Index_usage_case_-_edit_distance_check"></a>NGram Index usage case - <a href="../sqlpp/builtins.html#edit_distance_check">edit_distance_check</a></h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where edit_distance_check(u.name, "Suzanna Tilson", 2)[0];
+</pre></div></div>
+</div>
+<div class="section">
+<h4><a name="NGram_Index_usage_case_-_contains.28.29"></a>NGram Index usage case - <a href="(../sqlpp/builtins.html#contains">contains()</a></h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select m
+ from GleambookMessages m
+ where contains(m.message, "phone");
+</pre></div></div>
+</div></div>
+<div class="section">
+<h3><a name="Keyword_Index"></a>Keyword Index</h3>
+<p>A “keyword index” is constructed on a set of strings or sets (e.g., array, multiset). Instead of generating grams as in an ngram index, we generate tokens (e.g., words) and for each token, construct an inverted list that includes the ids of the objects with this token. The following two examples show how to create keyword index on two different types:</p>
+<div class="section">
+<h4><a name="Keyword_Index_on_String_Type"></a>Keyword Index on String Type</h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ drop index GleambookMessages.gbMessageIdx if exists;
+ create index gbMessageIdx on GleambookMessages(message) type keyword;
+
+ select m
+ from GleambookMessages m
+ where similarity_jaccard_check(word_tokens(m.message), word_tokens("love like ccast"), 0.2f)[0];
+</pre></div></div>
+</div>
+<div class="section">
+<h4><a name="Keyword_Index_on_Multiset_Type"></a>Keyword Index on Multiset Type</h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ create index gbUserIdxFIds on GleambookUsers(friendIds) type keyword;
+
+ select u
+ from GleambookUsers u
+ where similarity_jaccard_check(u.friendIds, {{3,10}}, 0.5f)[0];
+</pre></div></div>
+
+<p>As shown above, keyword index can be used to optimize queries with token-based similarity predicates, including <a href="../sqlpp/builtins.html#similarity_jaccard">similarity_jaccard</a> and <a href="../sqlpp/builtins.html#similarity_jaccard_check">similarity_jaccard_check</a>.</p></div>
+<div class="section">
+<h4><a name="Keyword_Index_usage_case_-_similarity_jaccard"></a>Keyword Index usage case - <a href="../sqlpp/builtins.html#similarity_jaccard">similarity_jaccard</a></h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where similarity_jaccard(u.friendIds, [1,5,9,10]) >= 0.6f;
+</pre></div></div>
+</div>
+<div class="section">
+<h4><a name="Keyword_Index_usage_case_-_similarity_jaccard_check"></a>Keyword Index usage case - <a href="../sqlpp/builtins.html#similarity_jaccard_check">similarity_jaccard_check</a></h4>
+
+<div>
+<div>
+<pre class="source"> use TinySocial;
+
+ select u
+ from GleambookUsers u
+ where similarity_jaccard_check(u.friendIds, [1,5,9,10], 0.6f)[0];
+</pre></div></div></div></div></div>
+ </div>
+ </div>
+ </div>
+ <hr/>
+ <footer>
+ <div class="container-fluid">
+ <div class="row-fluid">
+<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
+ feather logo, and the Apache AsterixDB project logo are either
+ registered trademarks or trademarks of The Apache Software
+ Foundation in the United States and other countries.
+ All other marks mentioned may be trademarks or registered
+ trademarks of their respective owners.
+ </div>
+ </div>
+ </div>
+ </footer>
+ </body>
+</html>