Add 0.9.1 Documentation

Change-Id: Ib852cde3e959f61fc2c95650535353c0b137c842
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1701
Reviewed-by: Xikui Wang <xkkwww@gmail.com>
diff --git a/content/docs/0.9.1/sqlpp/builtins.html b/content/docs/0.9.1/sqlpp/builtins.html
new file mode 100644
index 0000000..8d9e75d
--- /dev/null
+++ b/content/docs/0.9.1/sqlpp/builtins.html
@@ -0,0 +1,8593 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at 2017-04-24
+ | Rendered using Apache Maven Fluido Skin 1.3.0
+-->
+<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="20170424" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>AsterixDB &#x2013; Builtin Functions</title>
+    <link rel="stylesheet" href="../css/apache-maven-fluido-1.3.0.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.3.0.min.js"></script>
+
+                          
+        
+<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+        ga('create', 'UA-41536543-1', 'uci.edu');
+        ga('send', 'pageview');</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: 2017-04-24</li>
+                      
+                
+                    
+                 <li id="projectVersion" class="pull-right">Version: 0.9.1</li>
+      
+                                            <li class="divider pull-right">|</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="span3">
+          <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">
+          <i class="none"></i>
+        Option 1: using NCService</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../ansible.html" title="Option 2: using Ansible">
+          <i class="none"></i>
+        Option 2: using Ansible</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aws.html" title="Option 3: using Amazon Web Services">
+          <i class="none"></i>
+        Option 3: using Amazon Web Services</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../yarn.html" title="Option 4: using YARN">
+          <i class="none"></i>
+        Option 4: using YARN</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../install.html" title="Option 5: using Managix (deprecated)">
+          <i class="none"></i>
+        Option 5: using Managix (deprecated)</a>
+            </li>
+                              <li class="nav-header">AsterixDB Primer</li>
+                                
+      <li>
+    
+                          <a href="../sqlpp/primer-sqlpp.html" title="Option 1: using SQL++">
+          <i class="none"></i>
+        Option 1: using SQL++</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/primer.html" title="Option 2: using AQL">
+          <i class="none"></i>
+        Option 2: using AQL</a>
+            </li>
+                              <li class="nav-header">Data Model</li>
+                                
+      <li>
+    
+                          <a href="../datamodel.html" title="The Asterix Data Model">
+          <i class="none"></i>
+        The Asterix Data Model</a>
+            </li>
+                              <li class="nav-header">Queries - SQL++</li>
+                                
+      <li>
+    
+                          <a href="../sqlpp/manual.html" title="The SQL++ Query Language">
+          <i class="none"></i>
+        The SQL++ Query Language</a>
+            </li>
+                  
+      <li class="active">
+    
+            <a href="#"><i class="none"></i>Builtin Functions</a>
+          </li>
+                              <li class="nav-header">Queries - AQL</li>
+                                
+      <li>
+    
+                          <a href="../aql/manual.html" title="The Asterix Query Language (AQL)">
+          <i class="none"></i>
+        The Asterix Query Language (AQL)</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/builtins.html" title="Builtin Functions">
+          <i class="none"></i>
+        Builtin Functions</a>
+            </li>
+                              <li class="nav-header">API/SDK</li>
+                                
+      <li>
+    
+                          <a href="../api.html" title="HTTP API">
+          <i class="none"></i>
+        HTTP API</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../csv.html" title="CSV Output">
+          <i class="none"></i>
+        CSV Output</a>
+            </li>
+                              <li class="nav-header">Advanced Features</li>
+                                
+      <li>
+    
+                          <a href="../aql/fulltext.html" title="Support of Full-text Queries">
+          <i class="none"></i>
+        Support of Full-text Queries</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/externaldata.html" title="Accessing External Data">
+          <i class="none"></i>
+        Accessing External Data</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../feeds/tutorial.html" title="Support for Data Ingestion">
+          <i class="none"></i>
+        Support for Data Ingestion</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../udf.html" title="User Defined Functions">
+          <i class="none"></i>
+        User Defined Functions</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
+          <i class="none"></i>
+        Filter-Based LSM Index Acceleration</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/similarity.html" title="Support of Similarity Queries">
+          <i class="none"></i>
+        Support of Similarity Queries</a>
+            </li>
+            </ul>
+                
+                    
+                
+          <hr class="divider" />
+
+           <div id="poweredBy">
+                            <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="span9" >
+                                  
+            <!-- ! 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>
+<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="#MiscFunctions">Miscellaneous Functions</a></li>
+</ul>
+<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. <!-- ! 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 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: abs(2013), &quot;v2&quot;: abs(-4036), &quot;v3&quot;: abs(0), &quot;v4&quot;: abs(float(&quot;-2013.5&quot;)), &quot;v5&quot;: abs(double(&quot;-2013.593823748327284&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: 4036, &quot;v3&quot;: 0, &quot;v4&quot;: 2013.5, &quot;v5&quot;: 2013.5938237483274 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="acos"></a>acos</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: acos(1), &quot;v2&quot;: acos(2), &quot;v3&quot;: acos(0), &quot;v4&quot;: acos(float(&quot;0.5&quot;)), &quot;v5&quot;: acos(double(&quot;-0.5&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: NaN, &quot;v3&quot;: 1.5707963267948966, &quot;v4&quot;: 1.0471975511965979, &quot;v5&quot;: 2.0943951023931957 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="asin"></a>asin</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: asin(1), &quot;v2&quot;: asin(2), &quot;v3&quot;: asin(0), &quot;v4&quot;: asin(float(&quot;0.5&quot;)), &quot;v5&quot;: asin(double(&quot;-0.5&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1.5707963267948966, &quot;v2&quot;: NaN, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5235987755982989, &quot;v5&quot;: -0.5235987755982989 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="atan"></a>atan</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: atan(1), &quot;v2&quot;: atan(2), &quot;v3&quot;: atan(0), &quot;v4&quot;: atan(float(&quot;0.5&quot;)), &quot;v5&quot;: atan(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.7853981633974483, &quot;v2&quot;: 1.1071487177940904, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.4636476090008061, &quot;v5&quot;: 1.5697963271282298 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="atan2"></a>atan2</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: atan2(1, 2), &quot;v2&quot;: atan2(0, 4), &quot;v3&quot;: atan2(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="ceil"></a>ceil</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: ceil(2013),
+  &quot;v2&quot;: ceil(-4036),
+  &quot;v3&quot;: ceil(0.3),
+  &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
+  &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2013.0 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="cos"></a>cos</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: cos(1), &quot;v2&quot;: cos(2), &quot;v3&quot;: cos(0), &quot;v4&quot;: cos(float(&quot;0.5&quot;)), &quot;v5&quot;: cos(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.5403023058681398, &quot;v2&quot;: -0.4161468365471424, &quot;v3&quot;: 1.0, &quot;v4&quot;: 0.8775825618903728, &quot;v5&quot;: 0.562379076290703 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="exp"></a>exp</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: exp(1), &quot;v2&quot;: exp(2), &quot;v3&quot;: exp(0), &quot;v4&quot;: exp(float(&quot;0.5&quot;)), &quot;v5&quot;: exp(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2.718281828459045, &quot;v2&quot;: 7.38905609893065, &quot;v3&quot;: 1.0, &quot;v4&quot;: 1.6487212707001282, &quot;v5&quot;: Infinity }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="floor"></a>floor</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: floor(2013),
+  &quot;v2&quot;: floor(-4036),
+  &quot;v3&quot;: floor(0.8),
+  &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
+  &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 0.0, &quot;v4&quot;: -2014.0, &quot;v5&quot;: -2014.0 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="ln"></a>ln</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: ln(1), &quot;v2&quot;: ln(2), &quot;v3&quot;: ln(0), &quot;v4&quot;: ln(float(&quot;0.5&quot;)), &quot;v5&quot;: ln(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.6931471805599453, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -0.6931471805599453, &quot;v5&quot;: 6.907755278982137 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="log"></a>log</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: log(1), &quot;v2&quot;: log(2), &quot;v3&quot;: log(0), &quot;v4&quot;: log(float(&quot;0.5&quot;)), &quot;v5&quot;: log(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.3010299956639812, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -0.3010299956639812, &quot;v5&quot;: 3.0 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="power"></a>power</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: power(1, 2), &quot;v3&quot;: power(0, 4), &quot;v4&quot;: power(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="round"></a>round</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>round(numeric_value)
+</pre></div></div></li>
+  
+<li>
+<p>Computes the number with no fractional part that is closest (and also closest to positive infinity) to 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 rounded 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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: round(2013),
+  &quot;v2&quot;: round(-4036),
+  &quot;v3&quot;: round(0.8),
+  &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
+  &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: round_half_to_even(2013),
+  &quot;v2&quot;: round_half_to_even(-4036),
+  &quot;v3&quot;: round_half_to_even(0.8),
+  &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
+  &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
+  &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
+  &quot;v7&quot;: round_half_to_even(2013, 4),
+  &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0, &quot;v6&quot;: -2013.89, &quot;v7&quot;: 2013, &quot;v8&quot;: -2013.256 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sign"></a>sign</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: sign(1), &quot;v2&quot;: sign(2), &quot;v3&quot;: sign(0), &quot;v4&quot;: sign(float(&quot;0.5&quot;)), &quot;v5&quot;: sign(double(&quot;-1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sin"></a>sin</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: sin(1), &quot;v2&quot;: sin(2), &quot;v3&quot;: sin(0), &quot;v4&quot;: sin(float(&quot;0.5&quot;)), &quot;v5&quot;: sin(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0.8414709848078965, &quot;v2&quot;: 0.9092974268256817, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.479425538604203, &quot;v5&quot;: 0.8268795405320025 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sqrt"></a>sqrt</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: sqrt(1), &quot;v2&quot;: sqrt(2), &quot;v3&quot;: sqrt(0), &quot;v4&quot;: sqrt(float(&quot;0.5&quot;)), &quot;v5&quot;: sqrt(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1.0, &quot;v2&quot;: 1.4142135623730951, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.7071067811865476, &quot;v5&quot;: 31.622776601683793 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="tan"></a>tan</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: tan(1), &quot;v2&quot;: tan(2), &quot;v3&quot;: tan(0), &quot;v4&quot;: tan(float(&quot;0.5&quot;)), &quot;v5&quot;: tan(double(&quot;1000&quot;)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1.5574077246549023, &quot;v2&quot;: -2.185039863261519, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5463024898437905, &quot;v5&quot;: 1.4703241557027185 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="trunc"></a>trunc</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: trunc(1, 1), &quot;v2&quot;: trunc(2, -2), &quot;v3&quot;: trunc(0.122, 2), &quot;v4&quot;: trunc(float(&quot;11.52&quot;), -1), &quot;v5&quot;: trunc(double(&quot;1000.5252&quot;), 3) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: 2, &quot;v3&quot;: 0.12, &quot;v4&quot;: 10.0, &quot;v5&quot;: 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>
+<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 class="source">
+<div class="source">
+<pre>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>&#x2026;.</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 class="source">
+<div class="source">
+<pre>concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;test driven development&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="contains"></a>contains</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: contains(&quot;I like x-phone&quot;, &quot;phone&quot;), &quot;v2&quot;: contains(&quot;one&quot;, &quot;phone&quot;) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
+  &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="initcap_or_title"></a>initcap (or title)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 &#x201c;title&#x201d;.</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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="length"></a>length</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>length(&quot;test string&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>11
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="lower"></a>lower</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>lower(&quot;ASTERIXDB&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;asterixdb&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="ltrim"></a>ltrim</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; like x-phone&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="position"></a>position</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>position(string, string_pattern)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>.</p></li>
+  
+<li>Arguments:
+  
+<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>,  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 cause a type error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
+  &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 2, &quot;v2&quot;: -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 class="source">
+<div class="source">
+<pre>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>Arguments:
+  
+<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>,</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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
+  &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
+}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: 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 class="source">
+<div class="source">
+<pre>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>Arguments:
+  
+<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>,</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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
+  &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: 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 class="source">
+<div class="source">
+<pre>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>.</p></li>
+  
+<li>Arguments:
+  
+<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>,  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 cause a type error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
+  &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 0, &quot;v2&quot;: -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 class="source">
+<div class="source">
+<pre>regexp_replace(string, string_pattern, string_replacement[, string_flags])
+</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 replace the matched pattern <tt>string_pattern</tt> with the new pattern <tt>string_replacement</tt>.</p></li>
+  
+<li>Arguments:
+  
+<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>
+  </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 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 class="source">
+<div class="source">
+<pre>regexp_replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;like product-a the voicemail_service is awesome&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="repeat"></a>repeat</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>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>.</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 class="source">
+<div class="source">
+<pre>repeat(&quot;test&quot;, 3);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;testtesttest&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="rtrim"></a>rtrim</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
+  &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like &quot; }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="split"></a>split</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>split(&quot;test driven development&quot;, &quot; &quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="starts_with"></a>starts_with</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
+  &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="string_concat"></a>string_concat</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;ASTERIX ROCKS!&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="string_join"></a>string_join</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;ASTERIX!! ROCKS~&quot;
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>string_to_codepoint(&quot;Hello ASTERIX!&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;Hello ASTERIX!&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="substr"></a>substr</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>.</p></li>
+  
+<li>Arguments:
+  
+<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>,</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,</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>
+      
+<li>or, 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 class="source">
+<div class="source">
+<pre>substr(&quot;test string&quot;, 6, 3);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;str&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="substring_before"></a>substring_before</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; like &quot;
+</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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;one&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="trim"></a>trim</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; like &quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="upper"></a>upper</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>upper(&quot;hello&quot;)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;HELLO&quot;
+</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(&#x201c;ABCDEF0123456789&#x201d;,&#x201c;hex&#x201d;), parse_binary(&#x201c;abcdef0123456789&#x201d;,&#x201c;HEX&#x201d;), parse_binary(&#x2018;QXN0ZXJpeAE=&#x2019;,&#x201c;base64&#x201d;) ];</p></li>
+  
+<li>
+<p>The expected result is:</p>
+<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</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 class="source">
+<div class="source">
+<pre>[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
+</pre></div></div></li>
+  
+<li>
+<p>The expected result are:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
+</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 class="source">
+<div class="source">
+<pre>binary_length(hex(&quot;00AA&quot;))
+</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>,</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 class="source">
+<div class="source">
+<pre>sub_binary(hex(&quot;AABBCCDD&quot;), 4);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is</p>
+  
+<div class="source">
+<div class="source">
+<pre>hex(&quot;DD&quot;)
+</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(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p></li>
+  
+<li>
+<p>The expected result is</p>
+<p>hex(&#x201c;4242&#x201d;)</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;point&quot;: create_point(30.0,70.0) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="create_line"></a>create_line</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="create_rectangle"></a>create_rectangle</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="create_circle"></a>create_circle</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="create_polygon"></a>create_polygon</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;polygon&quot;: polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="get_xget_y"></a>get_x/get_y</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;x_coordinate&quot;: get_x(create_point(2.3,5.0)), &quot;y_coordinate&quot;: get_y(create_point(2.3,5.0)) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ point(&quot;1.0,1.0&quot;), point(&quot;2.0,2.0&quot;), point(&quot;3.0,3.0&quot;), point(&quot;4.0,4.0&quot;) ]
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="get_centerget_radius"></a>get_center/get_radius</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
+  &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="spatial_distance"></a>spatial_distance</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>spatial_area(create_circle(create_point(0.0,0.0), 5.0));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>spatial_intersect(point(&quot;39.28,70.48&quot;), create_rectangle(create_point(30.0,70.0), create_point(40.0,80.0)));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
+</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 class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 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 class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 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 class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>similarity_jaccard([1,5,8,9], [1,5,9,10]);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 &#x201c;check&#x201d; version of Jaccard is faster than the &#x201c;non_check&#x201d; 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:  * the first or second argument is any other non-array value,  * or, the third argument is any other non-double value.</li>
+  </ul></li>
+  
+<li>
+<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>word_tokens(&quot;I like the phone, awesome!&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
+</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_yearget_monthget_dayget_hourget_minuteget_secondget_millisecond"></a>get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
+  &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
+  &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
+  &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
+  &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
+  &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
+  &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;year&quot;: 2010, &quot;month&quot;: 11, &quot;day&quot;: 30, &quot;hour&quot;: 5, &quot;min&quot;: 28, &quot;second&quot;: 23, &quot;ms&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;2008-04-26T18:10:00.000+08:00&quot;
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;18:10:00.000+08:00&quot;
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>calendar_duration_from_datetime(
+      datetime(&quot;2016-03-26T10:10:00&quot;),
+      datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
+);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>duration(&quot;P5Y2M24DT10H10M&quot;)
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="get_year_month_durationget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>year_month_duration(&quot;P1Y&quot;)
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="months_from_year_month_durationmilliseconds_from_day_time_duration"></a>months_from_year_month_duration/milliseconds_from_day_time_duration</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>months_from_year_month_duration/milliseconds_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>an <tt>bigint</tt> representing the number or 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 class="source">
+<div class="source">
+<pre>months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;)));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>67
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="duration_from_monthsduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>duration_from_months(8);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>duration(&quot;P8M&quot;)
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
+  &quot;dr2&quot; : duration_from_interval(interval(datetime(&quot;2012-06-26T01:01:01.111&quot;), datetime(&quot;2012-07-27T02:02:02.222&quot;))),
+  &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
+  &quot;dr4&quot; : duration_from_interval(null)
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
+  &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
+  &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
+  &quot;dr4&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>time(&quot;10:10:00.000Z&quot;)
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;date&quot;: date_from_unix_time_in_days(15800),
+  &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
+  &quot;time&quot;: time_from_unix_time_in_ms(3748)
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;date&quot;: date_from_unix_time_in_days(15800),
+  &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
+  &quot;time&quot;: time_from_unix_time_in_ms(3748)
+}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="parse_dateparse_timeparse_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 class="source">
+<div class="source">
+<pre>parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>time(&quot;00:30:30.000Z&quot;)
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="print_dateprint_timeprint_datetime"></a>print_date/print_time/print_datetime</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;30:30&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="get_interval_start_get_interval_end"></a>get_interval_start, get_interval_end</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
+  &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="get_interval_start_dateget_interval_start_datetimeget_interval_start_time_get_interval_end_dateget_interval_end_datetimeget_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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
+  &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
+  &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
+  &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
+  &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
+  &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;start1&quot;: date(&quot;1984-01-01&quot;),
+  &quot;end1&quot;: date(&quot;1985-01-01&quot;),
+  &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
+  &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
+  &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
+  &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
+}
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;overlap1&quot;: get_overlapping_interval(interval(time(&quot;11:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;12:23:39&quot;), time(&quot;23:18:00&quot;))),
+  &quot;overlap2&quot;: get_overlapping_interval(interval(time(&quot;12:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;07:19:39&quot;), time(&quot;09:18:00&quot;))),
+  &quot;overlap3&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;1999-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
+  &quot;overlap4&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;2099-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
+  &quot;overlap5&quot;: get_overlapping_interval(interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2009-10-10T23:18:00&quot;))),
+  &quot;overlap6&quot;: get_overlapping_interval(interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;1888-10-10T23:18:00&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
+  &quot;overlap2&quot;: null,
+  &quot;overlap3&quot;: null,
+  &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
+  &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
+  &quot;overlap6&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
+  &quot;bin2&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;1990-01-01T00:00:00.000Z&quot;), year_month_duration(&quot;P6M&quot;)),
+  &quot;bin3&quot;: interval_bin(time(&quot;12:23:34.930+07:00&quot;), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT1M&quot;)),
+  &quot;bin4&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;2013-01-01T00:00:00.000&quot;), day_time_duration(&quot;PT24H&quot;))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
+  &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
+  &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
+  &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
+}
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_start_from_datetimedatetime"></a>interval_start_from_date/time/datetime</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
+  &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
+  &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expectecd result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
+  &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
+  &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
+}
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;timebins&quot;: overlap_bins(interval(time(&quot;17:23:37&quot;), time(&quot;18:30:21&quot;)), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT30M&quot;)),
+  &quot;datebins&quot;: overlap_bins(interval(date(&quot;1984-03-17&quot;), date(&quot;2013-08-22&quot;)), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P10Y&quot;)),
+  &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
+                              datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;timebins&quot;: [
+                interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
+                interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
+                interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
+                interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
+              ],
+  &quot;datebins&quot;: [
+                interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
+                interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
+                interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
+                interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
+              ],
+  &quot;datetimebins&quot;: [
+                    interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
+                    interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
+                    interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
+                   ]
+};
+</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_interval_after"></a>interval_before, interval_after</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 &lt; interval2.start</tt>, and <tt>interval_after(interval1, interval2)</tt> is true  if and only if <tt>interval1.start &gt; 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 class="source">
+<div class="source">
+<pre>{
+  &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                     interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
+  &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
+                                   interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_covers_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Return Value:</p>
+  
+<ul>
+    
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</li>
+  </ul>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end
+
+`interval_covered_by(interval1, interval2)` is true if and only if
+
+interval2.start &lt;= interval1.start AND interval2.end &gt;= 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 class="source">
+<div class="source">
+<pre>{
+  &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                     interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
+  &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                                             interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_overlaps_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Return Value:</p>
+  
+<ul>
+    
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if</li>
+  </ul>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.start &lt; interval2.start
+AND interval2.end &gt; interval1.end
+AND interval1.end &gt; interval2.start
+</pre></div></div>
+<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
+  
+<div class="source">
+<div class="source">
+<pre>interval2.start &lt; interval1.start
+AND interval1.end &gt; interval2.end
+AND interval2.end &gt; 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&#x2019;s relations on the definition of overlap.</p></li>
+  
+<li>
+<p>Examples:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
+  &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                                          interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: 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&#x2019;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 class="source">
+<div class="source">
+<pre>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>
+<p>Return Value:</p>
+  
+<ul>
+    
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</li>
+  </ul>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.start &lt; interval2.end
+AND interval1.end &gt; interval2.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></li>
+  
+<li>
+<p>Examples:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                       interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
+  &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                                       interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_meets_interval_met_by"></a>interval_meets, interval_met_by</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                          interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
+  &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                           interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;meets&quot;: true, &quot;metby&quot;: true }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_starts_interval_started_by"></a>interval_starts, interval_started_by</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Return Value:</p>
+  
+<ul>
+    
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if</li>
+  </ul>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.start = interval2.start
+AND interval1.end &lt;= interval2.end
+</pre></div></div>
+<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.start = interval2.start
+AND interval2.end &lt;= 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 class="source">
+<div class="source">
+<pre>{
+  &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                     interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
+  &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                                             interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="interval_ends_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Return Value:</p>
+  
+<ul>
+    
+<li>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</li>
+  </ul>
+  
+<div class="source">
+<div class="source">
+<pre>interval1.end = interval2.end
+AND interval1.start &gt;= interval2.start
+
+`interval_ended_by(interval1, interval2)` returns true if and only if
+
+interval2.end = interval1.end
+AND interval2.start &gt;= 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></li>
+  
+<li>
+<p>Examples:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
+                                 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
+  &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
+                                         interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
+};
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>get_object_fields(
+                  {
+                    &quot;id&quot;: 1,
+                    &quot;project&quot;: &quot;AsterixDB&quot;,
+                    &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
+                    &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+                  }
+                 );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[
+  { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
+  { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
+  { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
+    &quot;nested&quot;: [
+                { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
+                { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
+              ]
+  },
+  { &quot;field-name&quot;:
+        &quot;related&quot;,
+        &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
+        &quot;is-open&quot;: false,
+        &quot;list&quot;: [
+                  { &quot;field-type&quot;: &quot;STRING&quot; },
+                  { &quot;field-type&quot;: &quot;STRING&quot; },
+                  { &quot;field-type&quot;: &quot;STRING&quot; }
+                ]
+  }
+]
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>get_object_field_value({
+                         &quot;id&quot;: 1,
+                         &quot;project&quot;: &quot;AsterixDB&quot;,
+                         &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
+                         &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+                        },
+                        &quot;project&quot;
+                       );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;AsterixDB&quot;
+</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 class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>object_remove_fields(
+                       {
+                         &quot;id&quot;:1,
+                         &quot;project&quot;:&quot;AsterixDB&quot;,
+                         &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
+                         &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+                       },
+                       [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
+                     );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;id&quot;:1,
+  &quot;project&quot;:&quot;AsterixDB&quot;,
+  &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
+}
+</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 class="source">
+<div class="source">
+<pre>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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>object_add_fields(
+                   {
+                     &quot;id&quot;:1,
+                     &quot;project&quot;:&quot;AsterixDB&quot;,
+                     &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
+                     &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+                    },
+                    [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
+                  );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+   &quot;id&quot;:1,
+   &quot;project&quot;:&quot;AsterixDB&quot;,
+   &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
+   &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+   &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
+ }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="object_merge"></a>object_merge</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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&#x2019;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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>object_merge(
+              {
+                &quot;id&quot;:1,
+                &quot;project&quot;:&quot;AsterixDB&quot;,
+                &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
+                &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+              },
+              {
+                &quot;user_id&quot;: 22,
+                &quot;employer&quot;: &quot;UC Irvine&quot;,
+                &quot;employment_type&quot;: &quot;visitor&quot;
+              }
+            );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+  &quot;employment_type&quot;: &quot;visitor&quot;,
+  &quot;address&quot;: {
+    &quot;city&quot;: &quot;Irvine&quot;,
+    &quot;state&quot;: &quot;CA&quot;
+  },
+  &quot;related&quot;: [
+    &quot;Hivestrix&quot;,
+    &quot;Preglix&quot;,
+    &quot;Apache VXQuery&quot;
+  ],
+  &quot;user_id&quot;: 22,
+  &quot;project&quot;: &quot;AsterixDB&quot;,
+  &quot;employer&quot;: &quot;UC Irvine&quot;,
+  &quot;id&quot;: 1
+}
+</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_Array_Functions"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
+<p>A high-level description of SQL++ aggregate functions can be found at <a href="manual.html#Aggregation_functions">here</a>. As SQL++ supports all legitimate SQL GROUP BY and Aggregation queries, <a href="manual.html#SQL-92_aggregation_functions">here</a> is a description of how standard SQL aggregation functions are supported.</p>
+<p>This section contains detailed descriptions of each SQL++ aggregate function (i.e., array function).</p>
+<div class="section">
+<h3><a name="array_count"></a>array_count</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>array_count( ['hello', 'world', 1, 2, 3, null, missing] );
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>array_avg( [1.2, 2.3, 3.4, 0, null] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>6.9
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="array_sql_min"></a>array_sql_min</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>array_min( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>array_max( [1.2, 2.3, 3.4, 0, null, missing] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>3.4
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="coll_count"></a>coll_count</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>coll_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 class="source">
+<div class="source">
+<pre>coll_count( [1, 2, null, missing] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>4
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="coll_avg"></a>coll_avg</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>coll_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 class="source">
+<div class="source">
+<pre>coll_avg( [100, 200, 300] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 200.0 ]
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="coll_sum"></a>coll_sum</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>coll_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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>coll_sum( [100, 200, 300] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>600
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="array_min"></a>array_min</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>coll_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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>coll_min( [10.2, 100, 5] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>5.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 class="source">
+<div class="source">
+<pre>coll_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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>coll_max( [10.2, 100, 5] );
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>100.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="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 class="source">
+<div class="source">
+<pre>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>&#x2026;.</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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: greatest(1, 2, 3), &quot;v2&quot;: greatest(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="least"></a>least</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>&#x2026;.</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>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: least(1, 2, 3), &quot;v2&quot;: least(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: -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_Back_to_TOC"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<div class="section">
+<h3><a name="is_array_isarray"></a>is_array (isarray)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;a&quot;: is_array(true),
+  &quot;b&quot;: is_array(false),
+  &quot;c&quot;: isarray(null),
+  &quot;d&quot;: isarray(missing),
+  &quot;e&quot;: isarray(&quot;d&quot;),
+  &quot;f&quot;: isarray(4.0),
+  &quot;g&quot;: isarray(5),
+  &quot;h&quot;: isarray([&quot;1&quot;, 2]),
+  &quot;i&quot;: isarray({&quot;a&quot;:1})
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false }
+</pre></div></div></li>
+</ul>
+<p>The function has an alias <tt>isarray</tt>.</p></div>
+<div class="section">
+<h3><a name="is_boolean_isboolean_isbool"></a>is_boolean (isboolean, isbool)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;a&quot;: isboolean(true),
+  &quot;b&quot;: isboolean(false),
+  &quot;c&quot;: is_boolean(null),
+  &quot;d&quot;: is_boolean(missing),
+  &quot;e&quot;: isbool(&quot;d&quot;),
+  &quot;f&quot;: isbool(4.0),
+  &quot;g&quot;: isbool(5),
+  &quot;h&quot;: isbool([&quot;1&quot;, 2]),
+  &quot;i&quot;: isbool({&quot;a&quot;:1})
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
+</pre></div></div></li>
+</ul>
+<p>The function has two aliases, <tt>isboolean</tt> or <tt>isbool</tt>.</p></div>
+<div class="section">
+<h3><a name="is_number_isnumber_isnum"></a>is_number (isnumber, isnum)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;a&quot;: is_number(true),
+  &quot;b&quot;: is_number(false),
+  &quot;c&quot;: isnumber(null),
+  &quot;d&quot;: isnumber(missing),
+  &quot;e&quot;: isnumber(&quot;d&quot;),
+  &quot;f&quot;: isnum(4.0),
+  &quot;g&quot;: isnum(5),
+  &quot;h&quot;: isnum([&quot;1&quot;, 2]),
+  &quot;i&quot;: isnum({&quot;a&quot;:1})
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false }
+</pre></div></div></li>
+</ul>
+<p>The function has two aliases, <tt>isnumber</tt> or <tt>isnum</tt>.</p></div>
+<div class="section">
+<h3><a name="is_object_isobject_isobj"></a>is_object (isobject, isobj)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;a&quot;: is_object(true),
+  &quot;b&quot;: is_object(false),
+  &quot;c&quot;: isobject(null),
+  &quot;d&quot;: isobject(missing),
+  &quot;e&quot;: isobj(&quot;d&quot;),
+  &quot;f&quot;: isobj(4.0),
+  &quot;g&quot;: isobj(5),
+  &quot;h&quot;: isobj([&quot;1&quot;, 2]),
+  &quot;i&quot;: isobj({&quot;a&quot;:1})
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+<p>{ &#x201c;a&#x201d;: false, &#x201c;b&#x201d;: false, &#x201c;c&#x201d;: null, &#x201c;e&#x201d;: false, &#x201c;f&#x201d;: false, &#x201c;g&#x201d;: false, &#x201c;h&#x201d;: false, &#x201c;i&#x201d;: true }</p></li>
+</ul>
+<p>The function has two aliases, <tt>isobject</tt> or <tt>isobj</tt>.</p></div>
+<div class="section">
+<h3><a name="is_string_isstring_isstr"></a>is_string (isstring, isstr)</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{
+  &quot;a&quot;: is_string(true),
+  &quot;b&quot;: isstring(false),
+  &quot;c&quot;: isstring(null),
+  &quot;d&quot;: isstr(missing),
+  &quot;e&quot;: isstr(&quot;d&quot;),
+  &quot;f&quot;: isstr(4.0),
+  &quot;g&quot;: isstr(5),
+  &quot;h&quot;: isstr([&quot;1&quot;, 2]),
+  &quot;i&quot;: isstr({&quot;a&quot;:1})
+};
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
+</pre></div></div></li>
+</ul>
+<p>The function has two aliases, <tt>isstring</tt> or <tt>isstr</tt>.</p></div>
+<div class="section">
+<h3><a name="is_null"></a>is_null</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: 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 class="source">
+<div class="source">
+<pre>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>/`<tt>missing</tt> value (<tt>true</tt>) or not (<tt>false</tt>).</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
+</pre></div></div></li>
+</ul>
+<p>The function has an alias <tt>isunknown</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_Back_to_TOC"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<div class="section">
+<h3><a name="uuid"></a>uuid</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>len([&quot;Hello&quot;, &quot;World&quot;])
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>2
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="not"></a>not</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="range"></a>range</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>range(0, 3);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>[ 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 class="source">
+<div class="source">
+<pre>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>
+<p>Example 1:</p>
+  
+<div class="source">
+<div class="source">
+<pre>switch_case(
+    &quot;a&quot;,
+    &quot;a&quot;, 0,
+    &quot;x&quot;, 1,
+    &quot;y&quot;, 2,
+    &quot;z&quot;, 3
+);
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>0
+</pre></div></div></li>
+  
+<li>
+<p>Example 2:</p>
+  
+<div class="source">
+<div class="source">
+<pre>switch_case(
+    &quot;a&quot;,
+    &quot;x&quot;, 1,
+    &quot;y&quot;, 2,
+    &quot;z&quot;, 3
+);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>deep_equal(expr1, expr2)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>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.</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>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>deep_equal(
+           {
+             &quot;id&quot;:1,
+             &quot;project&quot;:&quot;AsterixDB&quot;,
+             &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
+             &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+           },
+           {
+             &quot;id&quot;:1,
+             &quot;project&quot;:&quot;AsterixDB&quot;,
+             &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
+             &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
+           }
+);
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>false
+</pre></div></div></li>
+</ul></div></div>
+                  </div>
+            </div>
+          </div>
+
+    <hr/>
+
+    <footer>
+            <div class="container-fluid">
+              <div class="row span12">Copyright &copy;                    2017
+                        <a href="https://www.apache.org/">The Apache Software Foundation</a>.
+            All Rights Reserved.      
+                    
+      </div>
+
+                                                                  <?xml version="1.0" encoding="UTF-8"?>
+<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>
+    </footer>
+  </body>
+</html>
diff --git a/content/docs/0.9.1/sqlpp/manual.html b/content/docs/0.9.1/sqlpp/manual.html
new file mode 100644
index 0000000..582af4a
--- /dev/null
+++ b/content/docs/0.9.1/sqlpp/manual.html
@@ -0,0 +1,4533 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at 2017-04-24
+ | Rendered using Apache Maven Fluido Skin 1.3.0
+-->
+<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="20170424" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>AsterixDB &#x2013; The SQL++ Query Language</title>
+    <link rel="stylesheet" href="../css/apache-maven-fluido-1.3.0.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.3.0.min.js"></script>
+
+                          
+        
+<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+        ga('create', 'UA-41536543-1', 'uci.edu');
+        ga('send', 'pageview');</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: 2017-04-24</li>
+                      
+                
+                    
+                 <li id="projectVersion" class="pull-right">Version: 0.9.1</li>
+      
+                                            <li class="divider pull-right">|</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="span3">
+          <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">
+          <i class="none"></i>
+        Option 1: using NCService</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../ansible.html" title="Option 2: using Ansible">
+          <i class="none"></i>
+        Option 2: using Ansible</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aws.html" title="Option 3: using Amazon Web Services">
+          <i class="none"></i>
+        Option 3: using Amazon Web Services</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../yarn.html" title="Option 4: using YARN">
+          <i class="none"></i>
+        Option 4: using YARN</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../install.html" title="Option 5: using Managix (deprecated)">
+          <i class="none"></i>
+        Option 5: using Managix (deprecated)</a>
+            </li>
+                              <li class="nav-header">AsterixDB Primer</li>
+                                
+      <li>
+    
+                          <a href="../sqlpp/primer-sqlpp.html" title="Option 1: using SQL++">
+          <i class="none"></i>
+        Option 1: using SQL++</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/primer.html" title="Option 2: using AQL">
+          <i class="none"></i>
+        Option 2: using AQL</a>
+            </li>
+                              <li class="nav-header">Data Model</li>
+                                
+      <li>
+    
+                          <a href="../datamodel.html" title="The Asterix Data Model">
+          <i class="none"></i>
+        The Asterix Data Model</a>
+            </li>
+                              <li class="nav-header">Queries - SQL++</li>
+                                
+      <li class="active">
+    
+            <a href="#"><i class="none"></i>The SQL++ Query Language</a>
+          </li>
+                  
+      <li>
+    
+                          <a href="../sqlpp/builtins.html" title="Builtin Functions">
+          <i class="none"></i>
+        Builtin Functions</a>
+            </li>
+                              <li class="nav-header">Queries - AQL</li>
+                                
+      <li>
+    
+                          <a href="../aql/manual.html" title="The Asterix Query Language (AQL)">
+          <i class="none"></i>
+        The Asterix Query Language (AQL)</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/builtins.html" title="Builtin Functions">
+          <i class="none"></i>
+        Builtin Functions</a>
+            </li>
+                              <li class="nav-header">API/SDK</li>
+                                
+      <li>
+    
+                          <a href="../api.html" title="HTTP API">
+          <i class="none"></i>
+        HTTP API</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../csv.html" title="CSV Output">
+          <i class="none"></i>
+        CSV Output</a>
+            </li>
+                              <li class="nav-header">Advanced Features</li>
+                                
+      <li>
+    
+                          <a href="../aql/fulltext.html" title="Support of Full-text Queries">
+          <i class="none"></i>
+        Support of Full-text Queries</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/externaldata.html" title="Accessing External Data">
+          <i class="none"></i>
+        Accessing External Data</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../feeds/tutorial.html" title="Support for Data Ingestion">
+          <i class="none"></i>
+        Support for Data Ingestion</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../udf.html" title="User Defined Functions">
+          <i class="none"></i>
+        User Defined Functions</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
+          <i class="none"></i>
+        Filter-Based LSM Index Acceleration</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/similarity.html" title="Support of Similarity Queries">
+          <i class="none"></i>
+        Support of Similarity Queries</a>
+            </li>
+            </ul>
+                
+                    
+                
+          <hr class="divider" />
+
+           <div id="poweredBy">
+                            <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="span9" >
+                                  
+            <!-- ! 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 SQL++ 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="#Case_expressions">Case Expressions</a></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="#Constructors">Constructors</a></li>
+    </ul></li>
+  </ul></li>
+  
+<li><a href="#Queries">3. Queries</a>
+  
+<ul>
+    
+<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="#Vs_SQL-92">SQL++ Vs. 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="#Declarations">Declarations</a></li>
+    
+<li><a href="#Lifecycle_management_statements">Lifecycle Management Statements</a>
+    
+<ul>
+      
+<li><a href="#Dataverses">Dataverses</a></li>
+      
+<li><a href="#Datasets">Datasets</a></li>
+      
+<li><a href="#Types">Types</a></li>
+      
+<li><a href="#Functions">Functions</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>
+</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 the SQL++ Query Language, a SQL-inspired language for working with semistructured data. SQL++ has much in common with SQL, but some differences do exist due to the different data models that the two languages were designed to serve. SQL was designed in the 1970&#x2019;s for interacting with the flat, schema-ified world of relational databases, while SQL++ is much newer and targets the nested, schema-optional (or even schema-less) world of modern NoSQL systems.</p>
+<p>In the context of Apache AsterixDB, SQL++ 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 &#x201c;<a href="primer-sqlpp.html">AsterixDB 101: An ADM and SQL++ Primer</a>&#x201d; 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 SQL++.</p>
+<p>In what follows, we detail the features of the SQL++ language in a grammar-guided manner. We list and briefly explain each of the productions in the SQL++ 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>SQL++ is a highly composable expression language. Each SQL++ expression returns zero or more data model instances. There are three major kinds of expressions in SQL++. At the topmost level, a SQL++ expression can be an OperatorExpression (similar to a mathematical expression), an ConditionalExpression (to choose between alternative values), or a QuantifiedExpression (which yields a boolean value). Each will be detailed as we explore the full SQL++ grammar.</p>
+
+<div class="source">
+<div class="source">
+<pre>Expression ::= OperatorExpression | CaseExpression | 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 class="source">
+<div class="source">
+<pre>OperatorExpression ::= PathExpression
+                       | Operator OperatorExpression
+                       | OperatorExpression Operator (OperatorExpression)?
+                       | OperatorExpression &lt;BETWEEN&gt; OperatorExpression &lt;AND&gt; OperatorExpression
+</pre></div></div>
+<p>SQL++ 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>*, /, % </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</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>=, !=, &lt;&gt;, &lt;, &gt;, &lt;=, &gt;=, 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, divide, modulo </td>
+      
+<td>SELECT VALUE 4 / 2.0; </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>^ </td>
+      
+<td>Exponentiation </td>
+      
+<td>SELECT VALUE 2^3; </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>|| </td>
+      
+<td>String concatenation </td>
+      
+<td>SELECT VALUE &#x201c;ab&#x201d;||&#x201c;c&#x201d;||&#x201c;d&#x201d;; </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 [&#x201c;en&#x201d;, &#x201c;de&#x201d;]; </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 [&#x201c;en&#x201d;]; </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. SQL++ (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>{&#x201c;name&#x201d;: &#x201c;Jack&#x201d;, &#x201c;friend&#x201d;: &#x201c;Jill&#x201d;}</p>
+<p>{&#x201c;name&#x201d;: &#x201c;Jake&#x201d;, &#x201c;friend&#x201d;: NULL}</p>
+<p>{&#x201c;name&#x201d;: &#x201c;Joe&#x201d;}</p>
+<p>The following table enumerates all of SQL++&#x2019;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>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>&lt;&gt; </td>
+      
+<td>Inequality test </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId&lt;&gt;10;</td>
+    </tr>
+    
+<tr class="b">
+      
+<td>&lt; </td>
+      
+<td>Less than </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId&lt;10; </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>&gt; </td>
+      
+<td>Greater than </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId&gt;10; </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>&lt;= </td>
+      
+<td>Less than or equal to </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId&lt;=10; </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>&gt;= </td>
+      
+<td>Greater than or equal to </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.chirpId&gt;=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, &#x201c;%&#x201d; matches <br />any string while &#x201c;_&#x201d; matches <br /> any character. </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name LIKE &#x201c;%Giesen%&#x201d;;</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, &#x201c;%&#x201d; matches <br />any string while &#x201c;_&#x201d; matches <br /> any character. </td>
+      
+<td>SELECT * FROM ChirpMessages cm <br />WHERE cm.user.name NOT LIKE &#x201c;%Giesen%&#x201d;;</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>
+  </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="Case_Expressions"></a><a name="Case_expressions" id="Case_expressions">Case Expressions</a></h2>
+
+<div class="source">
+<div class="source">
+<pre>CaseExpression ::= SimpleCaseExpression | SearchedCaseExpression
+SimpleCaseExpression ::= &lt;CASE&gt; Expression ( &lt;WHEN&gt; Expression &lt;THEN&gt; Expression )+ ( &lt;ELSE&gt; Expression )? &lt;END&gt;
+SearchedCaseExpression ::= &lt;CASE&gt; ( &lt;WHEN&gt; Expression &lt;THEN&gt; Expression )+ ( &lt;ELSE&gt; Expression )? &lt;END&gt;
+</pre></div></div>
+<p>In a simple <tt>CASE</tt> expression, the query evaluator searches for the first <tt>WHEN</tt> &#x2026; <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> &#x2026; <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 class="source">
+<div class="source">
+<pre>CASE (2 &lt; 3) WHEN true THEN &quot;yes&quot; ELSE &quot;no&quot; END
+</pre></div></div></div></div></div></div>
+<div class="section">
+<h2><a name="Quantified_Expressions"></a><a name="Quantified_expressions" id="Quantified_expressions">Quantified Expressions</a></h2>
+
+<div class="source">
+<div class="source">
+<pre>QuantifiedExpression ::= ( (&lt;ANY&gt;|&lt;SOME&gt;) | &lt;EVERY&gt; ) Variable &lt;IN&gt; Expression ( &quot;,&quot; Variable &quot;in&quot; Expression )*
+                         &lt;SATISFIES&gt; Expression (&lt;END&gt;)?
+</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> (&#x201c;every&#x201d; value in an empty set satisfies the condition) while the second expression would yield <tt>FALSE</tt> (since there isn&#x2019;t &#x201c;some&#x201d; 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 class="source">
+<div class="source">
+<pre>EVERY x IN [ 1, 2, 3 ] SATISFIES x &lt; 3
+SOME x IN [ 1, 2, 3 ] SATISFIES x &lt; 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 class="source">
+<div class="source">
+<pre>PathExpression  ::= PrimaryExpression ( Field | Index )*
+Field           ::= &quot;.&quot; Identifier
+Index           ::= &quot;[&quot; ( Expression | &quot;?&quot; ) &quot;]&quot;
+</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 SQL++ expression that yields an instance of a complex type, for example, a object or array instance. For objects, path access is based on field names. For arrays, path access is based on (zero-based) array-style indexing. SQL++ also supports an &#x201c;I&#x2019;m feeling lucky&#x201d; style index accessor, [?], for selecting an arbitrary element from an array. 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 a object, index-based element access for 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 class="source">
+<div class="source">
+<pre>({&quot;name&quot;: &quot;MyABCs&quot;, &quot;array&quot;: [ &quot;a&quot;, &quot;b&quot;, &quot;c&quot;]}).array
+
+([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;])[2]
+
+({&quot;name&quot;: &quot;MyABCs&quot;, &quot;array&quot;: [ &quot;a&quot;, &quot;b&quot;, &quot;c&quot;]}).array[2]
+</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 class="source">
+<div class="source">
+<pre>PrimaryExpr ::= Literal
+              | VariableReference
+              | ParenthesizedExpression
+              | FunctionCallExpression
+              | Constructor
+</pre></div></div>
+<p>The most basic building block for any SQL++ expression 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 class="source">
+<div class="source">
+<pre>Literal        ::= StringLiteral
+                   | IntegerLiteral
+                   | FloatLiteral
+                   | DoubleLiteral
+                   | &lt;NULL&gt;
+                   | &lt;MISSING&gt;
+                   | &lt;TRUE&gt;
+                   | &lt;FALSE&gt;
+StringLiteral  ::= &quot;\&quot;&quot; (
+                             &lt;EscapeQuot&gt;
+                           | &lt;EscapeBslash&gt;
+                           | &lt;EscapeSlash&gt;
+                           | &lt;EscapeBspace&gt;
+                           | &lt;EscapeFormf&gt;
+                           | &lt;EscapeNl&gt;
+                           | &lt;EscapeCr&gt;
+                           | &lt;EscapeTab&gt;
+                           | ~[&quot;\&quot;&quot;,&quot;\\&quot;])*
+                    &quot;\&quot;&quot;
+                    | &quot;\'&quot;(
+                             &lt;EscapeApos&gt;
+                           | &lt;EscapeBslash&gt;
+                           | &lt;EscapeSlash&gt;
+                           | &lt;EscapeBspace&gt;
+                           | &lt;EscapeFormf&gt;
+                           | &lt;EscapeNl&gt;
+                           | &lt;EscapeCr&gt;
+                           | &lt;EscapeTab&gt;
+                           | ~[&quot;\'&quot;,&quot;\\&quot;])*
+                      &quot;\'&quot;
+&lt;ESCAPE_Apos&gt;  ::= &quot;\\\'&quot;
+&lt;ESCAPE_Quot&gt;  ::= &quot;\\\&quot;&quot;
+&lt;EscapeBslash&gt; ::= &quot;\\\\&quot;
+&lt;EscapeSlash&gt;  ::= &quot;\\/&quot;
+&lt;EscapeBspace&gt; ::= &quot;\\b&quot;
+&lt;EscapeFormf&gt;  ::= &quot;\\f&quot;
+&lt;EscapeNl&gt;     ::= &quot;\\n&quot;
+&lt;EscapeCr&gt;     ::= &quot;\\r&quot;
+&lt;EscapeTab&gt;    ::= &quot;\\t&quot;
+
+IntegerLiteral ::= &lt;DIGITS&gt;
+&lt;DIGITS&gt;       ::= [&quot;0&quot; - &quot;9&quot;]+
+FloatLiteral   ::= &lt;DIGITS&gt; ( &quot;f&quot; | &quot;F&quot; )
+                 | &lt;DIGITS&gt; ( &quot;.&quot; &lt;DIGITS&gt; ( &quot;f&quot; | &quot;F&quot; ) )?
+                 | &quot;.&quot; &lt;DIGITS&gt; ( &quot;f&quot; | &quot;F&quot; )
+DoubleLiteral  ::= &lt;DIGITS&gt; &quot;.&quot; &lt;DIGITS&gt;
+                   | &quot;.&quot; &lt;DIGITS&gt;
+</pre></div></div>
+<p>Literals (constants) in SQL++ 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 specialy value <tt>MISSING</tt> is only meaningful in the context of SQL++ 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 SQL++ literals.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div class="source">
+<div class="source">
+<pre>'a string'
+&quot;test string&quot;
+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 SQL++.</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 class="source">
+<div class="source">
+<pre>VariableReference     ::= &lt;IDENTIFIER&gt;|&lt;DelimitedIdentifier&gt;
+&lt;IDENTIFIER&gt;          ::= &lt;LETTER&gt; (&lt;LETTER&gt; | &lt;DIGIT&gt; | &quot;_&quot; | &quot;$&quot;)*
+&lt;LETTER&gt;              ::= [&quot;A&quot; - &quot;Z&quot;, &quot;a&quot; - &quot;z&quot;]
+DelimitedIdentifier   ::= &quot;`&quot; (&lt;EscapeQuot&gt;
+                                | &lt;EscapeBslash&gt;
+                                | &lt;EscapeSlash&gt;
+                                | &lt;EscapeBspace&gt;
+                                | &lt;EscapeFormf&gt;
+                                | &lt;EscapeNl&gt;
+                                | &lt;EscapeCr&gt;
+                                | &lt;EscapeTab&gt;
+                                | ~[&quot;`&quot;,&quot;\\&quot;])*
+                          &quot;`&quot;
+</pre></div></div>
+<p>A variable in SQL++ 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&#x2019;s desired name clashes with a SQL++ keyword or includes characters not allowed in regular identifiers.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Examples"></a>Examples</h5>
+
+<div class="source">
+<div class="source">
+<pre>tweet
+id
+`SELECT`
+`my-function`
+</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 class="source">
+<div class="source">
+<pre>ParenthesizedExpression ::= &quot;(&quot; Expression &quot;)&quot; | Subquery
+</pre></div></div>
+<p>An expression can be parenthesized to control the precedence order or otherwise clarify a query. In SQL++, 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 class="source">
+<div class="source">
+<pre>( 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 class="source">
+<div class="source">
+<pre>FunctionCallExpression ::= FunctionName &quot;(&quot; ( Expression ( &quot;,&quot; Expression )* )? &quot;)&quot;
+</pre></div></div>
+<p>Functions are included in SQL++, like most languages, as a way to package useful functionality or to componentize complicated or reusable SQL++ computations. A function call is a legal SQL++ 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 SQL++ expressions.</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 class="source">
+<div class="source">
+<pre>length('a string')
+</pre></div></div></div></div></div>
+<div class="section">
+<h3><a name="Constructors" id="Constructors">Constructors</a></h3>
+
+<div class="source">
+<div class="source">
+<pre>Constructor              ::= ArrayConstructor | MultisetConstructor | ObjectConstructor
+ArrayConstructor         ::= &quot;[&quot; ( Expression ( &quot;,&quot; Expression )* )? &quot;]&quot;
+MultisetConstructor      ::= &quot;{{&quot; ( Expression ( &quot;,&quot; Expression )* )? &quot;}}&quot;
+ObjectConstructor        ::= &quot;{&quot; ( FieldBinding ( &quot;,&quot; FieldBinding )* )? &quot;}&quot;
+FieldBinding             ::= Expression &quot;:&quot; Expression
+</pre></div></div>
+<p>A major feature of SQL++ is its ability to construct new data model instances. This is accomplished using its constructors for each of the model&#x2019;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 SQL++ 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 SQL++ 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 class="source">
+<div class="source">
+<pre>[ 'a', 'b', 'c', 'c' ]
+
+[ 42, &quot;forty-two!&quot;, { &quot;rank&quot; : &quot;Captain&quot;, &quot;name&quot;: &quot;America&quot; }, 3.14159 ]
+
+{
+  'project name': 'Hyracks',
+  'project members': [ 'vinayakb', 'dtabass', 'chenli', 'tsotras', 'tillw' ]
+}
+</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>
+<!-- ! 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 SQL++ query can be any legal SQL++ expression or <tt>SELECT</tt> statement. A SQL++ query always ends with a semicolon.</p>
+
+<div class="source">
+<div class="source">
+<pre>Query ::= (Expression | SelectStatement) &quot;;&quot;
+</pre></div></div></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 SQL++.</p>
+
+<div class="source">
+<div class="source">
+<pre>SelectStatement    ::= ( WithClause )?
+                       SelectSetOperation (OrderbyClause )? ( LimitClause )?
+SelectSetOperation ::= SelectBlock (&lt;UNION&gt; &lt;ALL&gt; ( SelectBlock | Subquery ) )*
+Subquery           ::= &quot;(&quot; SelectStatement &quot;)&quot;
+
+SelectBlock        ::= SelectClause
+                       ( FromClause ( LetClause )?)?
+                       ( WhereClause )?
+                       ( GroupbyClause ( LetClause )? ( HavingClause )? )?
+                       |
+                       FromClause ( LetClause )?
+                       ( WhereClause )?
+                       ( GroupbyClause ( LetClause )? ( HavingClause )? )?
+                       SelectClause
+
+SelectClause       ::= &lt;SELECT&gt; ( &lt;ALL&gt; | &lt;DISTINCT&gt; )? ( SelectRegular | SelectValue )
+SelectRegular      ::= Projection ( &quot;,&quot; Projection )*
+SelectValue      ::= ( &lt;VALUE&gt; | &lt;ELEMENT&gt; | &lt;RAW&gt; ) Expression
+Projection         ::= ( Expression ( &lt;AS&gt; )? Identifier | &quot;*&quot; )
+
+FromClause         ::= &lt;FROM&gt; FromTerm ( &quot;,&quot; FromTerm )*
+FromTerm           ::= Expression (( &lt;AS&gt; )? Variable)?
+                       ( ( JoinType )? ( JoinClause | UnnestClause ) )*
+
+JoinClause         ::= &lt;JOIN&gt; Expression (( &lt;AS&gt; )? Variable)? &lt;ON&gt; Expression
+UnnestClause       ::= ( &lt;UNNEST&gt; | &lt;CORRELATE&gt; | &lt;FLATTEN&gt; ) Expression
+                       ( &lt;AS&gt; )? Variable ( &lt;AT&gt; Variable )?
+JoinType           ::= ( &lt;INNER&gt; | &lt;LEFT&gt; ( &lt;OUTER&gt; )? )
+
+WithClause         ::= &lt;WITH&gt; WithElement ( &quot;,&quot; WithElement )*
+LetClause          ::= (&lt;LET&gt; | &lt;LETTING&gt;) LetElement ( &quot;,&quot; LetElement )*
+LetElement         ::= Variable &quot;=&quot; Expression
+WithElement        ::= Variable &lt;AS&gt; Expression
+
+WhereClause        ::= &lt;WHERE&gt; Expression
+
+GroupbyClause      ::= &lt;GROUP&gt; &lt;BY&gt; ( Expression ( (&lt;AS&gt;)? Variable )? ( &quot;,&quot; Expression ( (&lt;AS&gt;)? Variable )? )*
+                       ( &lt;GROUP&gt; &lt;AS&gt; Variable
+                         (&quot;(&quot; Variable &lt;AS&gt; VariableReference (&quot;,&quot; Variable &lt;AS&gt; VariableReference )* &quot;)&quot;)?
+                       )?
+HavingClause       ::= &lt;HAVING&gt; Expression
+
+OrderbyClause      ::= &lt;ORDER&gt; &lt;BY&gt; Expression ( &lt;ASC&gt; | &lt;DESC&gt; )? ( &quot;,&quot; Expression ( &lt;ASC&gt; | &lt;DESC&gt; )? )*
+LimitClause        ::= &lt;LIMIT&gt; Expression ( &lt;OFFSET&gt; 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 class="source">
+<div class="source">
+<pre>[ {
+  &quot;id&quot;:1,
+  &quot;alias&quot;:&quot;Margarita&quot;,
+  &quot;name&quot;:&quot;MargaritaStoddard&quot;,
+  &quot;nickname&quot;:&quot;Mags&quot;,
+  &quot;userSince&quot;:&quot;2012-08-20T10:10:00&quot;,
+  &quot;friendIds&quot;:[2,3,6,10],
+  &quot;employment&quot;:[{
+                  &quot;organizationName&quot;:&quot;Codetechno&quot;,
+                  &quot;start-date&quot;:&quot;2006-08-06&quot;
+                },
+                {
+                  &quot;organizationName&quot;:&quot;geomedia&quot;,
+                  &quot;start-date&quot;:&quot;2010-06-17&quot;,
+                  &quot;end-date&quot;:&quot;2010-01-26&quot;
+                }],
+  &quot;gender&quot;:&quot;F&quot;
+},
+{
+  &quot;id&quot;:2,
+  &quot;alias&quot;:&quot;Isbel&quot;,
+  &quot;name&quot;:&quot;IsbelDull&quot;,
+  &quot;nickname&quot;:&quot;Izzy&quot;,
+  &quot;userSince&quot;:&quot;2011-01-22T10:10:00&quot;,
+  &quot;friendIds&quot;:[1,4],
+  &quot;employment&quot;:[{
+                  &quot;organizationName&quot;:&quot;Hexviafind&quot;,
+                  &quot;startDate&quot;:&quot;2010-04-27&quot;
+               }]
+},
+{
+  &quot;id&quot;:3,
+  &quot;alias&quot;:&quot;Emory&quot;,
+  &quot;name&quot;:&quot;EmoryUnk&quot;,
+  &quot;userSince&quot;:&quot;2012-07-10T10:10:00&quot;,
+  &quot;friendIds&quot;:[1,5,8,9],
+  &quot;employment&quot;:[{
+                  &quot;organizationName&quot;:&quot;geomedia&quot;,
+                  &quot;startDate&quot;:&quot;2010-06-17&quot;,
+                  &quot;endDate&quot;:&quot;2010-01-26&quot;
+               }]
+} ]
+</pre></div></div>
+<p><tt>GleambookMessages</tt> collection (or, dataset):</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+  &quot;messageId&quot;:2,
+  &quot;authorId&quot;:1,
+  &quot;inResponseTo&quot;:4,
+  &quot;senderLocation&quot;:[41.66,80.87],
+  &quot;message&quot;:&quot; dislike x-phone its touch-screen is horrible&quot;
+},
+{
+  &quot;messageId&quot;:3,
+  &quot;authorId&quot;:2,
+  &quot;inResponseTo&quot;:4,
+  &quot;senderLocation&quot;:[48.09,81.01],
+  &quot;message&quot;:&quot; like product-y the plan is amazing&quot;
+},
+{
+  &quot;messageId&quot;:4,
+  &quot;authorId&quot;:1,
+  &quot;inResponseTo&quot;:2,
+  &quot;senderLocation&quot;:[37.73,97.04],
+  &quot;message&quot;:&quot; can't stand acast the network is horrible:(&quot;
+},
+{
+  &quot;messageId&quot;:6,
+  &quot;authorId&quot;:2,
+  &quot;inResponseTo&quot;:1,
+  &quot;senderLocation&quot;:[31.5,75.56],
+  &quot;message&quot;:&quot; like product-z its platform is mind-blowing&quot;
+}
+{
+  &quot;messageId&quot;:8,
+  &quot;authorId&quot;:1,
+  &quot;inResponseTo&quot;:11,
+  &quot;senderLocation&quot;:[40.33,80.87],
+  &quot;message&quot;:&quot; like ccast the 3G is awesome:)&quot;
+},
+{
+  &quot;messageId&quot;:10,
+  &quot;authorId&quot;:1,
+  &quot;inResponseTo&quot;:12,
+  &quot;senderLocation&quot;:[42.5,70.01],
+  &quot;message&quot;:&quot; can't stand product-w the touch-screen is terrible&quot;
+},
+{
+  &quot;messageId&quot;:11,
+  &quot;authorId&quot;:1,
+  &quot;inResponseTo&quot;:1,
+  &quot;senderLocation&quot;:[38.97,77.49],
+  &quot;message&quot;:&quot; can't stand acast its plan is terrible&quot;
+} ]
+</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 SQL++ <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_ElementValueRaw"></a><a name="Select_element" id="Select_element">Select Element/Value/Raw</a></h3>
+<p>The <tt>SELECT VALUE</tt> clause in SQL++ returns an array or multiset that contains the results of evaluating the <tt>VALUE</tt> expression, with one evaluation being performed per &#x201c;binding tuple&#x201d; (i.e., per <tt>FROM</tt> clause item) satisfying the statement&#x2019;s selection criteria. For historical reasons SQL++ 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 class="source">
+<div class="source">
+<pre>SELECT VALUE 1;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[
+  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 class="source">
+<div class="source">
+<pre>SELECT VALUE user
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[{
+    &quot;userSince&quot;: &quot;2012-08-20T10:10:00.000Z&quot;,
+    &quot;friendIds&quot;: [
+        2,
+        3,
+        6,
+        10
+    ],
+    &quot;gender&quot;: &quot;F&quot;,
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;nickname&quot;: &quot;Mags&quot;,
+    &quot;alias&quot;: &quot;Margarita&quot;,
+    &quot;id&quot;: 1,
+    &quot;employment&quot;: [
+        {
+            &quot;organizationName&quot;: &quot;Codetechno&quot;,
+            &quot;start-date&quot;: &quot;2006-08-06&quot;
+        },
+        {
+            &quot;end-date&quot;: &quot;2010-01-26&quot;,
+            &quot;organizationName&quot;: &quot;geomedia&quot;,
+            &quot;start-date&quot;: &quot;2010-06-17&quot;
+        }
+    ]
+} ]
+</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>In SQL++, the traditional SQL-style <tt>SELECT</tt> syntax is also supported. This syntax can also be reformulated in a <tt>SELECT VALUE</tt> based manner in SQL++. (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 an SQL++ 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 class="source">
+<div class="source">
+<pre>SELECT user.alias user_alias, user.name user_name
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+<p>Returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;user_name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;user_alias&quot;: &quot;Margarita&quot;
+} ]
+</pre></div></div></div></div></div>
+<div class="section">
+<h3><a name="SELECT_"></a><a name="Select_star" id="Select_star">SELECT *</a></h3>
+<p>In SQL++, <tt>SELECT *</tt> returns a 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;user&quot;: {
+        &quot;userSince&quot;: &quot;2012-08-20T10:10:00.000Z&quot;,
+        &quot;friendIds&quot;: [
+            2,
+            3,
+            6,
+            10
+        ],
+        &quot;gender&quot;: &quot;F&quot;,
+        &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+        &quot;nickname&quot;: &quot;Mags&quot;,
+        &quot;alias&quot;: &quot;Margarita&quot;,
+        &quot;id&quot;: 1,
+        &quot;employment&quot;: [
+            {
+                &quot;organizationName&quot;: &quot;Codetechno&quot;,
+                &quot;start-date&quot;: &quot;2006-08-06&quot;
+            },
+            {
+                &quot;end-date&quot;: &quot;2010-01-26&quot;,
+                &quot;organizationName&quot;: &quot;geomedia&quot;,
+                &quot;start-date&quot;: &quot;2010-06-17&quot;
+            }
+        ]
+    }
+}, {
+    &quot;user&quot;: {
+        &quot;userSince&quot;: &quot;2011-01-22T10:10:00.000Z&quot;,
+        &quot;friendIds&quot;: [
+            1,
+            4
+        ],
+        &quot;name&quot;: &quot;IsbelDull&quot;,
+        &quot;nickname&quot;: &quot;Izzy&quot;,
+        &quot;alias&quot;: &quot;Isbel&quot;,
+        &quot;id&quot;: 2,
+        &quot;employment&quot;: [
+            {
+                &quot;organizationName&quot;: &quot;Hexviafind&quot;,
+                &quot;startDate&quot;: &quot;2010-04-27&quot;
+            }
+        ]
+    }
+}, {
+    &quot;user&quot;: {
+        &quot;userSince&quot;: &quot;2012-07-10T10:10:00.000Z&quot;,
+        &quot;friendIds&quot;: [
+            1,
+            5,
+            8,
+            9
+        ],
+        &quot;name&quot;: &quot;EmoryUnk&quot;,
+        &quot;alias&quot;: &quot;Emory&quot;,
+        &quot;id&quot;: 3,
+        &quot;employment&quot;: [
+            {
+                &quot;organizationName&quot;: &quot;geomedia&quot;,
+                &quot;endDate&quot;: &quot;2010-01-26&quot;,
+                &quot;startDate&quot;: &quot;2010-06-17&quot;
+            }
+        ]
+    }
+} ]
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;u&quot;: {
+        &quot;userSince&quot;: &quot;2011-01-22T10:10:00&quot;,
+        &quot;friendIds&quot;: [
+            1,
+            4
+        ],
+        &quot;name&quot;: &quot;IsbelDull&quot;,
+        &quot;nickname&quot;: &quot;Izzy&quot;,
+        &quot;alias&quot;: &quot;Isbel&quot;,
+        &quot;id&quot;: 2,
+        &quot;employment&quot;: [
+            {
+                &quot;organizationName&quot;: &quot;Hexviafind&quot;,
+                &quot;startDate&quot;: &quot;2010-04-27&quot;
+            }
+        ]
+    },
+    &quot;m&quot;: {
+        &quot;senderLocation&quot;: [
+            31.5,
+            75.56
+        ],
+        &quot;inResponseTo&quot;: 1,
+        &quot;messageId&quot;: 6,
+        &quot;authorId&quot;: 2,
+        &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+    }
+}, {
+    &quot;u&quot;: {
+        &quot;userSince&quot;: &quot;2011-01-22T10:10:00&quot;,
+        &quot;friendIds&quot;: [
+            1,
+            4
+        ],
+        &quot;name&quot;: &quot;IsbelDull&quot;,
+        &quot;nickname&quot;: &quot;Izzy&quot;,
+        &quot;alias&quot;: &quot;Isbel&quot;,
+        &quot;id&quot;: 2,
+        &quot;employment&quot;: [
+            {
+                &quot;organizationName&quot;: &quot;Hexviafind&quot;,
+                &quot;startDate&quot;: &quot;2010-04-27&quot;
+            }
+        ]
+    },
+    &quot;m&quot;: {
+        &quot;senderLocation&quot;: [
+            48.09,
+            81.01
+        ],
+        &quot;inResponseTo&quot;: 4,
+        &quot;messageId&quot;: 3,
+        &quot;authorId&quot;: 2,
+        &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+    }
+} ]
+</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>SQL++&#x2019;s <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 class="source">
+<div class="source">
+<pre>SELECT DISTINCT * FROM [1, 2, 2, 3] AS foo;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;foo&quot;: 1
+}, {
+    &quot;foo&quot;: 2
+}, {
+    &quot;foo&quot;: 3
+} ]
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT DISTINCT VALUE foo FROM [1, 2, 2, 3] AS foo;
+</pre></div></div>
+<p>This version of the query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ 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, SQL++ 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 class="source">
+<div class="source">
+<pre>SELECT substr(user.name, 10), user.alias
+FROM GleambookUsers user
+WHERE user.id = 1;
+</pre></div></div>
+<p>This query outputs:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;alias&quot;: &quot;Margarita&quot;,
+    &quot;$1&quot;: &quot;Stoddard&quot;
+} ]
+</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, 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.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT substr(name, 10) AS lname, alias
+FROM GleambookUsers user
+WHERE id = 1;
+</pre></div></div>
+<p>Outputs:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;lname&quot;: &quot;Stoddard&quot;,
+    &quot;alias&quot;: &quot;Margarita&quot;
+} ]
+</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&#x2019;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&#x2019;s object.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;orgName&quot;: &quot;Codetechno&quot;,
+    &quot;userId&quot;: 1
+}, {
+    &quot;orgName&quot;: &quot;geomedia&quot;,
+    &quot;userId&quot;: 1
+} ]
+</pre></div></div>
+<p>Note that <tt>UNNEST</tt> has SQL&#x2019;s inner join semantics &#x2014; 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&#x2019;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&#x2019;s result still includes user 1.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;userId&quot;: 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 SQL++ <tt>UNNEST</tt> clause is similar to SQL&#x2019;s <tt>JOIN</tt> clause except that it allows its right argument to be correlated to its left argument, as in the examples above &#x2014; i.e., think &#x201c;correlated cross-product&#x201d;. 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&#x2019;s name and an entire message. The query can be thought of as saying &#x201c;for each Gleambook user, unnest the <tt>GleambookMessages</tt> collection and filter the output with the condition <tt>message.authorId = user.id</tt>&#x201d;.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+}, {
+    &quot;uname&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+}, {
+    &quot;uname&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+} ]
+</pre></div></div>
+<p>Similarly, the above query can also be expressed as the <tt>UNNEST</tt>ing of a correlated SQL++ subquery:</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 SQL++, in addition to stored collections, a <tt>FROM</tt> clause can iterate over any intermediate collection returned by a valid SQL++ 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 class="source">
+<div class="source">
+<pre>SELECT VALUE foo
+FROM [1, 2, 2, 3] AS foo
+WHERE foo &gt; 2;
+</pre></div></div>
+<p>Returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[
+  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>SQL++ 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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, SQL++ supports implicit <tt>FROM</tt> binding variables (i.e., aliases), for which a binding variable is generated. SQL++ variable generation falls into three cases:</p>
+
+<ul>
+  
+<li>If the binding expression is a variable reference expression, the generated variable&#x2019;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&#x2019;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 class="source">
+<div class="source">
+<pre>SELECT GleambookUsers.name, GleambookMessages.message
+FROM GleambookUsers, GleambookMessages
+WHERE GleambookMessages.authorId = GleambookUsers.id;
+</pre></div></div>
+<p>Returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+}, {
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+}, {
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+}, {
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+}, {
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+}, {
+    &quot;name&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+}, {
+    &quot;name&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+} ]
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT GleambookUsers.name, GleambookMessages.message
+FROM GleambookUsers,
+  (
+    SELECT VALUE GleambookMessages
+    FROM GleambookMessages
+    WHERE GleambookMessages.authorId = GleambookUsers.id
+  );
+</pre></div></div>
+<p>Returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>Error: &quot;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 )&quot;,
+    &quot;query_from_user&quot;: &quot;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      );&quot;
+</pre></div></div></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 SQL++ 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 preceeding examples can also be expressed as follows:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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>SQL++ supports SQL&#x2019;s notion of left outer join. The following query is an example:</p>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+}, {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+}, {
+    &quot;uname&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+}, {
+    &quot;uname&quot;: &quot;IsbelDull&quot;,
+    &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+}, {
+    &quot;uname&quot;: &quot;EmoryUnk&quot;
+} ]
+</pre></div></div>
+<p>For non-matching left-side tuples, SQL++ produces <tt>MISSING</tt> values for the right-side binding variables; that is why the last object in the above result doesn&#x2019;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, SQL++ views fields from the right-side as being &#x201c;not there&#x201d; (a.k.a. <tt>MISSING</tt>) instead of as being &#x201c;there but unknown&#x201d; (i.e., <tt>NULL</tt>).</p>
+<p>The left-outer join query can also be expressed using <tt>LEFT OUTER UNNEST</tt>:</p>
+
+<div class="source">
+<div class="source">
+<pre>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, in SQL++, 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>
+<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 SQL++ <tt>GROUP BY</tt> clause generalizes standard SQL&#x2019;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), SQL++ allows a user to define a <i>group variable</i> by using the clause&#x2019;s <tt>GROUP AS</tt> extension to denote the resulting group. After grouping, then, the query&#x2019;s in-scope variables include the grouping key&#x2019;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&#x2019;s name. The <tt>GROUP AS</tt> syntax is as follows:</p>
+
+<div class="source">
+<div class="source">
+<pre>&lt;GROUP&gt; &lt;AS&gt; Variable (&quot;(&quot; Variable &lt;AS&gt; VariableReference (&quot;,&quot; Variable &lt;AS&gt; VariableReference )* &quot;)&quot;)?
+</pre></div></div>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;msgs&quot;: [
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    38.97,
+                    77.49
+                ],
+                &quot;inResponseTo&quot;: 1,
+                &quot;messageId&quot;: 11,
+                &quot;authorId&quot;: 1,
+                &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+            }
+        },
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    41.66,
+                    80.87
+                ],
+                &quot;inResponseTo&quot;: 4,
+                &quot;messageId&quot;: 2,
+                &quot;authorId&quot;: 1,
+                &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+            }
+        },
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    37.73,
+                    97.04
+                ],
+                &quot;inResponseTo&quot;: 2,
+                &quot;messageId&quot;: 4,
+                &quot;authorId&quot;: 1,
+                &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+            }
+        },
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    40.33,
+                    80.87
+                ],
+                &quot;inResponseTo&quot;: 11,
+                &quot;messageId&quot;: 8,
+                &quot;authorId&quot;: 1,
+                &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+            }
+        },
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    42.5,
+                    70.01
+                ],
+                &quot;inResponseTo&quot;: 12,
+                &quot;messageId&quot;: 10,
+                &quot;authorId&quot;: 1,
+                &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+            }
+        }
+    ],
+    &quot;uid&quot;: 1
+}, {
+    &quot;msgs&quot;: [
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    31.5,
+                    75.56
+                ],
+                &quot;inResponseTo&quot;: 1,
+                &quot;messageId&quot;: 6,
+                &quot;authorId&quot;: 2,
+                &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+            }
+        },
+        {
+            &quot;msg&quot;: {
+                &quot;senderLocation&quot;: [
+                    48.09,
+                    81.01
+                ],
+                &quot;inResponseTo&quot;: 4,
+                &quot;messageId&quot;: 3,
+                &quot;authorId&quot;: 2,
+                &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+            }
+        }
+    ],
+    &quot;uid&quot;: 2
+} ]
+</pre></div></div>
+<p>As we can see from the above query result, each group in the example query&#x2019;s output has an associated group variable value called <tt>msgs</tt> that appears in the <tt>SELECT *</tt>&#x2019;s result. This variable contains a collection of objects associated with the group; each of the group&#x2019;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 SQL++ makes more complex, composable, nested subqueries over a group possible, which is important given the more complex data model of SQL++ (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 &#x201c;extra wrapping&#x201d; of each message as the <tt>msg</tt> field of a 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> clase to tunnel through the extra nesting and produce the desired result.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>   [ {
+       &quot;msgs&quot;: [
+           {
+               &quot;senderLocation&quot;: [
+                   38.97,
+                   77.49
+               ],
+               &quot;inResponseTo&quot;: 1,
+               &quot;messageId&quot;: 11,
+               &quot;authorId&quot;: 1,
+               &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+           },
+           {
+               &quot;senderLocation&quot;: [
+                   41.66,
+                   80.87
+               ],
+               &quot;inResponseTo&quot;: 4,
+               &quot;messageId&quot;: 2,
+               &quot;authorId&quot;: 1,
+               &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+           },
+           {
+               &quot;senderLocation&quot;: [
+                   37.73,
+                   97.04
+               ],
+               &quot;inResponseTo&quot;: 2,
+               &quot;messageId&quot;: 4,
+               &quot;authorId&quot;: 1,
+               &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+           },
+           {
+               &quot;senderLocation&quot;: [
+                   40.33,
+                   80.87
+               ],
+               &quot;inResponseTo&quot;: 11,
+               &quot;messageId&quot;: 8,
+               &quot;authorId&quot;: 1,
+               &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+           },
+           {
+               &quot;senderLocation&quot;: [
+                   42.5,
+                   70.01
+               ],
+               &quot;inResponseTo&quot;: 12,
+               &quot;messageId&quot;: 10,
+               &quot;authorId&quot;: 1,
+               &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+           }
+       ],
+       &quot;uid&quot;: 1
+   }, {
+       &quot;msgs&quot;: [
+           {
+               &quot;senderLocation&quot;: [
+                   31.5,
+                   75.56
+               ],
+               &quot;inResponseTo&quot;: 1,
+               &quot;messageId&quot;: 6,
+               &quot;authorId&quot;: 2,
+               &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+           },
+           {
+               &quot;senderLocation&quot;: [
+                   48.09,
+                   81.01
+               ],
+               &quot;inResponseTo&quot;: 4,
+               &quot;messageId&quot;: 3,
+               &quot;authorId&quot;: 2,
+               &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+           }
+       ],
+       &quot;uid&quot;: 2
+   } ]
+</pre></div></div>
+<p>Because this is a fairly common case, a third variant with output identical to the second variant is also possible:</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT uid, msg 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 query exploits a bit of SQL-style &#x201c;syntactic sugar&#x201d; that SQL++ offers to shorten some user queries. In particular, in the <tt>SELECT</tt> list, the reference to the <tt>GROUP</tt> variable field <tt>msg</tt> &#x2013; because it references a field of the group variable &#x2013; is allowed but is &#x201c;pluralized&#x201d;. As a result, the <tt>msg</tt> reference in the <tt>SELECT</tt> list is implicitly rewritten into the second variant&#x2019;s <tt>SELECT VALUE</tt> subquery.</p>
+<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.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT uid,
+       (SELECT VALUE g.msg
+        FROM g
+        WHERE g.msg.message LIKE '% like%'
+        ORDER BY g.msg.messageId
+        LIMIT 2) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId AS uid
+GROUP AS g(gbm as msg);
+</pre></div></div>
+<p>This example query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;msgs&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                40.33,
+                80.87
+            ],
+            &quot;inResponseTo&quot;: 11,
+            &quot;messageId&quot;: 8,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+        }
+    ],
+    &quot;uid&quot;: 1
+}, {
+    &quot;msgs&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                48.09,
+                81.01
+            ],
+            &quot;inResponseTo&quot;: 4,
+            &quot;messageId&quot;: 3,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                31.5,
+                75.56
+            ],
+            &quot;inResponseTo&quot;: 1,
+            &quot;messageId&quot;: 6,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+        }
+    ],
+    &quot;uid&quot;: 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 SQL++ 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 in SQL++, 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&#x2019;t provide binding variables for its grouping key expressions.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT authorId,
+       (SELECT VALUE g.msg
+        FROM g
+        WHERE g.msg.message LIKE '% like%'
+        ORDER BY g.msg.messageId
+        LIMIT 2) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId
+GROUP AS g(gbm as msg);
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>    [ {
+    &quot;msgs&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                40.33,
+                80.87
+            ],
+            &quot;inResponseTo&quot;: 11,
+            &quot;messageId&quot;: 8,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+        }
+    ],
+    &quot;authorId&quot;: 1
+}, {
+    &quot;msgs&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                48.09,
+                81.01
+            ],
+            &quot;inResponseTo&quot;: 4,
+            &quot;messageId&quot;: 3,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                31.5,
+                75.56
+            ],
+            &quot;inResponseTo&quot;: 1,
+            &quot;messageId&quot;: 6,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+        }
+    ],
+    &quot;authorId&quot;: 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&#x2019;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 SQL++&#x2019;s <tt>GROUP BY</tt> syntax. If a user&#x2019;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&#x2019;s query will not be able to refer to the generated group variable.)</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT uid,
+       (SELECT m.message
+        FROM message m
+        WHERE m.message LIKE '% like%'
+        ORDER BY m.messageId
+        LIMIT 2) AS msgs
+FROM GleambookMessages message
+GROUP BY message.authorId AS uid;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;msgs&quot;: [
+        {
+            &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+        }
+    ],
+    &quot;uid&quot;: 1
+}, {
+    &quot;msgs&quot;: [
+        {
+            &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+        },
+        {
+            &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+        }
+    ],
+    &quot;uid&quot;: 2
+} ]
+</pre></div></div>
+<p>Note that in the query above, in principle, <tt>message</tt> is not an in-scope variable in the <tt>SELECT</tt> clause. However, the query above is a syntactically-sugared simplification of the following query and it is thus legal, executable, and returns the same result:</p>
+
+<div class="source">
+<div class="source">
+<pre>SELECT uid,
+   (SELECT g.msg.message
+    FROM g
+    WHERE g.msg.message LIKE '% like%'
+    ORDER BY g.msg.messageId
+    LIMIT 2) AS msgs
+FROM GleambookMessages gbm
+GROUP BY gbm.authorId AS uid GROUP AS g(gbm as msg);
+</pre></div></div></div></div></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&#x2019;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 SQL++ 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 SQL++ built-in aggregation functions 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>COLL_COUNT </td>
+      
+<td>counted </td>
+      
+<td>counted </td>
+      
+<td>0 </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>COLL_SUM </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>COLL_MAX </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>COLL_MIN </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+      
+<td>returns NULL </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>COLL_AVG </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>
+  </tbody>
+</table>
+<p>Notice that SQL++ has twice as many functions listed above as there are aggregate functions in SQL-92. This is because SQL++ offers two versions of each &#x2013; one that handles <tt>UNKNOWN</tt> values in a semantically strict fashion, where unknown values in the input result in unknown values in the output &#x2013; and one that handles them in the ad hoc &#x201c;just ignore the unknown values&#x201d; fashion that the SQL standard chose to adopt.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>ARRAY_AVG(
+    (
+      SELECT VALUE ARRAY_COUNT(friendIds) FROM GleambookUsers
+    )
+);
+</pre></div></div>
+<p>This example returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>3.3333333333333335
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;uid&quot;: 1,
+    &quot;msgCnt&quot;: 5
+}, {
+    &quot;uid&quot;: 2,
+    &quot;msgCnt&quot;: 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></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, SQL++ also offers SQL-92&#x2019;s aggregation function symbols (<tt>COUNT</tt>, <tt>SUM</tt>, <tt>MAX</tt>, <tt>MIN</tt>, and <tt>AVG</tt>) as supported syntactic sugar. The SQL++ compiler rewrites queries that utilize these function symbols into SQL++ queries that only use the SQL++ collection aggregate functions. The following example uses the SQL-92 syntax approach to compute a result that is identical to that of the more explicit SQL++ example above:</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 SQL++ built-in aggregation function. Rather, the <tt>COUNT</tt> query above is using a special &#x201c;sugared&#x201d; function symbol that the SQL++ compiler will rewrite as follows:</p>
+
+<div class="source">
+<div class="source">
+<pre>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>, and <tt>AVG</tt>. In contrast to the SQL++ collection aggregate functions, 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></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>SQL++ 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 class="source">
+<div class="source">
+<pre>SELECT msg.authorId, COUNT(*)
+FROM GleambookMessages msg
+GROUP BY msg.authorId;
+</pre></div></div>
+<p>This query outputs:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;authorId&quot;: 1,
+    &quot;$1&quot;: 5
+}, {
+    &quot;authorId&quot;: 2,
+    &quot;$1&quot;: 2
+} ]
+</pre></div></div>
+<p>In principle, a <tt>msg</tt> reference in the query&#x2019;s <tt>SELECT</tt> clause would be &#x201c;sugarized&#x201d; 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 class="source">
+<div class="source">
+<pre>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>SQL++ also allows column aliases to be used as <tt>GROUP BY</tt> keys or <tt>ORDER BY</tt> keys.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT msg.authorId AS aid, COUNT(*)
+FROM GleambookMessages msg
+GROUP BY aid;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;$1&quot;: 5,
+    &quot;aid&quot;: 1
+}, {
+    &quot;$1&quot;: 2,
+    &quot;aid&quot;: 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 disgarded.</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 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 class="source">
+<div class="source">
+<pre>  SELECT VALUE user
+  FROM GleambookUsers AS user
+  ORDER BY ARRAY_COUNT(user.friendIds) DESC;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>  [ {
+      &quot;userSince&quot;: &quot;2012-08-20T10:10:00.000Z&quot;,
+      &quot;friendIds&quot;: [
+          2,
+          3,
+          6,
+          10
+      ],
+      &quot;gender&quot;: &quot;F&quot;,
+      &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+      &quot;nickname&quot;: &quot;Mags&quot;,
+      &quot;alias&quot;: &quot;Margarita&quot;,
+      &quot;id&quot;: 1,
+      &quot;employment&quot;: [
+          {
+              &quot;organizationName&quot;: &quot;Codetechno&quot;,
+              &quot;start-date&quot;: &quot;2006-08-06&quot;
+          },
+          {
+              &quot;end-date&quot;: &quot;2010-01-26&quot;,
+              &quot;organizationName&quot;: &quot;geomedia&quot;,
+              &quot;start-date&quot;: &quot;2010-06-17&quot;
+          }
+      ]
+  }, {
+      &quot;userSince&quot;: &quot;2012-07-10T10:10:00.000Z&quot;,
+      &quot;friendIds&quot;: [
+          1,
+          5,
+          8,
+          9
+      ],
+      &quot;name&quot;: &quot;EmoryUnk&quot;,
+      &quot;alias&quot;: &quot;Emory&quot;,
+      &quot;id&quot;: 3,
+      &quot;employment&quot;: [
+          {
+              &quot;organizationName&quot;: &quot;geomedia&quot;,
+              &quot;endDate&quot;: &quot;2010-01-26&quot;,
+              &quot;startDate&quot;: &quot;2010-06-17&quot;
+          }
+      ]
+  }, {
+      &quot;userSince&quot;: &quot;2011-01-22T10:10:00.000Z&quot;,
+      &quot;friendIds&quot;: [
+          1,
+          4
+      ],
+      &quot;name&quot;: &quot;IsbelDull&quot;,
+      &quot;nickname&quot;: &quot;Izzy&quot;,
+      &quot;alias&quot;: &quot;Isbel&quot;,
+      &quot;id&quot;: 2,
+      &quot;employment&quot;: [
+          {
+              &quot;organizationName&quot;: &quot;Hexviafind&quot;,
+              &quot;startDate&quot;: &quot;2010-04-27&quot;
+          }
+      ]
+  } ]
+</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 class="source">
+<div class="source">
+<pre>  SELECT VALUE user
+  FROM GleambookUsers AS user
+  ORDER BY len(user.friendIds) DESC
+  LIMIT 1;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>  [ {
+      &quot;userSince&quot;: &quot;2012-08-20T10:10:00.000Z&quot;,
+      &quot;friendIds&quot;: [
+          2,
+          3,
+          6,
+          10
+      ],
+      &quot;gender&quot;: &quot;F&quot;,
+      &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+      &quot;nickname&quot;: &quot;Mags&quot;,
+      &quot;alias&quot;: &quot;Margarita&quot;,
+      &quot;id&quot;: 1,
+      &quot;employment&quot;: [
+          {
+              &quot;organizationName&quot;: &quot;Codetechno&quot;,
+              &quot;start-date&quot;: &quot;2006-08-06&quot;
+          },
+          {
+              &quot;end-date&quot;: &quot;2010-01-26&quot;,
+              &quot;organizationName&quot;: &quot;geomedia&quot;,
+              &quot;start-date&quot;: &quot;2010-06-17&quot;
+          }
+      ]
+  } ]
+</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 class="source">
+<div class="source">
+<pre>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) &gt; avgFriendCount;
+</pre></div></div>
+<p>This query returns:</p>
+
+<div class="source">
+<div class="source">
+<pre>[ {
+    &quot;userSince&quot;: &quot;2012-08-20T10:10:00.000Z&quot;,
+    &quot;friendIds&quot;: [
+        2,
+        3,
+        6,
+        10
+    ],
+    &quot;gender&quot;: &quot;F&quot;,
+    &quot;name&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;nickname&quot;: &quot;Mags&quot;,
+    &quot;alias&quot;: &quot;Margarita&quot;,
+    &quot;id&quot;: 1,
+    &quot;employment&quot;: [
+        {
+            &quot;organizationName&quot;: &quot;Codetechno&quot;,
+            &quot;start-date&quot;: &quot;2006-08-06&quot;
+        },
+        {
+            &quot;end-date&quot;: &quot;2010-01-26&quot;,
+            &quot;organizationName&quot;: &quot;geomedia&quot;,
+            &quot;start-date&quot;: &quot;2010-06-17&quot;
+        }
+    ]
+}, {
+    &quot;userSince&quot;: &quot;2012-07-10T10:10:00.000Z&quot;,
+    &quot;friendIds&quot;: [
+        1,
+        5,
+        8,
+        9
+    ],
+    &quot;name&quot;: &quot;EmoryUnk&quot;,
+    &quot;alias&quot;: &quot;Emory&quot;,
+    &quot;id&quot;: 3,
+    &quot;employment&quot;: [
+        {
+            &quot;organizationName&quot;: &quot;geomedia&quot;,
+            &quot;endDate&quot;: &quot;2010-01-26&quot;,
+            &quot;startDate&quot;: &quot;2010-06-17&quot;
+        }
+    ]
+} ]
+</pre></div></div>
+<p>The query is equivalent to the following, more complex, inlined form of the query:</p>
+
+<div class="source">
+<div class="source">
+<pre>SELECT *
+FROM GleambookUsers user
+WHERE ARRAY_COUNT(user.friendIds) &gt;
+    ( 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 &#x201c;[0]&#x201d; &#x2013; this is due to a noteworthy difference between SQL++ 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. SQL++, being designed to deal with nested data and schema-less data, does not (and should not) do this. Collection-valued data is perfectly legal in most SQL++ contexts, and its data is schema-less, so a query processor rarely knows exactly what to expect where and such automatic conversion is often not desirable. Thus, in the queries above, the use of &#x201c;[0]&#x201d; extracts the first (i.e., 0th) element of an array-valued query expression&#x2019;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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;uname&quot;: &quot;MargaritaStoddard&quot;,
+    &quot;messages&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                38.97,
+                77.49
+            ],
+            &quot;inResponseTo&quot;: 1,
+            &quot;messageId&quot;: 11,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                41.66,
+                80.87
+            ],
+            &quot;inResponseTo&quot;: 4,
+            &quot;messageId&quot;: 2,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                37.73,
+                97.04
+            ],
+            &quot;inResponseTo&quot;: 2,
+            &quot;messageId&quot;: 4,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                40.33,
+                80.87
+            ],
+            &quot;inResponseTo&quot;: 11,
+            &quot;messageId&quot;: 8,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                42.5,
+                70.01
+            ],
+            &quot;inResponseTo&quot;: 12,
+            &quot;messageId&quot;: 10,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot;
+        }
+    ]
+}, {
+    &quot;uname&quot;: &quot;IsbelDull&quot;,
+    &quot;messages&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                31.5,
+                75.56
+            ],
+            &quot;inResponseTo&quot;: 1,
+            &quot;messageId&quot;: 6,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot;
+        },
+        {
+            &quot;senderLocation&quot;: [
+                48.09,
+                81.01
+            ],
+            &quot;inResponseTo&quot;: 4,
+            &quot;messageId&quot;: 3,
+            &quot;authorId&quot;: 2,
+            &quot;message&quot;: &quot; like product-y the plan is amazing&quot;
+        }
+    ]
+} ]
+</pre></div></div>
+<p>This query is equivalent to the following query that does not use the <tt>LET</tt> clause:</p>
+
+<div class="source">
+<div class="source">
+<pre>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, SQL++ does not constrain what the data looks like on the input streams; in particular, it allows heterogenity 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[
+  &quot; like product-z its platform is mind-blowing&quot;
+  , {
+    &quot;uname&quot;: &quot;IsbelDull&quot;
+}, &quot; like product-y the plan is amazing&quot;
+ ]
+</pre></div></div></div></div></div></div>
+<div class="section">
+<h2><a name="Subqueries" id="Subqueries">Subqueries</a></h2>
+<p>In SQL++, 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 &#x201c;dislike&#x201d; messages per user.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[ {
+    &quot;msgs&quot;: [
+        {
+            &quot;senderLocation&quot;: [
+                41.66,
+                80.87
+            ],
+            &quot;inResponseTo&quot;: 4,
+            &quot;messageId&quot;: 2,
+            &quot;authorId&quot;: 1,
+            &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot;
+        }
+    ],
+    &quot;uid&quot;: 1
+}, {
+    &quot;msgs&quot;: [
+
+    ],
+    &quot;uid&quot;: 2
+} ]
+</pre></div></div>
+<p>Note that a subquery, like a top-level <tt>SELECT</tt> statment, always returns a collection &#x2013; regardless of where within a query the subquery occurs &#x2013; and again, its result is never automatically cast into a scalar.</p></div></div></div></div>
+<div class="section">
+<h2><a name="SQL_vs._SQL-92"></a><a name="Vs_SQL-92" id="Vs_SQL-92">SQL++ vs. SQL-92</a></h2>
+<p>SQL++ offers the following additional features beyond SQL-92 (hence the &#x201c;++&#x201d; in its name):</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 &#x201c;SQL-92 compatibility cheat sheet&#x201d; for SQL++.</p>
+
+<table border="0" class="table table-striped">
+  <thead>
+    
+<tr class="a">
+      
+<th>Feature </th>
+      
+<th>SQL++ </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 is 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>&#x201c;Absence&#x201d; is more appropriate than &#x201c;unknown&#x201d; 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., [..,..,&#x2026;] </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, SQL++ does not conflict those 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>NULLIF 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>DISTINCT aggregates</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 SQL++ 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>An valid SQL++ query must satisfy the SQL++ grammar rules. 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>Syntax error: In line 2 &gt;&gt;GleambookUsers user;&lt;&lt; Encountered &lt;IDENTIFIER&gt; \&quot;GleambookUsers\&quot; at column 1.
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SELECT *
+FROM GleambookUsers user
+WHERE type=&quot;advertiser&quot;;
+</pre></div></div>
+<p>Since &#x201c;type&#x201d; is a reserved keyword in the SQL++ parser, we will get a syntax error as follows:</p>
+
+<div class="source">
+<div class="source">
+<pre>Error: Syntax error: In line 3 &gt;&gt;WHERE type=&quot;advertiser&quot;;&lt;&lt; Encountered 'type' &quot;type&quot; at column 7.
+==&gt; WHERE type=&quot;advertiser&quot;;
+</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 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 class="source">
+<div class="source">
+<pre>SELECT *
+FROM GleambookUser user;
+</pre></div></div>
+<p>Assume we have a typo in &#x201c;GleambookUser&#x201d; which misses the ending &#x201c;s&#x201d;, we will get an identifier resolution error as follows:</p>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>SELECT name, message
+FROM GleambookUsers u JOIN GleambookMessages m ON m.authorId = u.id;
+</pre></div></div>
+<p>If the compiler cannot figure out all possible fields in <tt>GleambookUsers</tt> and <tt>GleambookMessages</tt>, we will get an identifier resolution error as follows:</p>
+
+<div class="source">
+<div class="source">
+<pre>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 SQL++ compiler does type checks based on its available type information. In addition, the SQL++ 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 class="source">
+<div class="source">
+<pre>abs(&quot;123&quot;);
+</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 class="source">
+<div class="source">
+<pre>Error: Arithmetic operations are not implemented for 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 class="source">
+<div class="source">
+<pre>Error: no space left on device
+Error: too many open files
+</pre></div></div>
+<p>The &#x201c;no space left on device&#x201d; issue usually can be fixed by cleaning up disk spaces and reserving more disk spaces for the system. The &#x201c;too many open files&#x201d; 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 class="source">
+<div class="source">
+<pre>Statement ::= ( SingleStatement ( &quot;;&quot; )? )* &lt;EOF&gt;
+SingleStatement ::= DatabaseDeclaration
+                  | FunctionDeclaration
+                  | CreateStatement
+                  | DropStatement
+                  | LoadStatement
+                  | SetStatement
+                  | InsertStatement
+                  | DeleteStatement
+                  | Query &quot;;&quot;
+</pre></div></div>
+<p>In addition to queries, an implementation of SQL++ needs to support statements for data definition and manipulation purposes as well as controlling the context to be used in evaluating SQL++ expressions. This section details the DDL and DML statements supported in the SQL++ language as realized today in Apache AsterixDB.</p></div>
+<div class="section">
+<h2><a name="Declarations" id="Declarations">Declarations</a></h2>
+
+<div class="source">
+<div class="source">
+<pre>DatabaseDeclaration ::= &quot;USE&quot; 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 a series of statements, the USE statement is provided in SQL++.</p>
+<p>As an example, the following statement sets the default dataverse to be &#x201c;TinySocial&#x201d;.</p>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>USE TinySocial;
+</pre></div></div>
+<p>When writing a complex SQL++ 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 SQL++ query expression.</p>
+
+<div class="source">
+<div class="source">
+<pre>FunctionDeclaration  ::= &quot;DECLARE&quot; &quot;FUNCTION&quot; Identifier ParameterList &quot;{&quot; Expression &quot;}&quot;
+ParameterList        ::= &quot;(&quot; ( &lt;VARIABLE&gt; ( &quot;,&quot; &lt;VARIABLE&gt; )* )? &quot;)&quot;
+</pre></div></div>
+<p>The following is a simple example of a temporary SQL++ function definition and its use.</p></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>[
+  { &quot;id&quot;: 2, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;friendCount&quot;: 2 }
+]
+</pre></div></div></div></div></div></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 class="source">
+<div class="source">
+<pre>CreateStatement ::= &quot;CREATE&quot; ( DatabaseSpecification
+                             | TypeSpecification
+                             | DatasetSpecification
+                             | IndexSpecification
+                             | FunctionSpecification )
+
+QualifiedName       ::= Identifier ( &quot;.&quot; Identifier )?
+DoubleQualifiedName ::= Identifier &quot;.&quot; Identifier ( &quot;.&quot; Identifier )?
+</pre></div></div>
+<p>The CREATE statement in SQL++ 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 SQL++ functions.</p>
+<div class="section">
+<h3><a name="Dataverses" id="Dataverses"> Dataverses</a></h3>
+
+<div class="source">
+<div class="source">
+<pre>DatabaseSpecification ::= &quot;DATAVERSE&quot; Identifier IfNotExists
+</pre></div></div>
+<p>The CREATE DATAVERSE statement is used to create new dataverses. To ease the authoring of reusable SQL++ 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>TypeSpecification    ::= &quot;TYPE&quot; FunctionOrTypeName IfNotExists &quot;AS&quot; ObjectTypeDef
+FunctionOrTypeName   ::= QualifiedName
+IfNotExists          ::= ( &lt;IF&gt; &lt;NOT&gt; &lt;EXISTS&gt; )?
+TypeExpr             ::= ObjectTypeDef | TypeReference | ArrayTypeDef | MultisetTypeDef
+ObjectTypeDef        ::= ( &lt;CLOSED&gt; | &lt;OPEN&gt; )? &quot;{&quot; ( ObjectField ( &quot;,&quot; ObjectField )* )? &quot;}&quot;
+ObjectField          ::= Identifier &quot;:&quot; ( TypeExpr ) ( &quot;?&quot; )?
+NestedField          ::= Identifier ( &quot;.&quot; Identifier )*
+IndexField           ::= NestedField ( &quot;:&quot; TypeReference )?
+TypeReference        ::= Identifier
+ArrayTypeDef         ::= &quot;[&quot; ( TypeExpr ) &quot;]&quot;
+MultisetTypeDef      ::= &quot;{{&quot; ( TypeExpr ) &quot;}}&quot;
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>DatasetSpecification ::= ( &lt;INTERNAL&gt; )? &lt;DATASET&gt; QualifiedName &quot;(&quot; QualifiedName &quot;)&quot; IfNotExists
+                           PrimaryKey ( &lt;ON&gt; Identifier )? ( &lt;HINTS&gt; Properties )?
+                           ( &quot;USING&quot; &quot;COMPACTION&quot; &quot;POLICY&quot; CompactionPolicy ( Configuration )? )?
+                           ( &lt;WITH&gt; &lt;FILTER&gt; &lt;ON&gt; Identifier )?
+                          |
+                           &lt;EXTERNAL&gt; &lt;DATASET&gt; QualifiedName &quot;(&quot; QualifiedName &quot;)&quot; IfNotExists &lt;USING&gt; AdapterName
+                           Configuration ( &lt;HINTS&gt; Properties )?
+                           ( &lt;USING&gt; &lt;COMPACTION&gt; &lt;POLICY&gt; CompactionPolicy ( Configuration )? )?
+AdapterName          ::= Identifier
+Configuration        ::= &quot;(&quot; ( KeyValuePair ( &quot;,&quot; KeyValuePair )* )? &quot;)&quot;
+KeyValuePair         ::= &quot;(&quot; StringLiteral &quot;=&quot; StringLiteral &quot;)&quot;
+Properties           ::= ( &quot;(&quot; Property ( &quot;,&quot; Property )* &quot;)&quot; )?
+Property             ::= Identifier &quot;=&quot; ( StringLiteral | IntegerLiteral )
+FunctionSignature    ::= FunctionOrTypeName &quot;@&quot; IntegerLiteral
+PrimaryKey           ::= &lt;PRIMARY&gt; &lt;KEY&gt; NestedField ( &quot;,&quot; NestedField )* ( &lt;AUTOGENERATED&gt; )?
+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 SQL++ 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 &#x201c;AUTOGENERATED&#x201d; after the &#x201c;PRIMARY KEY&#x201d; 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&#x2019;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&#x2019;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&#x2019;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&#x2019;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&#x2019;s control. Files living in HDFS or in the local filesystem(s) of a cluster&#x2019;s nodes are currently supported. External dataset support allows SQL++ queries to treat foreign data as though it were stored in the system, making it possible to query &#x201c;legacy&#x201d; 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 class="source">
+<div class="source">
+<pre>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&#x2019;s declared type must be UUID in this case.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div class="source">
+<div class="source">
+<pre>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&#x2019;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 class="source">
+<div class="source">
+<pre>CREATE EXTERNAL DATASET LineItem(LineItemType) USING hdfs (
+  (&quot;hdfs&quot;=&quot;hdfs://HOST:PORT&quot;),
+  (&quot;path&quot;=&quot;HDFS_PATH&quot;),
+  (&quot;input-format&quot;=&quot;text-input-format&quot;),
+  (&quot;format&quot;=&quot;delimited-text&quot;),
+  (&quot;delimiter&quot;=&quot;|&quot;));
+</pre></div></div></div>
+<div class="section">
+<h4><a name="Indices"></a>Indices</h4>
+
+<div class="source">
+<div class="source">
+<pre>IndexSpecification ::= &lt;INDEX&gt; Identifier IfNotExists &lt;ON&gt; QualifiedName
+                       &quot;(&quot; ( IndexField ) ( &quot;,&quot; IndexField )* &quot;)&quot; ( &quot;type&quot; IndexType &quot;?&quot;)?
+                       ( &lt;ENFORCED&gt; )?
+IndexType          ::= &lt;BTREE&gt; | &lt;RTREE&gt; | &lt;KEYWORD&gt; | &lt;NGRAM&gt; &quot;(&quot; IntegerLiteral &quot;)&quot;
+</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&#x2019;s datatype is declared as open <b>and</b> if the field&#x2019;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>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div class="source">
+<div class="source">
+<pre>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-predeclared) sendTime 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 sendTime field.</p></div>
+<div class="section">
+<h4><a name="Example"></a>Example</h4>
+
+<div class="source">
+<div class="source">
+<pre>CREATE INDEX gbSendTimeIdx ON GleambookMessages(sendTime: datetime?) TYPE BTREE ENFORCED;
+</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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>CREATE INDEX gbSenderLocIndex ON GleambookMessages(&quot;sender-location&quot;) 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 class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>CREATE INDEX fbMessageIdx ON GleambookMessages(message) TYPE KEYWORD;
+</pre></div></div></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 SQL++ queries. The body of a function can be any SQL++ expression involving the function&#x2019;s parameters.</p>
+
+<div class="source">
+<div class="source">
+<pre>FunctionSpecification ::= &quot;FUNCTION&quot; FunctionOrTypeName IfNotExists ParameterList &quot;{&quot; Expression &quot;}&quot;
+</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 class="source">
+<div class="source">
+<pre>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 class="section">
+<h4><a name="Removal"></a>Removal</h4>
+
+<div class="source">
+<div class="source">
+<pre>DropStatement       ::= &quot;DROP&quot; ( &quot;DATAVERSE&quot; Identifier IfExists
+                               | &quot;TYPE&quot; FunctionOrTypeName IfExists
+                               | &quot;DATASET&quot; QualifiedName IfExists
+                               | &quot;INDEX&quot; DoubleQualifiedName IfExists
+                               | &quot;FUNCTION&quot; FunctionSignature IfExists )
+IfExists            ::= ( &quot;IF&quot; &quot;EXISTS&quot; )?
+</pre></div></div>
+<p>The DROP statement in SQL++ is the inverse of the CREATE statement. It can be used to drop dataverses, datatypes, datasets, indexes, and functions.</p>
+<p>The following examples illustrate some uses of the DROP statement.</p>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>DROP DATASET GleambookUsers IF EXISTS;
+
+DROP INDEX GleambookMessages.gbSenderLocIndex;
+
+DROP TYPE TinySocial2.GleambookUserType;
+
+DROP FUNCTION friendInfo@1;
+
+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 SQL++ 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="ImportExport_Statements"></a>Import/Export Statements</h3>
+
+<div class="source">
+<div class="source">
+<pre>LoadStatement  ::= &lt;LOAD&gt; &lt;DATASET&gt; QualifiedName &lt;USING&gt; AdapterName Configuration ( &lt;PRE-SORTED&gt; )?
+</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 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 class="source">
+<div class="source">
+<pre> LOAD DATASET GleambookUsers USING localfs
+    ((&quot;path&quot;=&quot;127.0.0.1:///Users/bignosqlfan/tinysocialnew/gbu.adm&quot;),(&quot;format&quot;=&quot;adm&quot;));
+</pre></div></div></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 class="source">
+<div class="source">
+<pre>InsertStatement ::= &lt;INSERT&gt; &lt;INTO&gt; QualifiedName Query
+</pre></div></div>
+<p>The SQL++ INSERT statement is used to insert new data into a dataset. The data to be inserted comes from a SQL++ query expression. This expression can be as simple as a constant expression, or in general it can be any legal SQL++ query. If the target dataset has an auto-generated primary key field, the insert statement should not include a value for that field in it. (The system will automatically extend the provided object with this additional field and a corresponding value.) 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. The following example illustrates a query-based insertion.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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 class="source">
+<div class="source">
+<pre>UpsertStatement ::= &lt;UPSERT&gt; &lt;INTO&gt; QualifiedName Query
+</pre></div></div>
+<p>The SQL++ UPSERT statement syntactically mirrors the INSERT statement discussed above. The difference lies in its semantics, which for UPSERT are &#x201c;add or replace&#x201d; instead of the INSERT &#x201c;add if not present, else error&#x201d; semantics. Whereas an INSERT can fail if another object already exists with the specified key, the analogous UPSERT will replace the previous object&#x2019;s value with that of the new object in such cases.</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 class="source">
+<div class="source">
+<pre>UPSERT INTO UsersCopy (SELECT VALUE user FROM GleambookUsers user)
+</pre></div></div>
+<p>*Editor&#x2019;s note: Upserts currently work in AQL but are not yet enabled (at the moment) in SQL++.</p></div></div></div>
+<div class="section">
+<h3><a name="DELETEs"></a><a name="Deletes" id="Deletes">DELETEs</a></h3>
+
+<div class="source">
+<div class="source">
+<pre>DeleteStatement ::= &lt;DELETE&gt; &lt;FROM&gt; QualifiedName ( ( &lt;AS&gt; )? Variable )? ( &lt;WHERE&gt; Expression )?
+</pre></div></div>
+<p>The SQL++ 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 following examples illustrate single-object deletions.</p>
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>DELETE FROM GleambookUsers user WHERE user.id = 8;
+</pre></div></div></div>
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>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>PATH </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>POLICY </td>
+      
+<td>PRE-SORTED </td>
+      
+<td>PRIMARY </td>
+      
+<td>RAW </td>
+      
+<td>REFRESH </td>
+      
+<td>RETURN </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>RTREE </td>
+      
+<td>RUN </td>
+      
+<td>SATISFIES </td>
+      
+<td>SECONDARY </td>
+      
+<td>SELECT </td>
+      
+<td>SET </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>SOME </td>
+      
+<td>TEMPORARY </td>
+      
+<td>THEN </td>
+      
+<td>TYPE </td>
+      
+<td>UNKNOWN </td>
+      
+<td>UNNEST </td>
+    </tr>
+    
+<tr class="b">
+      
+<td>UPDATE </td>
+      
+<td>USE </td>
+      
+<td>USING </td>
+      
+<td>VALUE </td>
+      
+<td>WHEN </td>
+      
+<td>WHERE </td>
+    </tr>
+    
+<tr class="a">
+      
+<td>WITH </td>
+      
+<td>WRITE </td>
+      
+<td> </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 class="source">
+<div class="source">
+<pre>      SET &lt;IDENTIFIER&gt; &lt;STRING_LITERAL&gt;
+</pre></div></div>
+<p>As parameter identifiers are qualified names (containing a &#x2018;.&#x2019;) 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>
+<p><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:</p>
+  
+<ul>
+    
+<li><i>p</i> &lt; 0 or <i>p</i> &gt; the total number of cores in a cluster: the system will use all available cores in the  cluster;</li>
+  </ul>
+  
+<ul>
+    
+<li><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;</li>
+  </ul>
+  
+<ul>
+    
+<li>all other cases: the system will use the user-specified number as the maximum number of CPU cores to use for  executing the query.</li>
+  </ul></li>
+</ul>
+<div class="section">
+<div class="section">
+<div class="section">
+<h5><a name="Example"></a>Example</h5>
+
+<div class="source">
+<div class="source">
+<pre>SET `compiler.parallelism` &quot;16&quot;
+
+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>
+</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, &#x201c;B&#x201d; 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 class="source">
+<div class="source">
+<pre>SET `compiler.groupmemory` &quot;64MB&quot;
+
+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 class="source">
+<div class="source">
+<pre>SET `compiler.sortmemory` &quot;67108864&quot;
+
+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 class="source">
+<div class="source">
+<pre>SET `compiler.joinmemory` &quot;132000KB&quot;
+
+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>
+            </div>
+          </div>
+
+    <hr/>
+
+    <footer>
+            <div class="container-fluid">
+              <div class="row span12">Copyright &copy;                    2017
+                        <a href="https://www.apache.org/">The Apache Software Foundation</a>.
+            All Rights Reserved.      
+                    
+      </div>
+
+                                                                  <?xml version="1.0" encoding="UTF-8"?>
+<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>
+    </footer>
+  </body>
+</html>
diff --git a/content/docs/0.9.1/sqlpp/primer-sqlpp.html b/content/docs/0.9.1/sqlpp/primer-sqlpp.html
new file mode 100644
index 0000000..b109dba
--- /dev/null
+++ b/content/docs/0.9.1/sqlpp/primer-sqlpp.html
@@ -0,0 +1,948 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at 2017-04-24
+ | Rendered using Apache Maven Fluido Skin 1.3.0
+-->
+<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="20170424" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>AsterixDB &#x2013; AsterixDB 101: An ADM and SQL++ Primer</title>
+    <link rel="stylesheet" href="../css/apache-maven-fluido-1.3.0.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.3.0.min.js"></script>
+
+                          
+        
+<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+        ga('create', 'UA-41536543-1', 'uci.edu');
+        ga('send', 'pageview');</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: 2017-04-24</li>
+                      
+                
+                    
+                 <li id="projectVersion" class="pull-right">Version: 0.9.1</li>
+      
+                                            <li class="divider pull-right">|</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="span3">
+          <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">
+          <i class="none"></i>
+        Option 1: using NCService</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../ansible.html" title="Option 2: using Ansible">
+          <i class="none"></i>
+        Option 2: using Ansible</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aws.html" title="Option 3: using Amazon Web Services">
+          <i class="none"></i>
+        Option 3: using Amazon Web Services</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../yarn.html" title="Option 4: using YARN">
+          <i class="none"></i>
+        Option 4: using YARN</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../install.html" title="Option 5: using Managix (deprecated)">
+          <i class="none"></i>
+        Option 5: using Managix (deprecated)</a>
+            </li>
+                              <li class="nav-header">AsterixDB Primer</li>
+                                
+      <li class="active">
+    
+            <a href="#"><i class="none"></i>Option 1: using SQL++</a>
+          </li>
+                  
+      <li>
+    
+                          <a href="../aql/primer.html" title="Option 2: using AQL">
+          <i class="none"></i>
+        Option 2: using AQL</a>
+            </li>
+                              <li class="nav-header">Data Model</li>
+                                
+      <li>
+    
+                          <a href="../datamodel.html" title="The Asterix Data Model">
+          <i class="none"></i>
+        The Asterix Data Model</a>
+            </li>
+                              <li class="nav-header">Queries - SQL++</li>
+                                
+      <li>
+    
+                          <a href="../sqlpp/manual.html" title="The SQL++ Query Language">
+          <i class="none"></i>
+        The SQL++ Query Language</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../sqlpp/builtins.html" title="Builtin Functions">
+          <i class="none"></i>
+        Builtin Functions</a>
+            </li>
+                              <li class="nav-header">Queries - AQL</li>
+                                
+      <li>
+    
+                          <a href="../aql/manual.html" title="The Asterix Query Language (AQL)">
+          <i class="none"></i>
+        The Asterix Query Language (AQL)</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/builtins.html" title="Builtin Functions">
+          <i class="none"></i>
+        Builtin Functions</a>
+            </li>
+                              <li class="nav-header">API/SDK</li>
+                                
+      <li>
+    
+                          <a href="../api.html" title="HTTP API">
+          <i class="none"></i>
+        HTTP API</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../csv.html" title="CSV Output">
+          <i class="none"></i>
+        CSV Output</a>
+            </li>
+                              <li class="nav-header">Advanced Features</li>
+                                
+      <li>
+    
+                          <a href="../aql/fulltext.html" title="Support of Full-text Queries">
+          <i class="none"></i>
+        Support of Full-text Queries</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/externaldata.html" title="Accessing External Data">
+          <i class="none"></i>
+        Accessing External Data</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../feeds/tutorial.html" title="Support for Data Ingestion">
+          <i class="none"></i>
+        Support for Data Ingestion</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../udf.html" title="User Defined Functions">
+          <i class="none"></i>
+        User Defined Functions</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
+          <i class="none"></i>
+        Filter-Based LSM Index Acceleration</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/similarity.html" title="Support of Similarity Queries">
+          <i class="none"></i>
+        Support of Similarity Queries</a>
+            </li>
+            </ul>
+                
+                    
+                
+          <hr class="divider" />
+
+           <div id="poweredBy">
+                            <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="span9" >
+                                  
+            <!-- ! 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"></a>Welcome to AsterixDB!</h2>
+<p>This document introduces the main features of AsterixDB&#x2019;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 &#x201c;AsterixDB user experience&#x201d;. 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&#x2019;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&#x2019;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&#x2019;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_Semistructed_Data_in_AsterixDB"></a>ADM: Modeling Semistructed 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_Datatypes_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&#x2014;short for &#x201c;data universe&#x201d;&#x2014;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 &#x201c;empty&#x201d;; 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&#x2019;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&#x2019;ll start by defining a dataverse called &#x201c;TinySocial&#x201d; to hold our datatypes and datasets. The AsterixDB data model (ADM) is essentially a superset of JSON&#x2014;it&#x2019;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&#x2019; 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 class="source">
+<div class="source">
+<pre>    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&#x2019;s APIs), each Chirp message actually embeds an instance of the sending user&#x2019;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&#x2019;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&#x2014;it may be present or missing, but when it&#x2019;s present, its value&#x2019;s data type will conform to the datatype&#x2019;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 &#x201c;closed&#x201d;, 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&#x2019;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 &#x201c;just there&#x201d; in instances of open datatypes is stored with each instance&#x2014;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 class="source">
+<div class="source">
+<pre>    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&#x2019;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&#x2019;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&#x2014;AsterixDB is now ready for data, so let&#x2019;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 class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    INSERT INTO ChirpUsers
+    ([
+    {&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:18,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},
+    {&quot;screenName&quot;:&quot;ColineGeyer@63&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:121,&quot;statusesCount&quot;:362,&quot;name&quot;:&quot;Coline Geyer&quot;,&quot;followersCount&quot;:17159},
+    {&quot;screenName&quot;:&quot;NilaMilliron_tw&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:445,&quot;statusesCount&quot;:164,&quot;name&quot;:&quot;Nila Milliron&quot;,&quot;followersCount&quot;:22649},
+    {&quot;screenName&quot;:&quot;ChangEwing_573&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:182,&quot;statusesCount&quot;:394,&quot;name&quot;:&quot;Chang Ewing&quot;,&quot;followersCount&quot;:32136}
+    ]);
+</pre></div></div>
+<p><a href="../data/chm.adm">Chirp Messages</a></p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    INSERT INTO ChirpMessages
+    ([
+    {&quot;chirpId&quot;:&quot;1&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;47.44,80.65&quot;),&quot;sendTime&quot;:datetime(&quot;2008-04-26T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-z&quot;,&quot;customization&quot;}},&quot;messageText&quot;:&quot; love product-z its customization is good:)&quot;},
+    {&quot;chirpId&quot;:&quot;2&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;ColineGeyer@63&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:121,&quot;statusesCount&quot;:362,&quot;name&quot;:&quot;Coline Geyer&quot;,&quot;followersCount&quot;:17159},&quot;senderLocation&quot;:point(&quot;32.84,67.14&quot;),&quot;sendTime&quot;:datetime(&quot;2010-05-13T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;ccast&quot;,&quot;shortcut-menu&quot;}},&quot;messageText&quot;:&quot; like ccast its shortcut-menu is awesome:)&quot;},
+    {&quot;chirpId&quot;:&quot;3&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;29.72,75.8&quot;),&quot;sendTime&quot;:datetime(&quot;2006-11-04T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-w&quot;,&quot;speed&quot;}},&quot;messageText&quot;:&quot; like product-w the speed is good:)&quot;},
+    {&quot;chirpId&quot;:&quot;4&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;39.28,70.48&quot;),&quot;sendTime&quot;:datetime(&quot;2011-12-26T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-b&quot;,&quot;voice-command&quot;}},&quot;messageText&quot;:&quot; like product-b the voice-command is mind-blowing:)&quot;},
+    {&quot;chirpId&quot;:&quot;5&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;40.09,92.69&quot;),&quot;sendTime&quot;:datetime(&quot;2006-08-04T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-w&quot;,&quot;speed&quot;}},&quot;messageText&quot;:&quot; can't stand product-w its speed is terrible:(&quot;},
+    {&quot;chirpId&quot;:&quot;6&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;ColineGeyer@63&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:121,&quot;statusesCount&quot;:362,&quot;name&quot;:&quot;Coline Geyer&quot;,&quot;followersCount&quot;:17159},&quot;senderLocation&quot;:point(&quot;47.51,83.99&quot;),&quot;sendTime&quot;:datetime(&quot;2010-05-07T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;x-phone&quot;,&quot;voice-clarity&quot;}},&quot;messageText&quot;:&quot; like x-phone the voice-clarity is good:)&quot;},
+    {&quot;chirpId&quot;:&quot;7&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;ChangEwing_573&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:182,&quot;statusesCount&quot;:394,&quot;name&quot;:&quot;Chang Ewing&quot;,&quot;followersCount&quot;:32136},&quot;senderLocation&quot;:point(&quot;36.21,72.6&quot;),&quot;sendTime&quot;:datetime(&quot;2011-08-25T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-y&quot;,&quot;platform&quot;}},&quot;messageText&quot;:&quot; like product-y the platform is good&quot;},
+    {&quot;chirpId&quot;:&quot;8&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;46.05,93.34&quot;),&quot;sendTime&quot;:datetime(&quot;2005-10-14T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-z&quot;,&quot;shortcut-menu&quot;}},&quot;messageText&quot;:&quot; like product-z the shortcut-menu is awesome:)&quot;},
+    {&quot;chirpId&quot;:&quot;9&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NathanGiesen@211&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:39339,&quot;statusesCount&quot;:473,&quot;name&quot;:&quot;Nathan Giesen&quot;,&quot;followersCount&quot;:49416},&quot;senderLocation&quot;:point(&quot;36.86,74.62&quot;),&quot;sendTime&quot;:datetime(&quot;2012-07-21T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;ccast&quot;,&quot;voicemail-service&quot;}},&quot;messageText&quot;:&quot; love ccast its voicemail-service is awesome&quot;},
+    {&quot;chirpId&quot;:&quot;10&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;ColineGeyer@63&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:121,&quot;statusesCount&quot;:362,&quot;name&quot;:&quot;Coline Geyer&quot;,&quot;followersCount&quot;:17159},&quot;senderLocation&quot;:point(&quot;29.15,76.53&quot;),&quot;sendTime&quot;:datetime(&quot;2008-01-26T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;ccast&quot;,&quot;voice-clarity&quot;}},&quot;messageText&quot;:&quot; hate ccast its voice-clarity is OMG:(&quot;},
+    {&quot;chirpId&quot;:&quot;11&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;NilaMilliron_tw&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:445,&quot;statusesCount&quot;:164,&quot;name&quot;:&quot;Nila Milliron&quot;,&quot;followersCount&quot;:22649},&quot;senderLocation&quot;:point(&quot;37.59,68.42&quot;),&quot;sendTime&quot;:datetime(&quot;2008-03-09T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;x-phone&quot;,&quot;platform&quot;}},&quot;messageText&quot;:&quot; can't stand x-phone its platform is terrible&quot;},
+    {&quot;chirpId&quot;:&quot;12&quot;,&quot;user&quot;:{&quot;screenName&quot;:&quot;OliJackson_512&quot;,&quot;lang&quot;:&quot;en&quot;,&quot;friendsCount&quot;:445,&quot;statusesCount&quot;:164,&quot;name&quot;:&quot;Oli Jackson&quot;,&quot;followersCount&quot;:22649},&quot;senderLocation&quot;:point(&quot;24.82,94.63&quot;),&quot;sendTime&quot;:datetime(&quot;2010-02-13T10:10:00&quot;),&quot;referredTopics&quot;:{{&quot;product-y&quot;,&quot;voice-command&quot;}},&quot;messageText&quot;:&quot; like product-y the voice-command is amazing:)&quot;}
+    ]);
+</pre></div></div>
+<p><a href="../data/gbu.adm">Gleambook Users</a></p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    INSERT INTO GleambookUsers
+    ([
+    {&quot;id&quot;:1,&quot;alias&quot;:&quot;Margarita&quot;,&quot;name&quot;:&quot;MargaritaStoddard&quot;,&quot;nickname&quot;:&quot;Mags&quot;,&quot;userSince&quot;:datetime(&quot;2012-08-20T10:10:00&quot;),&quot;friendIds&quot;:{{2,3,6,10}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Codetechno&quot;,&quot;startDate&quot;:date(&quot;2006-08-06&quot;)},{&quot;organizationName&quot;:&quot;geomedia&quot;,&quot;startDate&quot;:date(&quot;2010-06-17&quot;),&quot;endDate&quot;:date(&quot;2010-01-26&quot;)}],&quot;gender&quot;:&quot;F&quot;},
+    {&quot;id&quot;:2,&quot;alias&quot;:&quot;Isbel&quot;,&quot;name&quot;:&quot;IsbelDull&quot;,&quot;nickname&quot;:&quot;Izzy&quot;,&quot;userSince&quot;:datetime(&quot;2011-01-22T10:10:00&quot;),&quot;friendIds&quot;:{{1,4}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Hexviafind&quot;,&quot;startDate&quot;:date(&quot;2010-04-27&quot;)}]},
+    {&quot;id&quot;:3,&quot;alias&quot;:&quot;Emory&quot;,&quot;name&quot;:&quot;EmoryUnk&quot;,&quot;userSince&quot;:datetime(&quot;2012-07-10T10:10:00&quot;),&quot;friendIds&quot;:{{1,5,8,9}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;geomedia&quot;,&quot;startDate&quot;:date(&quot;2010-06-17&quot;),&quot;endDate&quot;:date(&quot;2010-01-26&quot;)}]},
+    {&quot;id&quot;:4,&quot;alias&quot;:&quot;Nicholas&quot;,&quot;name&quot;:&quot;NicholasStroh&quot;,&quot;userSince&quot;:datetime(&quot;2010-12-27T10:10:00&quot;),&quot;friendIds&quot;:{{2}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Zamcorporation&quot;,&quot;startDate&quot;:date(&quot;2010-06-08&quot;)}]},
+    {&quot;id&quot;:5,&quot;alias&quot;:&quot;Von&quot;,&quot;name&quot;:&quot;VonKemble&quot;,&quot;userSince&quot;:datetime(&quot;2010-01-05T10:10:00&quot;),&quot;friendIds&quot;:{{3,6,10}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Kongreen&quot;,&quot;startDate&quot;:date(&quot;2010-11-27&quot;)}]},
+    {&quot;id&quot;:6,&quot;alias&quot;:&quot;Willis&quot;,&quot;name&quot;:&quot;WillisWynne&quot;,&quot;userSince&quot;:datetime(&quot;2005-01-17T10:10:00&quot;),&quot;friendIds&quot;:{{1,3,7}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;jaydax&quot;,&quot;startDate&quot;:date(&quot;2009-05-15&quot;)}]},
+    {&quot;id&quot;:7,&quot;alias&quot;:&quot;Suzanna&quot;,&quot;name&quot;:&quot;SuzannaTillson&quot;,&quot;userSince&quot;:datetime(&quot;2012-08-07T10:10:00&quot;),&quot;friendIds&quot;:{{6}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Labzatron&quot;,&quot;startDate&quot;:date(&quot;2011-04-19&quot;)}]},
+    {&quot;id&quot;:8,&quot;alias&quot;:&quot;Nila&quot;,&quot;name&quot;:&quot;NilaMilliron&quot;,&quot;userSince&quot;:datetime(&quot;2008-01-01T10:10:00&quot;),&quot;friendIds&quot;:{{3}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Plexlane&quot;,&quot;startDate&quot;:date(&quot;2010-02-28&quot;)}]},
+    {&quot;id&quot;:9,&quot;alias&quot;:&quot;Woodrow&quot;,&quot;name&quot;:&quot;WoodrowNehling&quot;,&quot;nickname&quot;:&quot;Woody&quot;,&quot;userSince&quot;:datetime(&quot;2005-09-20T10:10:00&quot;),&quot;friendIds&quot;:{{3,10}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;Zuncan&quot;,&quot;startDate&quot;:date(&quot;2003-04-22&quot;),&quot;endDate&quot;:date(&quot;2009-12-13&quot;)}]},
+    {&quot;id&quot;:10,&quot;alias&quot;:&quot;Bram&quot;,&quot;name&quot;:&quot;BramHatch&quot;,&quot;userSince&quot;:datetime(&quot;2010-10-16T10:10:00&quot;),&quot;friendIds&quot;:{{1,5,9}},&quot;employment&quot;:[{&quot;organizationName&quot;:&quot;physcane&quot;,&quot;startDate&quot;:date(&quot;2007-06-05&quot;),&quot;endDate&quot;:date(&quot;2011-11-05&quot;)}]}
+    ]);
+</pre></div></div>
+<p><a href="../data/gbm.adm">Gleambook Messages</a></p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    INSERT INTO GleambookMessages
+    ([
+    {&quot;messageId&quot;:1,&quot;authorId&quot;:3,&quot;inResponseTo&quot;:2,&quot;senderLocation&quot;:point(&quot;47.16,77.75&quot;),&quot;message&quot;:&quot; love product-b its shortcut-menu is awesome:)&quot;},
+    {&quot;messageId&quot;:2,&quot;authorId&quot;:1,&quot;inResponseTo&quot;:4,&quot;senderLocation&quot;:point(&quot;41.66,80.87&quot;),&quot;message&quot;:&quot; dislike x-phone its touch-screen is horrible&quot;},
+    {&quot;messageId&quot;:3,&quot;authorId&quot;:2,&quot;inResponseTo&quot;:4,&quot;senderLocation&quot;:point(&quot;48.09,81.01&quot;),&quot;message&quot;:&quot; like product-y the plan is amazing&quot;},
+    {&quot;messageId&quot;:4,&quot;authorId&quot;:1,&quot;inResponseTo&quot;:2,&quot;senderLocation&quot;:point(&quot;37.73,97.04&quot;),&quot;message&quot;:&quot; can't stand acast the network is horrible:(&quot;},
+    {&quot;messageId&quot;:5,&quot;authorId&quot;:6,&quot;inResponseTo&quot;:2,&quot;senderLocation&quot;:point(&quot;34.7,90.76&quot;),&quot;message&quot;:&quot; love product-b the customization is mind-blowing&quot;},
+    {&quot;messageId&quot;:6,&quot;authorId&quot;:2,&quot;inResponseTo&quot;:1,&quot;senderLocation&quot;:point(&quot;31.5,75.56&quot;),&quot;message&quot;:&quot; like product-z its platform is mind-blowing&quot;},
+    {&quot;messageId&quot;:7,&quot;authorId&quot;:5,&quot;inResponseTo&quot;:15,&quot;senderLocation&quot;:point(&quot;32.91,85.05&quot;),&quot;message&quot;:&quot; dislike product-b the speed is horrible&quot;},
+    {&quot;messageId&quot;:8,&quot;authorId&quot;:1,&quot;inResponseTo&quot;:11,&quot;senderLocation&quot;:point(&quot;40.33,80.87&quot;),&quot;message&quot;:&quot; like ccast the 3G is awesome:)&quot;},
+    {&quot;messageId&quot;:9,&quot;authorId&quot;:3,&quot;inResponseTo&quot;:12,&quot;senderLocation&quot;:point(&quot;34.45,96.48&quot;),&quot;message&quot;:&quot; love ccast its wireless is good&quot;},
+    {&quot;messageId&quot;:10,&quot;authorId&quot;:1,&quot;inResponseTo&quot;:12,&quot;senderLocation&quot;:point(&quot;42.5,70.01&quot;),&quot;message&quot;:&quot; can't stand product-w the touch-screen is terrible&quot;},
+    {&quot;messageId&quot;:11,&quot;authorId&quot;:1,&quot;inResponseTo&quot;:1,&quot;senderLocation&quot;:point(&quot;38.97,77.49&quot;),&quot;message&quot;:&quot; can't stand acast its plan is terrible&quot;},
+    {&quot;messageId&quot;:12,&quot;authorId&quot;:10,&quot;inResponseTo&quot;:6,&quot;senderLocation&quot;:point(&quot;42.26,77.76&quot;),&quot;message&quot;:&quot; can't stand product-z its voicemail-service is OMG:(&quot;},
+    {&quot;messageId&quot;:13,&quot;authorId&quot;:10,&quot;inResponseTo&quot;:4,&quot;senderLocation&quot;:point(&quot;42.77,78.92&quot;),&quot;message&quot;:&quot; dislike x-phone the voice-command is bad:(&quot;},
+    {&quot;messageId&quot;:14,&quot;authorId&quot;:9,&quot;inResponseTo&quot;:12,&quot;senderLocation&quot;:point(&quot;41.33,85.28&quot;),&quot;message&quot;:&quot; love acast its 3G is good:)&quot;},
+    {&quot;messageId&quot;:15,&quot;authorId&quot;:7,&quot;inResponseTo&quot;:11,&quot;senderLocation&quot;:point(&quot;44.47,67.11&quot;),&quot;message&quot;:&quot; like x-phone the voicemail-service is awesome&quot;}
+    ]);
+</pre></div></div></div>
+<div class="section">
+<h2><a name="SQL:_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&#x2014;AsterixDB&#x2019;s original query language&#x2014;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&#x2019;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&#x2019;s <i>not</i> the best use of a 512-node shared-nothing compute cluster.) But enough talk! Let&#x2019;s go ahead and try writing some queries and see about learning SQL++ by example. (Again, don&#x2019;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&#x2019;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 class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT VALUE user
+    FROM GleambookUsers user
+    WHERE user.id = 8;
+</pre></div></div>
+<p>As in SQL, the query&#x2019;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 class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 8, &quot;alias&quot;: &quot;Nila&quot;, &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;userSince&quot;: datetime(&quot;2008-01-01T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Plexlane&quot;, &quot;startDate&quot;: date(&quot;2010-02-28&quot;) } ] }
+</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&#x2019;s find the Gleambook users whose ids are in the range between 2 and 4:</p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT VALUE user
+    FROM GleambookUsers user
+    WHERE user.id &gt;= 2 AND user.id &lt;= 4;
+</pre></div></div>
+<p>This query&#x2019;s expected result, also evaluable using the primary index on user id, is:</p>
+
+<div class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 2, &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;userSince&quot;: datetime(&quot;2011-01-22T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 4 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Hexviafind&quot;, &quot;startDate&quot;: date(&quot;2010-04-27&quot;) } ], &quot;nickname&quot;: &quot;Izzy&quot; }
+    { &quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;userSince&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 8, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ] }
+    { &quot;id&quot;: 4, &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;userSince&quot;: datetime(&quot;2010-12-27T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Zamcorporation&quot;, &quot;startDate&quot;: date(&quot;2010-06-08&quot;) } ] }
+</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 class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT VALUE user
+    FROM GleambookUsers user
+    WHERE user.userSince &gt;= datetime('2010-07-22T00:00:00')
+      AND user.userSince &lt;= 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 class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;userSince&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;physcane&quot;, &quot;startDate&quot;: date(&quot;2007-06-05&quot;), &quot;endDate&quot;: date(&quot;2011-11-05&quot;) } ] }
+    { &quot;id&quot;: 2, &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;userSince&quot;: datetime(&quot;2011-01-22T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 4 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Hexviafind&quot;, &quot;startDate&quot;: date(&quot;2010-04-27&quot;) } ], &quot;nickname&quot;: &quot;Izzy&quot; }
+    { &quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;userSince&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 8, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ] }
+    { &quot;id&quot;: 4, &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;userSince&quot;: datetime(&quot;2010-12-27T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Zamcorporation&quot;, &quot;startDate&quot;: date(&quot;2010-06-08&quot;) } ] }
+</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 &#x201c;whole&#x201d;, 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 class="source">
+<div class="source">
+<pre>    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, &#x201c;uname&#x201d; and &#x201c;message&#x201d;, containing the user&#x2019;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 class="source">
+<div class="source">
+<pre>    { &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;message&quot;: &quot; love product-b the customization is mind-blowing&quot; }
+    { &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;message&quot;: &quot; love acast its 3G is good:)&quot; }
+    { &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; can't stand product-z its voicemail-service is OMG:(&quot; }
+    { &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; dislike x-phone the voice-command is bad:(&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot; }
+    { &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot; }
+    { &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-y the plan is amazing&quot; }
+    { &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love ccast its wireless is good&quot; }
+    { &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love product-b its shortcut-menu is awesome:)&quot; }
+    { &quot;uname&quot;: &quot;VonKemble&quot;, &quot;message&quot;: &quot; dislike product-b the speed is horrible&quot; }
+    { &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;message&quot;: &quot; like x-phone the voicemail-service is awesome&quot; }
+</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 class="source">
+<div class="source">
+<pre>    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 &#x201c;user&#x201d; variable) to hold the user object and another field (named after the &#x201c;msg&#x201d; 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 class="source">
+<div class="source">
+<pre>    { &quot;user&quot;: { &quot;id&quot;: 6, &quot;alias&quot;: &quot;Willis&quot;, &quot;name&quot;: &quot;WillisWynne&quot;, &quot;userSince&quot;: datetime(&quot;2005-01-17T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 3, 7 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;jaydax&quot;, &quot;startDate&quot;: date(&quot;2009-05-15&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 5, &quot;authorId&quot;: 6, &quot;inResponseTo&quot;: 2, &quot;senderLocation&quot;: point(&quot;34.7,90.76&quot;), &quot;message&quot;: &quot; love product-b the customization is mind-blowing&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 9, &quot;alias&quot;: &quot;Woodrow&quot;, &quot;name&quot;: &quot;WoodrowNehling&quot;, &quot;userSince&quot;: datetime(&quot;2005-09-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Zuncan&quot;, &quot;startDate&quot;: date(&quot;2003-04-22&quot;), &quot;endDate&quot;: date(&quot;2009-12-13&quot;) } ], &quot;nickname&quot;: &quot;Woody&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 14, &quot;authorId&quot;: 9, &quot;inResponseTo&quot;: 12, &quot;senderLocation&quot;: point(&quot;41.33,85.28&quot;), &quot;message&quot;: &quot; love acast its 3G is good:)&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;userSince&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;physcane&quot;, &quot;startDate&quot;: date(&quot;2007-06-05&quot;), &quot;endDate&quot;: date(&quot;2011-11-05&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 12, &quot;authorId&quot;: 10, &quot;inResponseTo&quot;: 6, &quot;senderLocation&quot;: point(&quot;42.26,77.76&quot;), &quot;message&quot;: &quot; can't stand product-z its voicemail-service is OMG:(&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;userSince&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;physcane&quot;, &quot;startDate&quot;: date(&quot;2007-06-05&quot;), &quot;endDate&quot;: date(&quot;2011-11-05&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 13, &quot;authorId&quot;: 10, &quot;inResponseTo&quot;: 4, &quot;senderLocation&quot;: point(&quot;42.77,78.92&quot;), &quot;message&quot;: &quot; dislike x-phone the voice-command is bad:(&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 8, &quot;authorId&quot;: 1, &quot;inResponseTo&quot;: 11, &quot;senderLocation&quot;: point(&quot;40.33,80.87&quot;), &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 10, &quot;authorId&quot;: 1, &quot;inResponseTo&quot;: 12, &quot;senderLocation&quot;: point(&quot;42.5,70.01&quot;), &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 11, &quot;authorId&quot;: 1, &quot;inResponseTo&quot;: 1, &quot;senderLocation&quot;: point(&quot;38.97,77.49&quot;), &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 2, &quot;authorId&quot;: 1, &quot;inResponseTo&quot;: 4, &quot;senderLocation&quot;: point(&quot;41.66,80.87&quot;), &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 4, &quot;authorId&quot;: 1, &quot;inResponseTo&quot;: 2, &quot;senderLocation&quot;: point(&quot;37.73,97.04&quot;), &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 2, &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;userSince&quot;: datetime(&quot;2011-01-22T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 4 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Hexviafind&quot;, &quot;startDate&quot;: date(&quot;2010-04-27&quot;) } ], &quot;nickname&quot;: &quot;Izzy&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 6, &quot;authorId&quot;: 2, &quot;inResponseTo&quot;: 1, &quot;senderLocation&quot;: point(&quot;31.5,75.56&quot;), &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 2, &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;userSince&quot;: datetime(&quot;2011-01-22T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 4 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Hexviafind&quot;, &quot;startDate&quot;: date(&quot;2010-04-27&quot;) } ], &quot;nickname&quot;: &quot;Izzy&quot; }, &quot;msg&quot;: { &quot;messageId&quot;: 3, &quot;authorId&quot;: 2, &quot;inResponseTo&quot;: 4, &quot;senderLocation&quot;: point(&quot;48.09,81.01&quot;), &quot;message&quot;: &quot; like product-y the plan is amazing&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;userSince&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 8, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 9, &quot;authorId&quot;: 3, &quot;inResponseTo&quot;: 12, &quot;senderLocation&quot;: point(&quot;34.45,96.48&quot;), &quot;message&quot;: &quot; love ccast its wireless is good&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;userSince&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 8, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 1, &quot;authorId&quot;: 3, &quot;inResponseTo&quot;: 2, &quot;senderLocation&quot;: point(&quot;47.16,77.75&quot;), &quot;message&quot;: &quot; love product-b its shortcut-menu is awesome:)&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 5, &quot;alias&quot;: &quot;Von&quot;, &quot;name&quot;: &quot;VonKemble&quot;, &quot;userSince&quot;: datetime(&quot;2010-01-05T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Kongreen&quot;, &quot;startDate&quot;: date(&quot;2010-11-27&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 7, &quot;authorId&quot;: 5, &quot;inResponseTo&quot;: 15, &quot;senderLocation&quot;: point(&quot;32.91,85.05&quot;), &quot;message&quot;: &quot; dislike product-b the speed is horrible&quot; } }
+    { &quot;user&quot;: { &quot;id&quot;: 7, &quot;alias&quot;: &quot;Suzanna&quot;, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-07T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 6 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Labzatron&quot;, &quot;startDate&quot;: date(&quot;2011-04-19&quot;) } ] }, &quot;msg&quot;: { &quot;messageId&quot;: 15, &quot;authorId&quot;: 7, &quot;inResponseTo&quot;: 11, &quot;senderLocation&quot;: point(&quot;44.47,67.11&quot;), &quot;message&quot;: &quot; like x-phone the voicemail-service is awesome&quot; } }
+</pre></div></div>
+<p>Finally (for now :-)), another less lazy and more explicit SQL++ way of achieving the result shown above is:</p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT VALUE {&quot;user&quot;: user, &quot;message&quot;: 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 &#x201c;uname&#x201d; and &#x201c;message&#x201d; are both simple SQL++ expressions themselves&#x2014;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&#x2019;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&#x2019;t (yet) have the know-how to intelligently choose among its alternatives. We therefore asked ourselves the classic question&#x2014;WWOD?&#x2014;What Would Oracle Do?&#x2014;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 class="source">
+<div class="source">
+<pre>    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 class="source">
+<div class="source">
+<pre>    { &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-z its platform is mind-blowing&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; like ccast the 3G is awesome:)&quot; }
+    { &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love ccast its wireless is good&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand product-w the touch-screen is terrible&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast its plan is terrible&quot; }
+    { &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; can't stand product-z its voicemail-service is OMG:(&quot; }
+    { &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;message&quot;: &quot; love acast its 3G is good:)&quot; }
+    { &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;message&quot;: &quot; love product-b its shortcut-menu is awesome:)&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; dislike x-phone its touch-screen is horrible&quot; }
+    { &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;message&quot;: &quot; like product-y the plan is amazing&quot; }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;message&quot;: &quot; can't stand acast the network is horrible:(&quot; }
+    { &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;message&quot;: &quot; love product-b the customization is mind-blowing&quot; }
+    { &quot;uname&quot;: &quot;VonKemble&quot;, &quot;message&quot;: &quot; dislike product-b the speed is horrible&quot; }
+    { &quot;uname&quot;: &quot;BramHatch&quot;, &quot;message&quot;: &quot; dislike x-phone the voice-command is bad:(&quot; }
+    { &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;message&quot;: &quot; like x-phone the voicemail-service is awesome&quot; }
+</pre></div></div>
+<p>(It is worth knowing, with respect to influencing AsterixDB&#x2019;s query evaluation, that <i>FROM</i> clauses&#x2014;<i>a.k.a.</i> joins&#x2014; are currently evaluated in order, with the &#x201c;left&#x201d; clause probing the data of the &#x201c;right&#x201d; 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&#x2019;s <i>FROM</i> clause syntax&#x2014;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&#x2019;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 class="source">
+<div class="source">
+<pre>    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 &#x201c;uname&#x201d; field with the user&#x2019;s name and a &#x201c;messages&#x201d; 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 recogizes the equivalence of such a query to an outerjoin, and it will use an efficient hash-based strategy when actually computing the query&#x2019;s result.)</p>
+<p>Here is this example query&#x2019;s expected output:</p>
+
+<div class="source">
+<div class="source">
+<pre>    { &quot;uname&quot;: &quot;WillisWynne&quot;, &quot;messages&quot;: [ &quot; love product-b the customization is mind-blowing&quot; ] }
+    { &quot;uname&quot;: &quot;NilaMilliron&quot;, &quot;messages&quot;: [  ] }
+    { &quot;uname&quot;: &quot;WoodrowNehling&quot;, &quot;messages&quot;: [ &quot; love acast its 3G is good:)&quot; ] }
+    { &quot;uname&quot;: &quot;BramHatch&quot;, &quot;messages&quot;: [ &quot; dislike x-phone the voice-command is bad:(&quot;, &quot; can't stand product-z its voicemail-service is OMG:(&quot; ] }
+    { &quot;uname&quot;: &quot;MargaritaStoddard&quot;, &quot;messages&quot;: [ &quot; dislike x-phone its touch-screen is horrible&quot;, &quot; can't stand acast the network is horrible:(&quot;, &quot; like ccast the 3G is awesome:)&quot;, &quot; can't stand product-w the touch-screen is terrible&quot;, &quot; can't stand acast its plan is terrible&quot; ] }
+    { &quot;uname&quot;: &quot;IsbelDull&quot;, &quot;messages&quot;: [ &quot; like product-y the plan is amazing&quot;, &quot; like product-z its platform is mind-blowing&quot; ] }
+    { &quot;uname&quot;: &quot;EmoryUnk&quot;, &quot;messages&quot;: [ &quot; love product-b its shortcut-menu is awesome:)&quot;, &quot; love ccast its wireless is good&quot; ] }
+    { &quot;uname&quot;: &quot;NicholasStroh&quot;, &quot;messages&quot;: [  ] }
+    { &quot;uname&quot;: &quot;VonKemble&quot;, &quot;messages&quot;: [ &quot; dislike product-b the speed is horrible&quot; ] }
+    { &quot;uname&quot;: &quot;SuzannaTillson&quot;, &quot;messages&quot;: [ &quot; like x-phone the voicemail-service is awesome&quot; ] }
+</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&#x2019;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&#x2019;s <i>WHERE</i> clause:</p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT cm1.messageText AS message,
+           (SELECT VALUE cm2.messageText
+            FROM ChirpMessages cm2
+            WHERE `spatial-distance`(cm1.senderLocation, cm2.senderLocation) &lt;= 1
+              AND cm2.chirpId &lt; cm1.chirpId) AS nearbyMessages
+    FROM ChirpMessages cm1;
+</pre></div></div>
+<p>Here is the expected result for this query:</p>
+
+<div class="source">
+<div class="source">
+<pre>    { &quot;message&quot;: &quot; can't stand x-phone its platform is terrible&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like ccast its shortcut-menu is awesome:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like product-w the speed is good:)&quot;, &quot;nearbyMessages&quot;: [ &quot; hate ccast its voice-clarity is OMG:(&quot; ] }
+    { &quot;message&quot;: &quot; like product-b the voice-command is mind-blowing:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like x-phone the voice-clarity is good:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like product-y the platform is good&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; love ccast its voicemail-service is awesome&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; love product-z its customization is good:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like product-y the voice-command is amazing:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; can't stand product-w its speed is terrible:(&quot;, &quot;nearbyMessages&quot;: [  ] }
+    { &quot;message&quot;: &quot; like product-z the shortcut-menu is awesome:)&quot;, &quot;nearbyMessages&quot;: [  ] }
+</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 &#x201c;similar&#x201d; to their name. AsterixDB supports a variety of &#x201c;fuzzy match&#x201d; 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++&#x2019;s operator-based syntax (~=) for testing whether or not two values are similar:</p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+    SET simfunction &quot;edit-distance&quot;;
+    SET simthreshold &quot;3&quot;;
+
+    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 class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 6, &quot;name&quot;: &quot;WillisWynne&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 8, &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;similarUsers&quot;: [ { &quot;chirpScreenname&quot;: &quot;NilaMilliron_tw&quot;, &quot;chirpName&quot;: &quot;Nila Milliron&quot; } ] }
+    { &quot;id&quot;: 9, &quot;name&quot;: &quot;WoodrowNehling&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 10, &quot;name&quot;: &quot;BramHatch&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 1, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 2, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 3, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 4, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 5, &quot;name&quot;: &quot;VonKemble&quot;, &quot;similarUsers&quot;: [  ] }
+    { &quot;id&quot;: 7, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;similarUsers&quot;: [  ] }
+</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 &#x201c;some&#x201d; (existentially quantified) and &#x201c;all&#x201d; (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 class="source">
+<div class="source">
+<pre>    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 class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 6, &quot;alias&quot;: &quot;Willis&quot;, &quot;name&quot;: &quot;WillisWynne&quot;, &quot;userSince&quot;: datetime(&quot;2005-01-17T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 3, 7 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;jaydax&quot;, &quot;startDate&quot;: date(&quot;2009-05-15&quot;) } ] }
+    { &quot;id&quot;: 8, &quot;alias&quot;: &quot;Nila&quot;, &quot;name&quot;: &quot;NilaMilliron&quot;, &quot;userSince&quot;: datetime(&quot;2008-01-01T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Plexlane&quot;, &quot;startDate&quot;: date(&quot;2010-02-28&quot;) } ] }
+    { &quot;id&quot;: 1, &quot;alias&quot;: &quot;Margarita&quot;, &quot;name&quot;: &quot;MargaritaStoddard&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2, 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Codetechno&quot;, &quot;startDate&quot;: date(&quot;2006-08-06&quot;) }, { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ], &quot;nickname&quot;: &quot;Mags&quot;, &quot;gender&quot;: &quot;F&quot; }
+    { &quot;id&quot;: 2, &quot;alias&quot;: &quot;Isbel&quot;, &quot;name&quot;: &quot;IsbelDull&quot;, &quot;userSince&quot;: datetime(&quot;2011-01-22T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 4 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Hexviafind&quot;, &quot;startDate&quot;: date(&quot;2010-04-27&quot;) } ], &quot;nickname&quot;: &quot;Izzy&quot; }
+    { &quot;id&quot;: 4, &quot;alias&quot;: &quot;Nicholas&quot;, &quot;name&quot;: &quot;NicholasStroh&quot;, &quot;userSince&quot;: datetime(&quot;2010-12-27T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 2 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Zamcorporation&quot;, &quot;startDate&quot;: date(&quot;2010-06-08&quot;) } ] }
+    { &quot;id&quot;: 5, &quot;alias&quot;: &quot;Von&quot;, &quot;name&quot;: &quot;VonKemble&quot;, &quot;userSince&quot;: datetime(&quot;2010-01-05T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3, 6, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Kongreen&quot;, &quot;startDate&quot;: date(&quot;2010-11-27&quot;) } ] }
+    { &quot;id&quot;: 7, &quot;alias&quot;: &quot;Suzanna&quot;, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;userSince&quot;: datetime(&quot;2012-08-07T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 6 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Labzatron&quot;, &quot;startDate&quot;: date(&quot;2011-04-19&quot;) } ] }
+</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 class="source">
+<div class="source">
+<pre>    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 class="source">
+<div class="source">
+<pre>    { &quot;id&quot;: 9, &quot;alias&quot;: &quot;Woodrow&quot;, &quot;name&quot;: &quot;WoodrowNehling&quot;, &quot;userSince&quot;: datetime(&quot;2005-09-20T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 3, 10 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;Zuncan&quot;, &quot;startDate&quot;: date(&quot;2003-04-22&quot;), &quot;endDate&quot;: date(&quot;2009-12-13&quot;) } ], &quot;nickname&quot;: &quot;Woody&quot; }
+    { &quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;userSince&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;physcane&quot;, &quot;startDate&quot;: date(&quot;2007-06-05&quot;), &quot;endDate&quot;: date(&quot;2011-11-05&quot;) } ] }
+    { &quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;userSince&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friendIds&quot;: {{ 1, 5, 8, 9 }}, &quot;employment&quot;: [ { &quot;organizationName&quot;: &quot;geomedia&quot;, &quot;startDate&quot;: date(&quot;2010-06-17&quot;), &quot;endDate&quot;: date(&quot;2010-01-26&quot;) } ] }
+</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 class="source">
+<div class="source">
+<pre>    USE TinySocial;
+
+    SELECT COUNT(gbu) AS numUsers FROM GleambookUsers gbu;
+</pre></div></div>
+<p>This query&#x2019;s result will be:</p>
+
+<div class="source">
+<div class="source">
+<pre>    { &quot;numUsers&quot;: 10 }
+</pre></div></div>
+<p>If an &#x201c;unwrapped&#x201d; value is preferred, the following variant could be used instead:</p>
+
+<div class="source">
+<div class="source">
+<pre>    SELECT VALUE COUNT(gbu) FROM GleambookUsers gbu;
+</pre></div></div>
+<p>This time the result will simply be:</p>
+
+<div class="source">
+<div class="source">
+<pre>    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&#x2014;and also more explicit&#x2014;way to express the query above:</p>
+
+<div class="source">
+<div class="source">
+<pre>    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 _ARRAY<i>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 _ARRAY<i>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 class="source">
+<div class="source">
+<pre>    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&#x2019;s Chirp screen-name. Unlike SQL, where data is tabular&#x2014;flat&#x2014;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&#x2019;s screen name). In the context of the <i>SELECT</i> clause, <i>uid</i> is bound to the chirper&#x2019;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&#x2019;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&#x2019;s screen name is accessed via a path syntax that traverses each chirp&#x2019;s nested object structure.</p>
+<p>Here is the expected result for this query over the sample data:</p>
+
+<div class="source">
+<div class="source">
+<pre>    { &quot;user&quot;: &quot;ChangEwing_573&quot;, &quot;count&quot;: 1 }
+    { &quot;user&quot;: &quot;OliJackson_512&quot;, &quot;count&quot;: 1 }
+    { &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: 3 }
+    { &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: 6 }
+    { &quot;user&quot;: &quot;NilaMilliron_tw&quot;, &quot;count&quot;: 1 }
+</pre></div></div></div>
+<div class="section">
+<h3><a name="Query_9-B_-_Hash-Based_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 class="source">
+<div class="source">
+<pre>    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 class="source">
+<div class="source">
+<pre>    { &quot;user&quot;: &quot;OliJackson_512&quot;, &quot;count&quot;: 1 }
+    { &quot;user&quot;: &quot;ChangEwing_573&quot;, &quot;count&quot;: 1 }
+    { &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: 3 }
+    { &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: 6 }
+    { &quot;user&quot;: &quot;NilaMilliron_tw&quot;, &quot;count&quot;: 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 class="source">
+<div class="source">
+<pre>    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 class="source">
+<div class="source">
+<pre>    { &quot;user&quot;: &quot;NathanGiesen@211&quot;, &quot;count&quot;: 6 }
+    { &quot;user&quot;: &quot;ColineGeyer@63&quot;, &quot;count&quot;: 3 }
+    { &quot;user&quot;: &quot;ChangEwing_573&quot;, &quot;count&quot;: 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 class="source">
+<div class="source">
+<pre>    USE TinySocial;
+    SET simfunction &quot;jaccard&quot;;
+    SET simthreshold &quot;0.3&quot;;
+
+    SELECT cm1 AS chirp,
+           (SELECT VALUE cm2.chirpId
+            FROM ChirpMessages cm2
+            WHERE cm2.referredTopics ~= cm1.referredTopics
+              AND cm2.chirpId &gt; 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 &#x201c;similar&#x201d; 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&#x2019;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 class="source">
+<div class="source">
+<pre>    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;11&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NilaMilliron_tw&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 445, &quot;statusesCount&quot;: 164, &quot;name&quot;: &quot;Nila Milliron&quot;, &quot;followersCount&quot;: 22649 }, &quot;senderLocation&quot;: point(&quot;37.59,68.42&quot;), &quot;sendTime&quot;: datetime(&quot;2008-03-09T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;x-phone&quot;, &quot;platform&quot; }}, &quot;messageText&quot;: &quot; can't stand x-phone its platform is terrible&quot; }, &quot;similarChirps&quot;: [ &quot;6&quot;, &quot;7&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;2&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 121, &quot;statusesCount&quot;: 362, &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followersCount&quot;: 17159 }, &quot;senderLocation&quot;: point(&quot;32.84,67.14&quot;), &quot;sendTime&quot;: datetime(&quot;2010-05-13T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;ccast&quot;, &quot;shortcut-menu&quot; }}, &quot;messageText&quot;: &quot; like ccast its shortcut-menu is awesome:)&quot; }, &quot;similarChirps&quot;: [ &quot;9&quot;, &quot;8&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;3&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;29.72,75.8&quot;), &quot;sendTime&quot;: datetime(&quot;2006-11-04T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-w&quot;, &quot;speed&quot; }}, &quot;messageText&quot;: &quot; like product-w the speed is good:)&quot; }, &quot;similarChirps&quot;: [ &quot;5&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;4&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;39.28,70.48&quot;), &quot;sendTime&quot;: datetime(&quot;2011-12-26T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-b&quot;, &quot;voice-command&quot; }}, &quot;messageText&quot;: &quot; like product-b the voice-command is mind-blowing:)&quot; }, &quot;similarChirps&quot;: [  ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;6&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 121, &quot;statusesCount&quot;: 362, &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followersCount&quot;: 17159 }, &quot;senderLocation&quot;: point(&quot;47.51,83.99&quot;), &quot;sendTime&quot;: datetime(&quot;2010-05-07T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;x-phone&quot;, &quot;voice-clarity&quot; }}, &quot;messageText&quot;: &quot; like x-phone the voice-clarity is good:)&quot; }, &quot;similarChirps&quot;: [  ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;7&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;ChangEwing_573&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 182, &quot;statusesCount&quot;: 394, &quot;name&quot;: &quot;Chang Ewing&quot;, &quot;followersCount&quot;: 32136 }, &quot;senderLocation&quot;: point(&quot;36.21,72.6&quot;), &quot;sendTime&quot;: datetime(&quot;2011-08-25T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-y&quot;, &quot;platform&quot; }}, &quot;messageText&quot;: &quot; like product-y the platform is good&quot; }, &quot;similarChirps&quot;: [  ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;9&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;36.86,74.62&quot;), &quot;sendTime&quot;: datetime(&quot;2012-07-21T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;ccast&quot;, &quot;voicemail-service&quot; }}, &quot;messageText&quot;: &quot; love ccast its voicemail-service is awesome&quot; }, &quot;similarChirps&quot;: [  ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;1&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;47.44,80.65&quot;), &quot;sendTime&quot;: datetime(&quot;2008-04-26T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-z&quot;, &quot;customization&quot; }}, &quot;messageText&quot;: &quot; love product-z its customization is good:)&quot; }, &quot;similarChirps&quot;: [ &quot;8&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;10&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;ColineGeyer@63&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 121, &quot;statusesCount&quot;: 362, &quot;name&quot;: &quot;Coline Geyer&quot;, &quot;followersCount&quot;: 17159 }, &quot;senderLocation&quot;: point(&quot;29.15,76.53&quot;), &quot;sendTime&quot;: datetime(&quot;2008-01-26T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;ccast&quot;, &quot;voice-clarity&quot; }}, &quot;messageText&quot;: &quot; hate ccast its voice-clarity is OMG:(&quot; }, &quot;similarChirps&quot;: [ &quot;2&quot;, &quot;6&quot;, &quot;9&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;12&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;OliJackson_512&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 445, &quot;statusesCount&quot;: 164, &quot;name&quot;: &quot;Oli Jackson&quot;, &quot;followersCount&quot;: 22649 }, &quot;senderLocation&quot;: point(&quot;24.82,94.63&quot;), &quot;sendTime&quot;: datetime(&quot;2010-02-13T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-y&quot;, &quot;voice-command&quot; }}, &quot;messageText&quot;: &quot; like product-y the voice-command is amazing:)&quot; }, &quot;similarChirps&quot;: [ &quot;4&quot;, &quot;7&quot; ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;5&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;40.09,92.69&quot;), &quot;sendTime&quot;: datetime(&quot;2006-08-04T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-w&quot;, &quot;speed&quot; }}, &quot;messageText&quot;: &quot; can't stand product-w its speed is terrible:(&quot; }, &quot;similarChirps&quot;: [  ] }
+    { &quot;chirp&quot;: { &quot;chirpId&quot;: &quot;8&quot;, &quot;user&quot;: { &quot;screenName&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friendsCount&quot;: 39339, &quot;statusesCount&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followersCount&quot;: 49416 }, &quot;senderLocation&quot;: point(&quot;46.05,93.34&quot;), &quot;sendTime&quot;: datetime(&quot;2005-10-14T10:10:00.000Z&quot;), &quot;referredTopics&quot;: {{ &quot;product-z&quot;, &quot;shortcut-menu&quot; }}, &quot;messageText&quot;: &quot; like product-z the shortcut-menu is awesome:)&quot; }, &quot;similarChirps&quot;: [  ] }
+</pre></div></div></div>
+<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 &#x201c;searched delete&#x201d; 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 &quot;<a class="externalLink" href="mailto:NathanGiesen@211&quot;">NathanGiesen@211&quot;</a>. (Easy come, easy go. :-))</p>
+
+<div class="source">
+<div class="source">
+<pre>    USE TinySocial;
+    DELETE FROM ChirpMessages cm WHERE cm.chirpId = &quot;13&quot;;
+</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&#x2014;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&#x2019;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 &#x201c;/home/user/gbm.adm&#x201d; from the node named &#x201c;nc1&#x201d; into the GleambookUsers dataset.</p>
+
+<div class="source">
+<div class="source">
+<pre>USE TinySocial;
+
+LOAD DATASET GleambookUsers USING localfs
+    ((&quot;path&quot;=&quot;nc1://home/user/gbu.adm&quot;),(&quot;format&quot;=&quot;adm&quot;));
+</pre></div></div></div></div>
+<div class="section">
+<h2><a name="Further_Help"></a>Further Help</h2>
+<p>That&#x2019;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&#x2014;Big Data Management System&#x2014;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: &#x201c;With great power comes great responsibility&#x2026;&#x201d; :-)</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 span12">Copyright &copy;                    2017
+                        <a href="https://www.apache.org/">The Apache Software Foundation</a>.
+            All Rights Reserved.      
+                    
+      </div>
+
+                                                                  <?xml version="1.0" encoding="UTF-8"?>
+<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>
+    </footer>
+  </body>
+</html>