blob: b72617f135d274745ae1be24d9479e6941eda5f6 [file] [log] [blame]
<!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 Data Model (ADM)</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 class="active">
<a href="#"><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>
<a href="../aql/functions.html" title="AQL Functions">
<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 Data Model (ADM)</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="#PrimitiveTypes">Primitive Types</a>
<ul>
<li><a href="#PrimitiveTypesBoolean">Boolean</a></li>
<li><a href="#PrimitiveTypesInt">Int8 / Int16 / Int32 / Int64</a></li>
<li><a href="#PrimitiveTypesFloat">Float</a></li>
<li><a href="#PrimitiveTypesDouble">Double</a></li>
<li><a href="#PrimitiveTypesString">String</a></li>
<li><a href="#PrimitiveTypesPoint">Point</a></li>
<li><a href="#PrimitiveTypesLine">Line</a></li>
<li><a href="#PrimitiveTypesRectangle">Rectangle</a></li>
<li><a href="#PrimitiveTypesCircle">Circle</a></li>
<li><a href="#PrimitiveTypesPolygon">Polygon</a></li>
<li><a href="#PrimitiveTypesDate">Date</a></li>
<li><a href="#PrimitiveTypesTime">Time</a></li>
<li><a href="#PrimitiveTypesDateTime">Datetime</a></li>
<li><a href="#PrimitiveTypesDuration">Duration/Year-month-duration/Day-time-duration</a></li>
<li><a href="#PrimitiveTypesInterval">Interval</a></li>
<li><a href="#PrimitiveTypesUUID">UUID</a></li>
</ul></li>
<li><a href="#DerivedTypes">Derived Types</a>
<ul>
<li><a href="#DerivedTypesRecord">Record</a></li>
<li><a href="#DerivedTypesOrderedList">OrderedList</a></li>
<li><a href="#DerivedTypesUnorderedList">UnorderedList</a></li>
</ul></li>
</ul>
<p>An instance of Asterix data model (ADM) can be a <i><i>primitive type</i></i> (<tt>int32</tt>, <tt>int64</tt>, <tt>string</tt>, <tt>float</tt>, <tt>double</tt>, <tt>date</tt>, <tt>time</tt>, <tt>datetime</tt>, etc. or <tt>null</tt>) or a <i><i>derived type</i></i>.</p></div>
<div class="section">
<h2><a name="Primitive_Types_Back_to_TOC"></a><a name="PrimitiveTypes" id="PrimitiveTypes">Primitive Types</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
<div class="section">
<h3><a name="BooleanBack_to_TOC"></a><a name="PrimitiveTypesBoolean" id="PrimitiveTypesBoolean">Boolean</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>boolean</tt> data type can have one of the two values: <i><i>true</i></i> or <i><i>false</i></i>.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $t := true
let $f := false
return { &quot;true&quot;: $t, &quot;false&quot;: $f }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;true&quot;: true, &quot;false&quot;: false }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="Int8__Int16__Int32__Int64_Back_to_TOC"></a><a name="PrimitiveTypesInt" id="PrimitiveTypesInt">Int8 / Int16 / Int32 / Int64</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p>Integer types using 8, 16, 32, or 64 bits. The ranges of these types are:</p>
<ul>
<li><tt>int8</tt>: -127 to 127</li>
<li><tt>int16</tt>: -32767 to 32767</li>
<li><tt>int32</tt>: -2147483647 to 2147483647</li>
<li><tt>int64</tt>: -9223372036854775808 to 9223372036854775807</li>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v8 := int8(&quot;125&quot;)
let $v16 := int16(&quot;32765&quot;)
let $v32 := 294967295
let $v64 := int64(&quot;1700000000000000000&quot;)
return { &quot;int8&quot;: $v8, &quot;int16&quot;: $v16, &quot;int32&quot;: $v32, &quot;int64&quot;: $v64}
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;int8&quot;: 125i8, &quot;int16&quot;: 32765i16, &quot;int32&quot;: 294967295, &quot;int64&quot;: 1700000000000000000i64 }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="Float_Back_to_TOC"></a><a name="PrimitiveTypesFloat" id="PrimitiveTypesFloat">Float</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>float</tt> represents approximate numeric data values using 4 bytes. The range of a float value can be from 2^(-149) to (2-2^(-23)&#xb7;2^(127) for both positive and negative. Beyond these ranges will get <tt>INF</tt> or <tt>-INF</tt>.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := float(&quot;NaN&quot;)
let $v2 := float(&quot;INF&quot;)
let $v3 := float(&quot;-INF&quot;)
let $v4 := float(&quot;-2013.5&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: NaNf, &quot;v2&quot;: Infinityf, &quot;v3&quot;: -Infinityf, &quot;v4&quot;: -2013.5f }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="Double_Back_to_TOC"></a><a name="PrimitiveTypesDouble" id="PrimitiveTypesDouble">Double</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>double</tt> represents approximate numeric data values using 8 bytes. The range of a double value can be from (2^(-1022)) to (2-2^(-52))&#xb7;2^(1023) for both positive and negative. Beyond these ranges will get <tt>INF</tt> or <tt>-INF</tt>.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := double(&quot;NaN&quot;)
let $v2 := double(&quot;INF&quot;)
let $v3 := double(&quot;-INF&quot;)
let $v4 := double(&quot;-2013.593823748327284&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: NaNd, &quot;v2&quot;: Infinityd, &quot;v3&quot;: -Infinityd, &quot;v4&quot;: -2013.5938237483274d }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="String_Back_to_TOC"></a><a name="PrimitiveTypesString" id="PrimitiveTypesString">String</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>string</tt> represents a sequence of characters.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := string(&quot;This is a string.&quot;)
let $v2 := string(&quot;\&quot;This is a quoted string\&quot;&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: &quot;This is a string.&quot;, &quot;v2&quot;: &quot;\&quot;This is a quoted string\&quot;&quot; }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="Point_Back_to_TOC"></a><a name="PrimitiveTypesPoint" id="PrimitiveTypesPoint">Point</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>point</tt> is the fundamental two-dimensional building block for spatial types. It consists of two <tt>double</tt> coordinates x and y.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := point(&quot;80.10d, -10E5&quot;)
let $v2 := point(&quot;5.10E-10d, -10E5&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: point(&quot;80.1,-1000000.0&quot;), &quot;v2&quot;: point(&quot;5.1E-10,-1000000.0&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="Line_Back_to_TOC"></a><a name="PrimitiveTypesLine" id="PrimitiveTypesLine">Line</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>line</tt> consists of two points that represent the start and the end points of a line segment.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := line(&quot;10.1234,11.1e-1 +10.2E-2,-11.22&quot;)
let $v2 := line(&quot;0.1234,-1.00e-10 +10.5E-2,-01.02&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: line(&quot;10.1234,1.11 0.102,-11.22&quot;), &quot;v2&quot;: line(&quot;0.1234,-1.0E-10 0.105,-1.02&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="RectangleBack_to_TOC"></a><a name="PrimitiveTypesRectangle" id="PrimitiveTypesRectangle">Rectangle</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>rectangle</tt> consists of two points that represent the <i><i>bottom left</i></i> and <i><i>upper right</i></i> corners of a rectangle.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := rectangle(&quot;5.1,11.8 87.6,15.6548&quot;)
let $v2 := rectangle(&quot;0.1234,-1.00e-10 5.5487,0.48765&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: rectangle(&quot;5.1,11.8 87.6,15.6548&quot;), &quot;v2&quot;: rectangle(&quot;0.1234,-1.0E-10 5.5487,0.48765&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="CircleBack_to_TOC"></a><a name="PrimitiveTypesCircle" id="PrimitiveTypesCircle">Circle</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>circle</tt> consists of one point that represents the center of the circle and a radius of type <tt>double</tt>.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := circle(&quot;10.1234,11.1e-1 +10.2E-2&quot;)
let $v2 := circle(&quot;0.1234,-1.00e-10 +10.5E-2&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: circle(&quot;10.1234,1.11 0.102&quot;), &quot;v2&quot;: circle(&quot;0.1234,-1.0E-10 0.105&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="PolygonBack_to_TOC"></a><a name="PrimitiveTypesPolygon" id="PrimitiveTypesPolygon">Polygon</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>polygon</tt> consists of <i><i>n</i></i> points that represent the vertices of a <i><i>simple closed</i></i> polygon.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := polygon(&quot;-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81&quot;)
let $v2 := polygon(&quot;-1.0,+10.5e2 -02.15E+50,2.5 -1.0,+3.3e3 -2.50E+05,20.15 +3.5e+2,03.6 -4.60E-3,+4.75 -2,+1.0e2 -2.00E+5,20.10 30.5,03.25 -4.33E-3,+4.75&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: polygon(&quot;-1.2,130.0 -214000.0,2.15 -350.0,3.6 -0.0046,4.81&quot;), &quot;v2&quot;: polygon(&quot;-1.0,1050.0 -2.15E50,2.5 -1.0,3300.0 -250000.0,20.15 350.0,3.6 -0.0046,4.75 -2.0,100.0 -200000.0,20.1 30.5,3.25 -0.00433,4.75&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="DateBack_to_TOC"></a><a name="PrimitiveTypesDate" id="PrimitiveTypesDate">Date</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>date</tt> represents a time point along the Gregorian calendar system specified by the year, month and day. ASTERIX supports the date from <tt>-9999-01-01</tt> to <tt>9999-12-31</tt>.</p>
<p>A date value can be represented in two formats, extended format and basic format.</p>
<ul>
<li>Extended format is represented as <tt>[-]yyyy-mm-dd</tt> for <tt>year-month-day</tt>. Each field should be padded if there are less digits than the format specified.</li>
<li>Basic format is in the format of <tt>[-]yyyymmdd</tt>.</li>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := date(&quot;2013-01-01&quot;)
let $v2 := date(&quot;-19700101&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-1970-01-01&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="TimeBack_to_TOC"></a><a name="PrimitiveTypesTime" id="PrimitiveTypesTime">Time</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>time</tt> type describes the time within the range of a day. It is represented by three fields: hour, minute and second. Millisecond field is optional as the fraction of the second field. Its extended format is as <tt>hh:mm:ss[.mmm]</tt> and the basic format is <tt>hhmmss[mmm]</tt>. The value domain is from <tt>00:00:00.000</tt> to <tt>23:59:59.999</tt>.</p>
<p>Timezone field is optional for a time value. Timezone is represented as <tt>[+|-]hh:mm</tt> for extended format or <tt>[+|-]hhmm</tt> for basic format. Note that the sign designators cannot be omitted. <tt>Z</tt> can also be used to represent the UTC local time. If no timezone information is given, it is UTC by default.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := time(&quot;12:12:12.039Z&quot;)
let $v2 := time(&quot;000000000-0800&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;08:00:00.000Z&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="DatetimeBack_to_TOC"></a><a name="PrimitiveTypesDateTime" id="PrimitiveTypesDateTime">Datetime</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p>A <tt>datetime</tt> value is a combination of an <tt>date</tt> and <tt>time</tt>, representing a fixed time point along the Gregorian calendar system. The value is among <tt>-9999-01-01 00:00:00.000</tt> and <tt>9999-12-31 23:59:59.999</tt>.</p>
<p>A <tt>datetime</tt> value is represented as a combination of the representation of its <tt>date</tt> part and <tt>time</tt> part, separated by a separator <tt>T</tt>. Either extended or basic format can be used, and the two parts should be the same format.</p>
<p>Millisecond field and timezone field are optional, as specified in the <tt>time</tt> type.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := datetime(&quot;2013-01-01T12:12:12.039Z&quot;)
let $v2 := datetime(&quot;-19700101T000000000-0800&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: datetime(&quot;2013-01-01T12:12:12.039Z&quot;), &quot;v2&quot;: datetime(&quot;-1970-01-01T08:00:00.000Z&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="DurationYear-month-durationDay-time-durationBack_to_TOC"></a><a name="PrimitiveTypesDuration" id="PrimitiveTypesDuration">Duration/Year-month-duration/Day-time-duration</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>duration</tt> represents a duration of time. A duration value is specified by integers on at least one of the following fields: year, month, day, hour, minute, second, and millisecond.</p>
<p>A duration value is in the format of <tt>[-]PnYnMnDTnHnMn.mmmS</tt>. The millisecond part (as the fraction of the second field) is optional, and when no millisecond field is used, the decimal point should also be absent.</p>
<p>Negative durations are also supported for the arithmetic operations between time instance types (<tt>date</tt>, <tt>time</tt> and <tt>datetime</tt>), and is used to roll the time back for the given duration. For example <tt>date(&quot;2012-01-01&quot;) + duration(&quot;-P3D&quot;)</tt> will return <tt>date(&quot;2011-12-29&quot;)</tt>.</p>
<p>There are also two sub-duration types, namely <tt>year-month-duration</tt> and <tt>day-time-duration</tt>. <tt>year-month-duration</tt> represents only the years and months of a duration, while <tt>day-time-duration</tt> represents only the day to millisecond fields. Different from the <tt>duration</tt> type, both these two subtypes are totally ordered, so they can be used for comparison and index construction.</p>
<p>Note that a canonical representation of the duration is always returned, regardless whether the duration is in the canonical representation or not from the user&#x2019;s input. More information about canonical representation can be found from <a class="externalLink" href="http://www.w3.org/TR/xpath-functions/#canonical-dayTimeDuration">XPath dayTimeDuration Canonical Representation</a> and <a class="externalLink" href="http://www.w3.org/TR/xpath-functions/#canonical-yearMonthDuration">yearMonthDuration Canonical Representation</a>.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := duration(&quot;P100Y12MT12M&quot;)
let $v2 := duration(&quot;-PT20.943S&quot;)
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: duration(&quot;P101YT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="IntervalBack_to_TOC"></a><a name="PrimitiveTypesInterval" id="PrimitiveTypesInterval">Interval</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>interval</tt> represents inclusive-exclusive ranges of time. It is defined by two time point values with the same temporal type(<tt>date</tt>, <tt>time</tt> or <tt>datetime</tt>).</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := interval-from-date(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))
let $v2 := interval-from-time(time(&quot;00:01:01&quot;), time(&quot;213901049+0800&quot;))
let $v3 := interval-from-datetime(datetime(&quot;2013-01-01T00:01:01&quot;), datetime(&quot;20130505T213901049+0800&quot;))
return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: interval-date(&quot;2013-01-01, 2013-05-05&quot;), &quot;v2&quot;: interval-time(&quot;00:01:01.000Z, 13:39:01.049Z&quot;), &quot;v3&quot;: interval-datetime(&quot;2013-01-01T00:01:01.000Z, 2013-05-05T13:39:01.049Z&quot;) }
</pre></div></div></li>
</ul></div>
<div class="section">
<h3><a name="UUIDBack_to_TOC"></a><a name="PrimitiveTypesUUID" id="PrimitiveTypesUUID">UUID</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p><tt>uuid</tt> represents a UUID value, which stands for Universally unique identifier. It is defined by a canonical format using hexadecimal text with inserted hyphen characters. (E.g.: 5a28ce1e-6a74-4201-9e8f-683256e5706f). This type is generally used to store auto-generated primary key values.</p>
<ul>
<li>
<p>Example:</p>
<div class="source">
<div class="source">
<pre>let $v1 := uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;)
return { &quot;v1&quot;:$v1 }
</pre></div></div></li>
</ul>
<ul>
<li>
<p>The expected result is:</p>
<div class="source">
<div class="source">
<pre>{ &quot;v1&quot;: uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
</pre></div></div></li>
</ul></div></div>
<div class="section">
<h2><a name="Derived_TypesBack_to_TOC"></a><a name="DerivedTypes" id="DerivedTypes">Derived Types</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
<div class="section">
<h3><a name="RecordBack_to_TOC"></a><a name="DerivedTypesRecord" id="DerivedTypesRecord">Record</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p>A <tt>record</tt> contains a set of &#xfb01;elds, where each &#xfb01;eld is described by its name and type. A record type is either open or closed. Open records can contain &#xfb01;elds that are not part of the type de&#xfb01;nition, while closed records cannot. Syntactically, record constructors are surrounded by curly braces &#x201c;{&#x2026;}&#x201d;.</p>
<p>An example would be</p>
<div class="source">
<div class="source">
<pre> { &quot;id&quot;: 213508, &quot;name&quot;: &quot;Alice Bob&quot; }
</pre></div></div></div>
<div class="section">
<h3><a name="OrderedListBack_to_TOC"></a><a name="DerivedTypesOrderedList" id="DerivedTypesOrderedList">OrderedList</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p>An <tt>orderedList</tt> is a sequence of values for which the order is determined by creation or insertion. OrderedList constructors are denoted by brackets: &#x201c;[&#x2026;]&#x201d;.</p>
<p>An example would be</p>
<div class="source">
<div class="source">
<pre> [&quot;alice&quot;, 123, &quot;bob&quot;, null]
</pre></div></div></div>
<div class="section">
<h3><a name="UnorderedListBack_to_TOC"></a><a name="DerivedTypesUnorderedList" id="DerivedTypesUnorderedList">UnorderedList</a><font size="4"><a href="#toc">[Back to TOC]</a></font></h3>
<p>An <tt>unorderedList</tt> is an unordered sequence of values, similar to bags in SQL. UnorderedList constructors are denoted by two opening flower braces followed by data and two closing flower braces, like &#x201c;{{&#x2026;}}&#x201d;.</p>
<p>An example would be</p>
<div class="source">
<div class="source">
<pre> {{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}}
</pre></div></div></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row span12">Copyright &copy; 2016
<a href="http://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>