asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [28/30] incubator-asterixdb-site git commit: Add the documentation for release-0.8.8.
Date Fri, 25 Mar 2016 23:32:22 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-site/blob/08953b2e/content/docs/0.8.8-incubating/aql/functions.html
----------------------------------------------------------------------
diff --git a/content/docs/0.8.8-incubating/aql/functions.html b/content/docs/0.8.8-incubating/aql/functions.html
new file mode 100644
index 0000000..5e74ac3
--- /dev/null
+++ b/content/docs/0.8.8-incubating/aql/functions.html
@@ -0,0 +1,5111 @@
+<!DOCTYPE html>
+<!--
+ | Generated by Apache Maven Doxia at 2016-03-25
+ | 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="20160325" />
+    <meta http-equiv="Content-Language" content="en" />
+    <title>AsterixDB &#x2013; Asterix: Using 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="http://asterixdb.apache.org/" 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: 2016-03-25</li>
+                      
+                
+                    
+                 <li id="projectVersion" class="pull-right">Version: 0.8.8-incubating</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">Documentation</li>
+                                
+      <li>
+    
+                          <a href="../install.html" title="Installing and Managing AsterixDB using Managix">
+          <i class="none"></i>
+        Installing and Managing AsterixDB using Managix</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../yarn.html" title="Deploying AsterixDB using YARN">
+          <i class="none"></i>
+        Deploying AsterixDB using YARN</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/primer.html" title="AsterixDB 101: An ADM and AQL Primer">
+          <i class="none"></i>
+        AsterixDB 101: An ADM and AQL Primer</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/primer-sql-like.html" title="AsterixDB 101: An ADM and AQL Primer (For SQL Fans)">
+          <i class="none"></i>
+        AsterixDB 101: An ADM and AQL Primer (For SQL Fans)</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/js-sdk.html" title="AsterixDB Javascript SDK">
+          <i class="none"></i>
+        AsterixDB Javascript SDK</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/datamodel.html" title="Asterix Data Model (ADM)">
+          <i class="none"></i>
+        Asterix Data Model (ADM)</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/manual.html" title="Asterix Query Language (AQL)">
+          <i class="none"></i>
+        Asterix Query Language (AQL)</a>
+            </li>
+                  
+      <li class="active">
+    
+            <a href="#"><i class="none"></i>AQL Functions</a>
+          </li>
+                  
+      <li>
+    
+                          <a href="../aql/allens.html" title="AQL Allen's Relations Functions">
+          <i class="none"></i>
+        AQL Allen's Relations Functions</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../aql/similarity.html" title="AQL Support of Similarity Queries">
+          <i class="none"></i>
+        AQL Support of Similarity 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 in AsterixDB">
+          <i class="none"></i>
+        Support for Data Ingestion in AsterixDB</a>
+            </li>
+                  
+      <li>
+    
+                          <a href="../udf.html" title="Support for User Defined Functions in AsterixDB">
+          <i class="none"></i>
+        Support for User Defined Functions in AsterixDB</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="../api.html" title="HTTP API to AsterixDB">
+          <i class="none"></i>
+        HTTP API to AsterixDB</a>
+            </li>
+            </ul>
+                
+                    
+                
+          <hr class="divider" />
+
+           <div id="poweredBy">
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                            <div class="clear"></div>
+                                                                                                                         <a href="https://code.google.com/p/hyracks/" title="Hyracks" class="builtBy">
+        <img class="builtBy"  alt="Hyracks" src="../images/hyrax_ts.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>Asterix: Using 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="#AggregateFunctions">Aggregate 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="#RecordFunctions">Record Functions</a></li>
+  
+<li><a href="#OtherFunctions">Other Functions</a></li>
+</ul>
+<p>Asterix provides various classes of functions to support operations on numeric, string, spatial, and temporal data. This document explains how to use these functions.</p></div>
+<div class="section">
+<h2><a name="Numeric_Functions_Back_to_TOC"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></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_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Computes the absolute value of the argument.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>numeric_expression</tt>: A <tt>int8</tt>/<tt>int16</tt>/<tt>int32</tt>/<tt>int64</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, or <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>let $v1 := abs(2013)
+let $v2 := abs(-4036)
+let $v3 := abs(0)
+let $v4 := abs(float(&quot;-2013.5&quot;))
+let $v5 := abs(double(&quot;-2013.593823748327284&quot;))
+return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4, &quot;v5&quot;: $v5 }
+</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.5f, &quot;v5&quot;: 2013.5938237483274d }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="ceiling"></a>ceiling</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>ceiling(numeric_expression)
+</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_expression</tt>: A <tt>int8</tt>/<tt>int16</tt>/<tt>int32</tt>/<tt>int64</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, or <tt>null</tt> if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $v1 := ceiling(2013)
+let $v2 := ceiling(-4036)
+let $v3 := ceiling(0.3)
+let $v4 := ceiling(float(&quot;-2013.2&quot;))
+let $v5 := ceiling(double(&quot;-2013.893823748327284&quot;))
+return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4, &quot;v5&quot;: $v5 }
+</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.0d, &quot;v4&quot;: -2013.0f, &quot;v5&quot;: -2013.0d }
+</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_expression)
+</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_expression</tt>: A <tt>int8</tt>/<tt>int16</tt>/<tt>int32</tt>/<tt>int64</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, or <tt>null</tt> if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $v1 := floor(2013)
+let $v2 := floor(-4036)
+let $v3 := floor(0.8)
+let $v4 := floor(float(&quot;-2013.2&quot;))
+let $v5 := floor(double(&quot;-2013.893823748327284&quot;))
+return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4, &quot;v5&quot;: $v5 }
+</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.0d, &quot;v4&quot;: -2014.0f, &quot;v5&quot;: -2014.0d }
+</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_expression)
+</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_expression</tt>: A <tt>int8</tt>/<tt>int16</tt>/<tt>int32</tt>/<tt>int64</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, or <tt>null</tt> if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $v1 := round(2013)
+let $v2 := round(-4036)
+let $v3 := round(0.8)
+let $v4 := round(float(&quot;-2013.256&quot;))
+let $v5 := round(double(&quot;-2013.893823748327284&quot;))
+return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4, &quot;v5&quot;: $v5 }
+</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.0d, &quot;v4&quot;: -2013.0f, &quot;v5&quot;: -2014.0d }
+</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_expression, [precision])
+</pre></div></div></li>
+  
+<li>
+<p>Computes the closest numeric value to <tt>numeric_expression</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_expression</tt>: A <tt>int8</tt>/<tt>int16</tt>/<tt>int32</tt>/<tt>int64</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
+    
+<li><tt>precision</tt>: An optional integer 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, or <tt>null</tt> if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $v1 := round-half-to-even(2013)
+let $v2 := round-half-to-even(-4036)
+let $v3 := round-half-to-even(0.8)
+let $v4 := round-half-to-even(float(&quot;-2013.256&quot;))
+let $v5 := round-half-to-even(double(&quot;-2013.893823748327284&quot;))
+let $v6 := round-half-to-even(double(&quot;-2013.893823748327284&quot;), 2)
+let $v7 := round-half-to-even(2013, 4)
+let $v8 := round-half-to-even(float(&quot;-2013.256&quot;), 5)
+return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4, &quot;v5&quot;: $v5, &quot;v6&quot;: $v6, &quot;v7&quot;: $v7, &quot;v8&quot;: $v8 }
+</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.0d, &quot;v4&quot;: -2013.0f, &quot;v5&quot;: -2014.0d, &quot;v6&quot;: -2013.89d, &quot;v7&quot;: 2013, &quot;v8&quot;: -2013.256f }
+</pre></div></div></li>
+</ul></div></div>
+<div class="section">
+<h2><a name="String_Functions_Back_to_TOC"></a><a name="StringFunctions" id="StringFunctions">String Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<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_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Converts the string <tt>string_expression</tt> to its code-based representation.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> that will be converted.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>OrderedList</tt> of the code points for the string <tt>string_expression</tt>.</li>
+  </ul></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(list_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Converts the ordered code-based representation <tt>list_expression</tt> to the corresponding string.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list_expression</tt> : An <tt>OrderedList</tt> of code-points.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>string</tt> representation of <tt>list_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $s := &quot;Hello ASTERIX!&quot;
+let $l := string-to-codepoint($s)
+let $ss := codepoint-to-string($l)
+return {&quot;codes&quot;: $l, &quot;string&quot;: $ss}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;codes&quot;: [ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ], &quot;string&quot;: &quot;Hello ASTERIX!&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_expression, substring_to_contain)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the string <tt>string_expression</tt> contains the string <tt>substring_to_contain</tt></p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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_expression</tt> contains <tt>substring_to_contain</tt>, and <tt>false</tt> otherwise.</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>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where contains($i.message, &quot;phone&quot;)
+return {&quot;mid&quot;: $i.message-id, &quot;message&quot;: $i.message}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;mid&quot;: 2, &quot;message&quot;: &quot; dislike iphone its touch-screen is horrible&quot; }
+{ &quot;mid&quot;: 13, &quot;message&quot;: &quot; dislike iphone the voice-command is bad:(&quot; }
+{ &quot;mid&quot;: 15, &quot;message&quot;: &quot; like iphone the voicemail-service is awesome&quot; }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="like"></a>like</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>like(string_expression, string_pattern)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the string <tt>string_expression</tt> contains the string pattern <tt>string_pattern</tt>. Compared to the <tt>contains</tt> function, the <tt>like</tt> function also supports regular expressions.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> that might contain the pattern or <tt>null</tt>.</li>
+    
+<li><tt>string_pattern</tt> : A pattern <tt>string</tt> that might be contained or <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>boolean</tt> value, <tt>true</tt> if <tt>string_expression</tt> contains the pattern <tt>string_pattern</tt>, and <tt>false</tt> otherwise.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where like($i.message, &quot;%at&amp;t%&quot;)
+return $i.message
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; can't stand at&amp;t the network is horrible:(&quot;
+&quot; can't stand at&amp;t its plan is terrible&quot;
+&quot; love at&amp;t its 3G is good:)&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_expression, substring_to_start_with)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the string <tt>string_expression</tt> starts with the string <tt>substring_to_start_with</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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_expression</tt> starts with the string <tt>substring_to_start_with</tt>, and <tt>false</tt> otherwise.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where starts-with($i.message, &quot; like&quot;)
+return $i.message
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; like samsung the plan is amazing&quot;
+&quot; like t-mobile its platform is mind-blowing&quot;
+&quot; like verizon the 3G is awesome:)&quot;
+&quot; like iphone the voicemail-service is awesome&quot;
+</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_expression, substring_to_end_with)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the string <tt>string_expression</tt> ends with the string <tt>substring_to_end_with</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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>, returns <tt>true</tt> if <tt>string_expression</tt> ends with the string <tt>substring_to_end_with</tt>, and <tt>false</tt> otherwise.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where ends-with($i.message, &quot;:)&quot;)
+return $i.message
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; love sprint its shortcut-menu is awesome:)&quot;
+&quot; like verizon the 3G is awesome:)&quot;
+&quot; love at&amp;t its 3G is good:)&quot;
+</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(list_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Concatenates a list of strings <tt>list_expression</tt> into a single string.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list_expression</tt> : An <tt>OrderedList</tt> or <tt>UnorderedList</tt> of <tt>string</tt>s (could be <tt>null</tt>) to be concatenated.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns the concatenated <tt>string</tt> value.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $i := &quot;ASTERIX&quot;
+let $j := &quot; &quot;
+let $k := &quot;ROCKS!&quot;
+return string-concat([$i, $j, $k])
+</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(list_expression, string_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Joins a list of strings <tt>list_expression</tt> with the given separator <tt>string_expression</tt> into a single string.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list_expression</tt> : An <tt>OrderedList</tt> or <tt>UnorderedList</tt> of strings (could be <tt>null</tt>) to be joined.</li>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> as the separator.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns the joined <tt>String</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $i := [&quot;ASTERIX&quot;, &quot;ROCKS~&quot;]
+return string-join($i, &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="lowercase"></a>lowercase</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>lowercase(string_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Converts a given string <tt>string_expression</tt> to its lowercase form.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> to be converted.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns a <tt>string</tt> as the lowercase form of the given <tt>string_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $i := &quot;ASTERIX&quot;
+return lowercase($i)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>asterix
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="uppercase"></a>uppercase</h3>
+
+<ul>
+  
+<li>Syntax:</li>
+</ul>
+<p>uppercase(string_expression)</p>
+
+<ul>
+  
+<li>Converts a given string <tt>string_expression</tt> to its uppercase form.</li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> to be converted.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns a <tt>string</tt> as the uppercase form of the given <tt>string_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $i := &quot;asterix&quot;
+return uppercase($i)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>ASTERIX
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="uppercase"></a>uppercase</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>uppercase(string_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Converts a given string <tt>string_expression</tt> to its uppercase form.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> to be converted.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns a <tt>string</tt> as the uppercase form of the given <tt>string_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $i := &quot;asterix&quot;
+return uppercase($i)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>ASTERIX
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="matches"></a>matches</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>matches(string_expression, string_pattern)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the strings <tt>string_expression</tt> matches the given pattern <tt>string_pattern</tt> (A Java regular expression pattern).</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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>A <tt>boolean</tt>, returns <tt>true</tt> if <tt>string_expression</tt> matches the pattern <tt>string_pattern</tt>, and <tt>false</tt> otherwise.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where matches($i.message, &quot;dislike iphone&quot;)
+return $i.message
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; dislike iphone its touch-screen is horrible&quot;
+&quot; dislike iphone the voice-command is bad:(&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="replace"></a>replace</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>replace(string_expression, string_pattern, string_replacement[, string_flags])
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether the string <tt>string_expression</tt> matches the given pattern <tt>string_pattern</tt>, 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_expression</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.</li>
+    
+<li>The following modes are enabled with these flags: dotall (s), multiline (m), case-insenitive (i), and comments and whitespace (x).</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where matches($i.message, &quot; like iphone&quot;)
+return replace($i.message, &quot; like iphone&quot;, &quot;like android&quot;)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;like android the voicemail-service is awesome&quot;
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="string-length"></a>string-length</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>string-length(string_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the length of the string <tt>string_expression</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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>int64</tt> that represents the length of <tt>string_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+return {&quot;mid&quot;: $i.message-id, &quot;message-len&quot;: string-length($i.message)}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;mid&quot;: 1, &quot;message-len&quot;: 43 }
+{ &quot;mid&quot;: 2, &quot;message-len&quot;: 44 }
+{ &quot;mid&quot;: 3, &quot;message-len&quot;: 33 }
+{ &quot;mid&quot;: 4, &quot;message-len&quot;: 43 }
+{ &quot;mid&quot;: 5, &quot;message-len&quot;: 46 }
+{ &quot;mid&quot;: 6, &quot;message-len&quot;: 43 }
+{ &quot;mid&quot;: 7, &quot;message-len&quot;: 37 }
+{ &quot;mid&quot;: 8, &quot;message-len&quot;: 33 }
+{ &quot;mid&quot;: 9, &quot;message-len&quot;: 34 }
+{ &quot;mid&quot;: 10, &quot;message-len&quot;: 50 }
+{ &quot;mid&quot;: 11, &quot;message-len&quot;: 38 }
+{ &quot;mid&quot;: 12, &quot;message-len&quot;: 52 }
+{ &quot;mid&quot;: 13, &quot;message-len&quot;: 42 }
+{ &quot;mid&quot;: 14, &quot;message-len&quot;: 27 }
+{ &quot;mid&quot;: 15, &quot;message-len&quot;: 45 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="substring"></a>substring</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>substring(string_expression, offset[, length])
+</pre></div></div></li>
+  
+<li>
+<p>Returns the substring from the given string <tt>string_expression</tt> based on the given start offset <tt>offset</tt> with the optional <tt>length</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> to be extracted.</li>
+    
+<li><tt>offset</tt> : An <tt>int64</tt> as the starting offset of the substring in <tt>string_expression</tt>.</li>
+    
+<li><tt>length</tt> : (Optional) An <tt>int64</tt> as the length of the substring.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>string</tt> that represents the substring.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where string-length($i.message) &gt; 50
+return substring($i.message, 50)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot;G:(&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_expression, string_pattern)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the substring from the given string <tt>string_expression</tt> before the given pattern <tt>string_pattern</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where contains($i.message, &quot;iphone&quot;)
+return substring-before($i.message, &quot;iphone&quot;)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; dislike &quot;
+&quot; dislike &quot;
+&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>
+  
+<div class="source">
+<div class="source">
+<pre>substring-after(string_expression, string_pattern)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the substring from the given string <tt>string_expression</tt> after the given pattern <tt>string_pattern</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</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>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $i in dataset('FacebookMessages')
+where contains($i.message, &quot;iphone&quot;)
+return substring-after($i.message, &quot;iphone&quot;)
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>&quot; its touch-screen is horrible&quot;
+&quot; the voice-command is bad:(&quot;
+&quot; the voicemail-service is awesome&quot;
+</pre></div></div></li>
+</ul></div></div>
+<div class="section">
+<h2><a name="Aggregate_Functions_Back_to_TOC"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
+<div class="section">
+<h3><a name="count"></a>count</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>count(list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the number of items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing the items to be counted, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>int64</tt> value representing the number of items in the given list. <tt>0i64</tt> is returned if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $l1 := ['hello', 'world', 1, 2, 3]
+let $l2 := for $i in dataset TwitterUsers return $i
+return {&quot;count1&quot;: count($l1), &quot;count2&quot;: count($l2)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;count1&quot;: 5i64, &quot;count2&quot;: 4i64 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="avg"></a>avg</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>avg(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the average value of the items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing numeric or null values, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>double</tt> value representing the average of the numbers in the given list. <tt>null</tt> is returned if the input is <tt>null</tt>, or the input list contains <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $l := for $i in dataset TwitterUsers return $i.friends_count
+return {&quot;avg_friend_count&quot;: avg($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;avg_friend_count&quot;: 191.5d }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sum"></a>sum</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>sum(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the sum of the items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing numeric or null values, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>The sum of the numbers in the given list. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>int8</tt>-&gt; <tt>int16</tt>-&gt;<tt>int32</tt>-&gt;<tt>int64</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items. <tt>null</tt> is returned if the input is <tt>null</tt>, or the input list contains <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $l := for $i in dataset TwitterUsers return $i.friends_count
+return {&quot;sum_friend_count&quot;: sum($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;sum_friend_count&quot;: 766 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="minmax"></a>min/max</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>min(num_list), max(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the min/max value of numeric items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing the items to be compared, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>The min/max value of the given list. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>int8</tt>-&gt; <tt>int16</tt>-&gt;<tt>int32</tt>-&gt;<tt>int64</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items. <tt>null</tt> is returned if the input is <tt>null</tt>, or the input list contains <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $l := for $i in dataset TwitterUsers return $i. friends_count
+return {&quot;min_friend_count&quot;: min($l), &quot;max_friend_count&quot;: max($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;min_friend_count&quot;: 18, &quot;max_friend_count&quot;: 445 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sql-count"></a>sql-count</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>sql-count(list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the number of non-null items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing the items to be counted, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>int64</tt> value representing the number of non-null items in the given list. The value <tt>0i64</tt> is returned if the input is <tt>null</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p></li>
+</ul>
+
+<div class="source">
+<div class="source">
+<pre>    let $l1 := ['hello', 'world', 1, 2, 3, null]
+    return {&quot;count&quot;: sql-count($l1)}
+</pre></div></div>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;count&quot;: 5i64 }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sql-avg"></a>sql-avg</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>sql-avg(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the average value of the non-null items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing numeric or null values, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>double</tt> value representing the average of the non-null numbers in the given list. The <tt>null</tt> value is returned if the input is <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $l := [1.2, 2.3, 3.4, 0, null]
+return {&quot;avg&quot;: sql-avg($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;avg&quot;: 1.725d }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sql-sum"></a>sql-sum</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>sql-sum(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the sum of the non-null items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing numeric or null values, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>The sum of the non-null numbers in the given list. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>int8</tt>-&gt; <tt>int16</tt>-&gt;<tt>int32</tt>-&gt;<tt>int64</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items. The value <tt>null</tt> is returned if the input is <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $l := [1.2, 2.3, 3.4, 0, null]
+return {&quot;sum&quot;: sql-sum($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;sum&quot;: 6.9d }
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="sql-minmax"></a>sql-min/max</h3>
+
+<ul>
+  
+<li>
+<p>Syntax:</p>
+  
+<div class="source">
+<div class="source">
+<pre>sql-min(num_list), sql-max(num_list)
+</pre></div></div></li>
+  
+<li>
+<p>Gets the min/max value of the non-null numeric items in the given list.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>num_list</tt>: An <tt>orderedList</tt> or <tt>unorderedList</tt> containing the items to be compared, or a <tt>null</tt> value.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>The min/max value of the given list. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>int8</tt>-&gt; <tt>int16</tt>-&gt;<tt>int32</tt>-&gt;<tt>int64</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items. The value <tt>null</tt> is returned if the input is <tt>null</tt>. Non-numeric types in the input list will cause an error.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>let $l := [1.2, 2.3, 3.4, 0, null]
+return {&quot;min&quot;: sql-min($l), &quot;max&quot;: sql-max($l)}
+</pre></div></div></li>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;min&quot;: 0.0d, &quot;max&quot;: 3.4d }
+</pre></div></div></li>
+</ul></div></div>
+<div class="section">
+<h2><a name="Spatial_Functions_Back_to_TOC"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></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>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $c :=  create-point(30.0,70.0)
+return {&quot;point&quot;: $c}
+</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(point_expression1, point_expression2)
+</pre></div></div></li>
+  
+<li>
+<p>Creates the primitive type <tt>line</tt> using <tt>point_expression1</tt> and <tt>point_expression2</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression1</tt> : A <tt>point</tt> that represents the start point of the line.</li>
+    
+<li><tt>point_expression2</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>point_expression1</tt> and <tt>point_expression2</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $c :=  create-line(create-point(30.0,70.0), create-point(50.0,90.0))
+return {&quot;line&quot;: $c}
+</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(point_expression1, point_expression2)
+</pre></div></div></li>
+  
+<li>
+<p>Creates the primitive type <tt>rectangle</tt> using <tt>point_expression1</tt> and <tt>point_expression2</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression1</tt> : A <tt>point</tt> that represents the lower-left point of the rectangle.</li>
+    
+<li><tt>point_expression2</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>point_expression1</tt> and <tt>point_expression2</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $c :=  create-rectangle(create-point(30.0,70.0), create-point(50.0,90.0))
+return {&quot;rectangle&quot;: $c}
+</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_expression, radius)
+</pre></div></div></li>
+  
+<li>
+<p>Creates the primitive type <tt>circle</tt> using <tt>point_expression</tt> and <tt>radius</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression</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_expression</tt> and <tt>radius</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $c :=  create-circle(create-point(30.0,70.0), 5.0)
+return {&quot;circle&quot;: $c}
+</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(list_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Creates the primitive type <tt>polygon</tt> using the double values provided in the argument <tt>list_expression</tt>. Each two consecutive double values represent a point starting from the first double value in the list. Note that at least six double values should be specified, meaning a total of three points.</p></li>
+  
+<li>Arguments:</li>
+  
+<li><tt>list_expression</tt> : An OrderedList of doubles representing the points of the polygon.</li>
+  
+<li>Return Value:</li>
+  
+<li>A <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>list_expression</tt>.</li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $c :=  create-polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0])
+return {&quot;polygon&quot;: $c}
+</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_expression) or get-y(point_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the x or y coordinates of a point <tt>point_expression</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression</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_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $point := create-point(2.3,5.0)
+return {&quot;x-coordinate&quot;: get-x($point), &quot;y-coordinate&quot;: get-y($point)}
+</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.3d, &quot;y-coordinate&quot;: 5.0d }
+</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_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Returns an ordered list of the points forming the spatial object <tt>spatial_expression</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>spatial_expression</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>OrderedList</tt> of the points forming the spatial object <tt>spatial_expression</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $line := create-line(create-point(100.6,99.4), create-point(-72.0,-76.9))
+let $rectangle := create-rectangle(create-point(9.2,49.0), create-point(77.8,111.1))
+let $polygon := create-polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0])
+let $line_list := get-points($line)
+let $rectangle_list := get-points($rectangle)
+let $polygon_list := get-points($polygon)
+return {&quot;line-first-point&quot;: $line_list[0], &quot;line-second-point&quot;: $line_list[1], &quot;rectangle-left-bottom-point&quot;: $rectangle_list[0], &quot;rectangle-top-upper-point&quot;: $rectangle_list[1], &quot;polygon-first-point&quot;: $polygon_list[0], &quot;polygon-second-point&quot;: $polygon_list[1], &quot;polygon-third-point&quot;: $polygon_list[2], &quot;polygon-forth-point&quot;: $polygon_list[3]}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;line-first-point&quot;: point(&quot;100.6,99.4&quot;), &quot;line-second-point&quot;: point(&quot;-72.0,-76.9&quot;), &quot;rectangle-left-bottom-point&quot;: point(&quot;9.2,49.0&quot;), &quot;rectangle-top-upper-point&quot;: point(&quot;77.8,111.1&quot;), &quot;polygon-first-point&quot;: point(&quot;1.0,1.0&quot;), &quot;polygon-second-point&quot;: point(&quot;2.0,2.0&quot;), &quot;polygon-third-point&quot;: point(&quot;3.0,3.0&quot;), &quot;polygon-forth-point&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>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $circle := create-circle(create-point(6.0,3.0), 1.0)
+return {&quot;circle-radius&quot;: get-radius($circle), &quot;circle-center&quot;: get-center($circle)}
+</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.0d, &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(point_expression1, point_expression2)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the Euclidean distance between <tt>point_expression1</tt> and <tt>point_expression2</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression1</tt> : A <tt>point</tt>.</li>
+    
+<li><tt>point_expression2</tt> : A <tt>point</tt>.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>double</tt> as the Euclidean distance between <tt>point_expression1</tt> and <tt>point_expression2</tt>.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $t in dataset('TweetMessages')
+let $d :=  spatial-distance($t.sender-location, create-point(30.0,70.0))
+return {&quot;point&quot;: $t.sender-location, &quot;distance&quot;: $d}
+</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;47.44,80.65&quot;), &quot;distance&quot;: 20.434678857275934d }
+{ &quot;point&quot;: point(&quot;29.15,76.53&quot;), &quot;distance&quot;: 6.585089217315132d }
+{ &quot;point&quot;: point(&quot;37.59,68.42&quot;), &quot;distance&quot;: 7.752709203884797d }
+{ &quot;point&quot;: point(&quot;24.82,94.63&quot;), &quot;distance&quot;: 25.168816023007512d }
+{ &quot;point&quot;: point(&quot;32.84,67.14&quot;), &quot;distance&quot;: 4.030533463451212d }
+{ &quot;point&quot;: point(&quot;29.72,75.8&quot;), &quot;distance&quot;: 5.806754687430835d }
+{ &quot;point&quot;: point(&quot;39.28,70.48&quot;), &quot;distance&quot;: 9.292405501268227d }
+{ &quot;point&quot;: point(&quot;40.09,92.69&quot;), &quot;distance&quot;: 24.832321679617472d }
+{ &quot;point&quot;: point(&quot;47.51,83.99&quot;), &quot;distance&quot;: 22.41250097601782d }
+{ &quot;point&quot;: point(&quot;36.21,72.6&quot;), &quot;distance&quot;: 6.73231758015024d }
+{ &quot;point&quot;: point(&quot;46.05,93.34&quot;), &quot;distance&quot;: 28.325926286707734d }
+{ &quot;point&quot;: point(&quot;36.86,74.62&quot;), &quot;distance&quot;: 8.270671073135482d }
+</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>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+let $circleArea := spatial-area(create-circle(create-point(0.0,0.0), 5.0))
+return {&quot;Area&quot;:$circleArea}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;Area&quot;: 78.53981625d }
+</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_expression1, spatial_expression2)
+</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_expression1</tt> : A <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
+    
+<li><tt>spatial_expression2</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_expression1</tt> and <tt>spatial_expression2</tt> spatially overlap with each other.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $t in dataset('TweetMessages')
+where spatial-intersect($t.sender-location, create-rectangle(create-point(30.0,70.0), create-point(40.0,80.0)))
+return $t
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;tweetid&quot;: &quot;4&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: 39339, &quot;statuses_count&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: 49416 }, &quot;sender-location&quot;: point(&quot;39.28,70.48&quot;), &quot;send-time&quot;: datetime(&quot;2011-12-26T10:10:00.000Z&quot;), &quot;referred-topics&quot;: {{ &quot;sprint&quot;, &quot;voice-command&quot; }}, &quot;message-text&quot;: &quot; like sprint the voice-command is mind-blowing:)&quot; }
+{ &quot;tweetid&quot;: &quot;7&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;ChangEwing_573&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: 182, &quot;statuses_count&quot;: 394, &quot;name&quot;: &quot;Chang Ewing&quot;, &quot;followers_count&quot;: 32136 }, &quot;sender-location&quot;: point(&quot;36.21,72.6&quot;), &quot;send-time&quot;: datetime(&quot;2011-08-25T10:10:00.000Z&quot;), &quot;referred-topics&quot;: {{ &quot;samsung&quot;, &quot;platform&quot; }}, &quot;message-text&quot;: &quot; like samsung the platform is good&quot; }
+{ &quot;tweetid&quot;: &quot;9&quot;, &quot;user&quot;: { &quot;screen-name&quot;: &quot;NathanGiesen@211&quot;, &quot;lang&quot;: &quot;en&quot;, &quot;friends_count&quot;: 39339, &quot;statuses_count&quot;: 473, &quot;name&quot;: &quot;Nathan Giesen&quot;, &quot;followers_count&quot;: 49416 }, &quot;sender-location&quot;: point(&quot;36.86,74.62&quot;), &quot;send-time&quot;: datetime(&quot;2012-07-21T10:10:00.000Z&quot;), &quot;referred-topics&quot;: {{ &quot;verizon&quot;, &quot;voicemail-service&quot; }}, &quot;message-text&quot;: &quot; love verizon its voicemail-service is awesome&quot; }
+</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(point_expression1, point_expression2, x_increment, y_increment)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the grid cell that <tt>point_expression1</tt> belongs to.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>point_expression1</tt> : A <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
+    
+<li><tt>point_expression2</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>point_expression1</tt> belongs to.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $t in dataset('TweetMessages')
+group by $c :=  spatial-cell($t.sender-location, create-point(20.0,50.0), 5.5, 6.0) with $t
+let $num :=  count($t)
+return { &quot;cell&quot;: $c, &quot;count&quot;: $num}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;cell&quot;: rectangle(&quot;20.0,92.0 25.5,98.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;25.5,74.0 31.0,80.0&quot;), &quot;count&quot;: 2i64 }
+{ &quot;cell&quot;: rectangle(&quot;31.0,62.0 36.5,68.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;31.0,68.0 36.5,74.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;36.5,68.0 42.0,74.0&quot;), &quot;count&quot;: 2i64 }
+{ &quot;cell&quot;: rectangle(&quot;36.5,74.0 42.0,80.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;36.5,92.0 42.0,98.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;42.0,80.0 47.5,86.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;42.0,92.0 47.5,98.0&quot;), &quot;count&quot;: 1i64 }
+{ &quot;cell&quot;: rectangle(&quot;47.5,80.0 53.0,86.0&quot;), &quot;count&quot;: 1i64 }
+</pre></div></div></li>
+</ul></div></div>
+<div class="section">
+<h2><a name="Similarity_Functions_Back_to_TOC"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></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>OrderedList</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>int64</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>.</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>use dataverse TinySocial;
+
+for $user in dataset('FacebookUsers')
+let $ed := edit-distance($user.name, &quot;Suzanna Tilson&quot;)
+where $ed &lt;= 2
+return $user
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+&quot;id&quot;: 7, &quot;alias&quot;: &quot;Suzanna&quot;, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;user-since&quot;: datetime(&quot;2012-08-07T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 6 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;Labzatron&quot;, &quot;start-date&quot;: date(&quot;2011-04-19&quot;), &quot;end-date&quot;: null } ]
+}
+</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 <tt>expression1</tt> and <tt>expression2</tt> have an <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> within a given threshold. The &#x201c;check&#x201d; version of edit distance is faster than the &#x201c;non-check&#x201d; version because the former can detect whether two items satisfy a given threshold using early-termination techniques, as opposed to computing their real distance. Although possible, it is not necessary for the user to write queries using the &#x201c;check&#x201d; versions explicitly, since a rewrite rule can perform an appropriate transformation from a &#x201c;non-check&#x201d; version to a &#x201c;check&#x201d; version.</p></li>
+  
+<li>
+<p>Arguments:</p>
+  
+<ul>
+    
+<li><tt>expression1</tt> : A <tt>string</tt> or a homogeneous <tt>OrderedList</tt> of a comparable item type.</li>
+    
+<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
+    
+<li><tt>threshold</tt> : An <tt>int64</tt> that represents the distance threshold.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>OrderedList</tt> with two items:
+    
+<ul>
+      
+<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> and <tt>expression2</tt> are similar.</li>
+      
+<li>The second item contains an <tt>int64</tt> that represents the edit distance of <tt>expression1</tt> and <tt>expression2</tt> if it is within the threshold, or 0 otherwise.</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>use dataverse TinySocial;
+
+for $user in dataset('FacebookUsers')
+let $ed := edit-distance-check($user.name, &quot;Suzanna Tilson&quot;, 2)
+where $ed[0]
+return $ed[1]
+</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-contains"></a>edit-distance-contains</h3>
+
+<ul>
+  
+<li>Syntax:</li>
+</ul>
+<p>edit-distance-contains(expression1, expression2, threshold)</p>
+
+<ul>
+  
+<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>OrderedList</tt> of a comparable item type.</li>
+    
+<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
+    
+<li><tt>threshold</tt> : An <tt>int32</tt> that represents the distance threshold.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>OrderedList</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>int32</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>
+  </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>let $i := edit-distance-contains(&quot;happy&quot;,&quot;hapr&quot;,2)
+return $i;
+</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(list_expression1, list_expression2)
+</pre></div></div></li>
+  
+<li>
+<p>Returns the <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> of <tt>list_expression1</tt> and <tt>list_expression2</tt>.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>list_expression1</tt> : An <tt>UnorderedList</tt> or <tt>OrderedList</tt>.</li>
+    
+<li><tt>list_expression2</tt> : An <tt>UnorderedList</tt> or <tt>OrderedList</tt>.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>A <tt>float</tt> that represents the Jaccard similarity of <tt>list_expression1</tt> and <tt>list_expression2</tt>.</li>
+  </ul></li>
+  
+<li>Note: A <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $user in dataset('FacebookUsers')
+let $sim := similarity-jaccard($user.friend-ids, [1,5,9,10])
+where $sim &gt;= 0.6f
+return $user
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+&quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;user-since&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 1, 5, 8, 9 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;geomedia&quot;, &quot;start-date&quot;: date(&quot;2010-06-17&quot;), &quot;end-date&quot;: date(&quot;2010-01-26&quot;) } ]
+}
+{
+&quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;user-since&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 1, 5, 9 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;physcane&quot;, &quot;start-date&quot;: date(&quot;2007-06-05&quot;), &quot;end-date&quot;: date(&quot;2011-11-05&quot;) } ]
+}
+</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(list_expression1, list_expression2, threshold)
+</pre></div></div></li>
+  
+<li>
+<p>Checks whether <tt>list_expression1</tt> and <tt>list_expression2</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>list_expression1</tt> : An <tt>UnorderedList</tt> or <tt>OrderedList</tt>.</li>
+    
+<li><tt>list_expression2</tt> : An <tt>UnorderedList</tt> or <tt>OrderedList</tt>.</li>
+    
+<li><tt>threshold</tt> : A <tt>float</tt> that represents the similarity threshold.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>OrderedList</tt> with two items:</li>
+    
+<li>The first item contains a <tt>boolean</tt> value representing whether <tt>list_expression1</tt> and <tt>list_expression2</tt> are similar.</li>
+    
+<li>The second item contains a <tt>float</tt> that represents the Jaccard similarity of <tt>list_expression1</tt> and <tt>list_expression2</tt> if it is greater than or equal to the threshold, or 0 otherwise.</li>
+  </ul></li>
+  
+<li>Note: A <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $user in dataset('FacebookUsers')
+let $sim := similarity-jaccard-check($user.friend-ids, [1,5,9,10], 0.6f)
+where $sim[0]
+return $sim[1]
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>0.75f
+1.0f
+</pre></div></div></li>
+</ul></div>
+<div class="section">
+<h3><a name="Similarity_Operator_"></a>Similarity Operator ~=</h3>
+
+<ul>
+  
+<li>&#x201c;<tt>~=</tt>&#x201d; is syntactic sugar for expressing a similarity condition with a given similarity threshold.</li>
+  
+<li>The similarity function and threshold for &#x201c;<tt>~=</tt>&#x201d; are controlled via &#x201c;set&#x201d; directives.</li>
+  
+<li>The &#x201c;<tt>~=</tt>&#x201d; operator returns a <tt>boolean</tt> value that represents whether the operands are similar.</li>
+  
+<li>
+<p>Example for Jaccard similarity:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+set simfunction &quot;jaccard&quot;;
+set simthreshold &quot;0.6f&quot;;
+
+for $user in dataset('FacebookUsers')
+where $user.friend-ids ~= [1,5,9,10]
+return $user
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+&quot;id&quot;: 3, &quot;alias&quot;: &quot;Emory&quot;, &quot;name&quot;: &quot;EmoryUnk&quot;, &quot;user-since&quot;: datetime(&quot;2012-07-10T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 1, 5, 8, 9 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;geomedia&quot;, &quot;start-date&quot;: date(&quot;2010-06-17&quot;), &quot;end-date&quot;: date(&quot;2010-01-26&quot;) } ]
+}
+{
+&quot;id&quot;: 10, &quot;alias&quot;: &quot;Bram&quot;, &quot;name&quot;: &quot;BramHatch&quot;, &quot;user-since&quot;: datetime(&quot;2010-10-16T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 1, 5, 9 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;physcane&quot;, &quot;start-date&quot;: date(&quot;2007-06-05&quot;), &quot;end-date&quot;: date(&quot;2011-11-05&quot;) } ]
+}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>Example for edit-distance similarity:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+set simfunction &quot;edit-distance&quot;;
+set simthreshold &quot;2&quot;;
+
+for $user in dataset('FacebookUsers')
+where $user.name ~= &quot;Suzanna Tilson&quot;
+return $user
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected output is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{
+&quot;id&quot;: 7, &quot;alias&quot;: &quot;Suzanna&quot;, &quot;name&quot;: &quot;SuzannaTillson&quot;, &quot;user-since&quot;: datetime(&quot;2012-08-07T10:10:00.000Z&quot;), &quot;friend-ids&quot;: {{ 6 }},
+&quot;employment&quot;: [ { &quot;organization-name&quot;: &quot;Labzatron&quot;, &quot;start-date&quot;: date(&quot;2011-04-19&quot;), &quot;end-date&quot;: null } ]
+}
+</pre></div></div></li>
+</ul></div></div>
+<div class="section">
+<h2><a name="Tokenizing_Functions_Back_to_TOC"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></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_expression)
+</pre></div></div></li>
+  
+<li>
+<p>Returns a list of word tokens of <tt>string_expression</tt> using non-alphanumeric characters as delimiters.</p></li>
+  
+<li>Arguments:
+  
+<ul>
+    
+<li><tt>string_expression</tt> : A <tt>string</tt> that will be tokenized.</li>
+  </ul></li>
+  
+<li>Return Value:
+  
+<ul>
+    
+<li>An <tt>OrderedList</tt> of <tt>string</tt> word tokens.</li>
+  </ul></li>
+  
+<li>
+<p>Example:</p>
+  
+<div class="source">
+<div class="source">
+<pre>use dataverse TinySocial;
+
+for $t in dataset('TweetMessages')
+let $tokens := word-tokens($t.message-text)
+where $t.send-time &gt;= datetime('2012-01-01T00:00:00')
+return {
+&quot;tweetid&quot;: $t.tweetid,
+&quot;word-tokens&quot;: $tokens
+}
+</pre></div></div></li>
+</ul>
+
+<ul>
+  
+<li>
+<p>The expected result is:</p>
+  
+<div class="source">
+<div class="source">
+<pre>{ &quot;tweetid&quot;: &quot;9&quot;, &quot;word-tokens&quot;: [ &quot;love&quot;, &quot;verizon&quot;, &quot;its&quot;, &quot;voicemail&quot;, &quot;service&quot;, &quot;is&quot;, &quot;awesome&quot; ] }
+</pre></div></div></li>
+</ul>
+<!-- ### hashed-word-tokens ###
+ * Syntax:
+
+        hashed-word-tokens(string_expression)
+
+ * Returns a list of hashed word tokens of `string_expression`.
+ * Arguments:
+    * `string_expression` : A `string` that will be tokenized.
+ * Return Value:
+   * An `OrderedList` of `int32` hashed tokens.
+
+ * Example:
+
+        use dataverse TinySocial;
+
+        for $t in dataset('TweetMessages')
+        let $tokens := hashed-word-tokens($t.message-text)
+        where $t.send-time >= datetime('2012-01-01T00:00:00')
+        return {
+        "tweetid": $t.tweetid,
+        "hashed-word-tokens": $tokens
+        }
+
+
+ * The expected result is:
+
+        { "tweetid": "9", "hashed-word-tokens": [ -1217719622, -447857469, -1884722688, -325178649, 210976949, 285049676, 1916743959 ] }
+
+
+### counthashed-word-tokens ###
+ * Syntax:
+
+        counthashed-word-tokens(string_expression)
+
+ * Returns a list of hashed word tokens of `string_expression`. The hashing mechanism gives duplicate tokens different hash values, based on the occurrence count of that token.
+ * Arguments:
+    * `string_expression` : A `String` that will be tokenized.
+ * Return Value:
+    * An `OrderedList` of `Int32` hashed tokens.
+ * Example:
+
+        use dataverse TinySocial;
+
+        for $t in dataset('TweetMessages')
+        let $tokens := counthashed-word-tokens($t.message-text)
+        where $t.send-time >= datetime('2012-01-01T00:00:00')
+        return {
+        "tweetid": $t.tweetid,
+        "counthashed-word-tokens": $tokens
+        }
+
+
+ * The expected result is:
+
+        { "tweetid": "9", "counthashed-word-tokens": [ -1217719622, -447857469, -1884722688, -325178649, 210976949, 285049676, 1916743959 ] }
+
+
+### gram-tokens ###
+ * Syntax:
+
+        gram-tokens(string_expression, gram_length, boolean_expression)
+
+ * Returns a list of gram tokens of `string_expression`, which can be obtained by scanning the characters using a sliding window of a fixed length.
+ * Arguments:
+    * `string_expression` : A `String` that will be tokenized.
+    * `gram_length` : An `Int32` as the length of grams.
+   * `boolean_expression` : A `Boolean` value to indicate whether to generate additional grams by pre- and postfixing `string_expression` with special characters.
+ * Return Value:
+    * An `OrderedList` of String gram tokens.
+
+ * Example:
+
+        use dataverse TinySocial;
+
+        for $t in dataset('TweetMessages')
+        let $tokens := gram-tokens($t.message-text, 3, true)
+        where $t.send-time >= datetime('2012-01-01T00:00:00')
+        return {
+        "tweetid": $t.tweetid,
+        "gram-tokens": $tokens
+        }
+
+
+ * The expected result is:
+
+        {
+        "tweetid": "9",
+        "gram-tokens": [ "## ", "# l", " lo", "lov", "ove", "ve ", "e v", " ve", "ver", "eri", "riz", "izo", "zon", "on ", "n i", " it", "its", "ts ", "s v", " vo", "voi", "oic", "ice",
+        "cem", "ema", "mai", "ail", "il-", "l-s", "-se", "ser", "erv", "rvi", "vic", "ice", "ce ", "e i", " is", "is ", "s a", " aw", "awe", "wes", "eso", "som", "ome", "me$", "e$$" ]
+        }
+
+
+### hashed-gram-tokens ###
+ * Syntax:
+
+        hashed-gram-tokens(string_expression, gram_length, boolean_expression)
+
+ * Returns a list of hashed gram tokens of `string_expression`.
+ * Arguments:
+    * `string_expression` : A `String` that will be tokenized.
+    * `gram_length` : An `Int32` as the length of grams.
+    * `boolean_expression` : A `Boolean` to indicate whether to generate additional grams by pre- and postfixing `string_expression` with special characters.
+ * Return Value:
+    * An `OrderedList` of `Int32` hashed gram tokens.
+
+ * Example:
+
+        use dataverse TinySocial;
+
+        for $t in dataset('TweetMessages')
+        let $tokens := hashed-gram-tokens($t.message-text, 3, true)
+        where $t.send-time >= datetime('2012-01-01T00:00:00')
+        return {
+        "tweetid": $t.tweetid,
+        "hashed-gram-tokens": $tokens
+        }
+
+
+ * The expected result is:
+
+        {
+        "tweetid": "9",
+        "hashed-gram-tokens": [ 40557178, -2002241593, 161665899, -856104603, -500544946, 693410611, 395674299, -1015235909, 1115608337, 1187999872, -31006095, -219180466, -1676061637,
+        1040194153, -1339307841, -1527110163, -1884722688, -179148713, -431014627, -1789789823, -1209719926, 684519765, -486734513, 1734740619, -1971673751, -932421915, -2064668066,
+        -937135958, -790946468, -69070309, 1561601454, 26169001, -160734571, 1330043462, -486734513, -18796768, -470303314, 113421364, 1615760212, 1688217556, 1223719184, 536568131,
+        1682609873, 2935161, -414769471, -1027490137, 1602276102, 1050490461 ]
+        }
+
+
+### counthashed-gram-tokens ###
+ * Syntax:
+
+        counthashed-gram-tokens(string_expression, gram_length, boolean_expression)
+
+ * Returns a list of hashed gram tokens of `string_expression`. The hashing mechanism gives duplicate tokens different hash values, based on the occurrence count of that token.
+ * Arguments:
+    * `string_expression` : A `String` that will be tokenized.
+    * `gram_length` : An `Int32`, length of grams to generate.
+    * `boolean_expression` : A `Boolean`, whether to generate additional grams by pre- and postfixing `string_expression` with special characters.
+ * Return Value:
+    * An `OrderedList` of `Int32` hashed gram tokens.
+
+ * Example:
+
+        use dataverse TinySocial;
+
+        for $t in dataset('TweetMessages')
+        let $tokens := counthashed-gram-tokens($t.message-text, 3, true)
+        where $t.send-time >= datetime('2012-01-01T00:00:00')
+        return {
+        "tweetid": $t.tweetid,
+        "counthashed-gram-tokens": $tokens
+        }
+
+
+ * The expected result is:
+
+        {
+        "tweetid": "9",
+        "counthashed-gram-tokens": [ 40557178, -2002241593, 161665899, -856104603, -500544946, 693410611, 395674299, -1015235909, 1115608337, 1187999872, -31006095, -219180466, -1676061637,
+        1040194153, -1339307841, -1527110163, -1884722688, -179148713, -431014627, -1789789823, -1209719926, 684519765, -486734513, 1734740619, -1971673751, -932421915, -2064668066, -937135958,
+        -790946468, -69070309, 1561601454, 26169

<TRUNCATED>


Mime
View raw message