blob: 9c7189b137dedb01c6f0c40817d791c366243bf3 [file] [log] [blame]
Yingyi Bu08953b22016-03-25 15:23:26 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia at 2016-03-25
4 | Rendered using Apache Maven Fluido Skin 1.3.0
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20160325" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; Asterix Data Model (ADM)</title>
13 <link rel="stylesheet" href="../css/apache-maven-fluido-1.3.0.min.css" />
14 <link rel="stylesheet" href="../css/site.css" />
15 <link rel="stylesheet" href="../css/print.css" media="print" />
16
17
18 <script type="text/javascript" src="../js/apache-maven-fluido-1.3.0.min.js"></script>
19
20
21
22<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
23 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
24 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
25 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
26
27 ga('create', 'UA-41536543-1', 'uci.edu');
28 ga('send', 'pageview');</script>
29
30 </head>
31 <body class="topBarDisabled">
32
33
34
35
36 <div class="container-fluid">
37 <div id="banner">
38 <div class="pull-left">
39 <a href="http://asterixdb.apache.org/" id="bannerLeft">
40 <img src="../images/asterixlogo.png" alt="AsterixDB"/>
41 </a>
42 </div>
43 <div class="pull-right"> </div>
44 <div class="clear"><hr/></div>
45 </div>
46
47 <div id="breadcrumbs">
48 <ul class="breadcrumb">
49
50
51 <li id="publishDate">Last Published: 2016-03-25</li>
52
53
54
55 <li id="projectVersion" class="pull-right">Version: 0.8.8-incubating</li>
56
57 <li class="divider pull-right">|</li>
58
59 <li class="pull-right"> <a href="../index.html" title="Documentation Home">
60 Documentation Home</a>
61 </li>
62
63 </ul>
64 </div>
65
66
67 <div class="row-fluid">
68 <div id="leftColumn" class="span3">
69 <div class="well sidebar-nav">
70
71
72 <ul class="nav nav-list">
73 <li class="nav-header">Documentation</li>
74
75 <li>
76
77 <a href="../install.html" title="Installing and Managing AsterixDB using Managix">
78 <i class="none"></i>
79 Installing and Managing AsterixDB using Managix</a>
80 </li>
81
82 <li>
83
84 <a href="../yarn.html" title="Deploying AsterixDB using YARN">
85 <i class="none"></i>
86 Deploying AsterixDB using YARN</a>
87 </li>
88
89 <li>
90
91 <a href="../aql/primer.html" title="AsterixDB 101: An ADM and AQL Primer">
92 <i class="none"></i>
93 AsterixDB 101: An ADM and AQL Primer</a>
94 </li>
95
96 <li>
97
98 <a href="../aql/primer-sql-like.html" title="AsterixDB 101: An ADM and AQL Primer (For SQL Fans)">
99 <i class="none"></i>
100 AsterixDB 101: An ADM and AQL Primer (For SQL Fans)</a>
101 </li>
102
Yingyi Bu08953b22016-03-25 15:23:26 -0700103 <li class="active">
104
105 <a href="#"><i class="none"></i>Asterix Data Model (ADM)</a>
106 </li>
107
108 <li>
109
110 <a href="../aql/manual.html" title="Asterix Query Language (AQL)">
111 <i class="none"></i>
112 Asterix Query Language (AQL)</a>
113 </li>
114
115 <li>
116
117 <a href="../aql/functions.html" title="AQL Functions">
118 <i class="none"></i>
119 AQL Functions</a>
120 </li>
121
122 <li>
123
124 <a href="../aql/allens.html" title="AQL Allen's Relations Functions">
125 <i class="none"></i>
126 AQL Allen's Relations Functions</a>
127 </li>
128
129 <li>
130
131 <a href="../aql/similarity.html" title="AQL Support of Similarity Queries">
132 <i class="none"></i>
133 AQL Support of Similarity Queries</a>
134 </li>
135
136 <li>
137
138 <a href="../aql/externaldata.html" title="Accessing External Data">
139 <i class="none"></i>
140 Accessing External Data</a>
141 </li>
142
143 <li>
144
145 <a href="../feeds/tutorial.html" title="Support for Data Ingestion in AsterixDB">
146 <i class="none"></i>
147 Support for Data Ingestion in AsterixDB</a>
148 </li>
149
150 <li>
151
152 <a href="../udf.html" title="Support for User Defined Functions in AsterixDB">
153 <i class="none"></i>
154 Support for User Defined Functions in AsterixDB</a>
155 </li>
156
157 <li>
158
159 <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
160 <i class="none"></i>
161 Filter-Based LSM Index Acceleration</a>
162 </li>
163
164 <li>
165
166 <a href="../api.html" title="HTTP API to AsterixDB">
167 <i class="none"></i>
168 HTTP API to AsterixDB</a>
169 </li>
170 </ul>
171
172
173
174 <hr class="divider" />
175
176 <div id="poweredBy">
177 <div class="clear"></div>
178 <div class="clear"></div>
179 <div class="clear"></div>
180 <a href="https://code.google.com/p/hyracks/" title="Hyracks" class="builtBy">
181 <img class="builtBy" alt="Hyracks" src="../images/hyrax_ts.png" />
182 </a>
183 </div>
184 </div>
185 </div>
186
187
188 <div id="bodyColumn" class="span9" >
189
190 <!-- ! Licensed to the Apache Software Foundation (ASF) under one
191 ! or more contributor license agreements. See the NOTICE file
192 ! distributed with this work for additional information
193 ! regarding copyright ownership. The ASF licenses this file
194 ! to you under the Apache License, Version 2.0 (the
195 ! "License"); you may not use this file except in compliance
196 ! with the License. You may obtain a copy of the License at
197 !
198 ! http://www.apache.org/licenses/LICENSE-2.0
199 !
200 ! Unless required by applicable law or agreed to in writing,
201 ! software distributed under the License is distributed on an
202 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
203 ! KIND, either express or implied. See the License for the
204 ! specific language governing permissions and limitations
205 ! under the License.
206 ! --><h1>Asterix Data Model (ADM)</h1>
207<div class="section">
208<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
209
210<ul>
211
212<li><a href="#PrimitiveTypes">Primitive Types</a>
213
214<ul>
215
216<li><a href="#PrimitiveTypesBoolean">Boolean</a></li>
217
218<li><a href="#PrimitiveTypesInt">Int8 / Int16 / Int32 / Int64</a></li>
219
220<li><a href="#PrimitiveTypesFloat">Float</a></li>
221
222<li><a href="#PrimitiveTypesDouble">Double</a></li>
223
224<li><a href="#PrimitiveTypesString">String</a></li>
225
226<li><a href="#PrimitiveTypesPoint">Point</a></li>
227
228<li><a href="#PrimitiveTypesLine">Line</a></li>
229
230<li><a href="#PrimitiveTypesRectangle">Rectangle</a></li>
231
232<li><a href="#PrimitiveTypesCircle">Circle</a></li>
233
234<li><a href="#PrimitiveTypesPolygon">Polygon</a></li>
235
236<li><a href="#PrimitiveTypesDate">Date</a></li>
237
238<li><a href="#PrimitiveTypesTime">Time</a></li>
239
240<li><a href="#PrimitiveTypesDateTime">Datetime</a></li>
241
242<li><a href="#PrimitiveTypesDuration">Duration/Year-month-duration/Day-time-duration</a></li>
243
244<li><a href="#PrimitiveTypesInterval">Interval</a></li>
245
246<li><a href="#PrimitiveTypesUUID">UUID</a></li>
247 </ul></li>
248
249<li><a href="#DerivedTypes">Derived Types</a>
250
251<ul>
252
253<li><a href="#DerivedTypesRecord">Record</a></li>
254
255<li><a href="#DerivedTypesOrderedList">OrderedList</a></li>
256
257<li><a href="#DerivedTypesUnorderedList">UnorderedList</a></li>
258 </ul></li>
259</ul>
260<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>
261<div class="section">
262<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>
263<div class="section">
264<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>
265<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>
266
267<ul>
268
269<li>
270<p>Example:</p>
271
272<div class="source">
273<div class="source">
274<pre>let $t := true
275let $f := false
276return { &quot;true&quot;: $t, &quot;false&quot;: $f }
277</pre></div></div></li>
278</ul>
279
280<ul>
281
282<li>
283<p>The expected result is:</p>
284
285<div class="source">
286<div class="source">
287<pre>{ &quot;true&quot;: true, &quot;false&quot;: false }
288</pre></div></div></li>
289</ul></div>
290<div class="section">
291<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>
292<p>Integer types using 8, 16, 32, or 64 bits. The ranges of these types are:</p>
293
294<ul>
295
296<li><tt>int8</tt>: -127 to 127</li>
297
298<li><tt>int16</tt>: -32767 to 32767</li>
299
300<li><tt>int32</tt>: -2147483647 to 2147483647</li>
301
302<li><tt>int64</tt>: -9223372036854775808 to 9223372036854775807</li>
303
304<li>
305<p>Example:</p>
306
307<div class="source">
308<div class="source">
309<pre>let $v8 := int8(&quot;125&quot;)
310let $v16 := int16(&quot;32765&quot;)
311let $v32 := 294967295
312let $v64 := int64(&quot;1700000000000000000&quot;)
313return { &quot;int8&quot;: $v8, &quot;int16&quot;: $v16, &quot;int32&quot;: $v32, &quot;int64&quot;: $v64}
314</pre></div></div></li>
315</ul>
316
317<ul>
318
319<li>
320<p>The expected result is:</p>
321
322<div class="source">
323<div class="source">
324<pre>{ &quot;int8&quot;: 125i8, &quot;int16&quot;: 32765i16, &quot;int32&quot;: 294967295, &quot;int64&quot;: 1700000000000000000i64 }
325</pre></div></div></li>
326</ul></div>
327<div class="section">
328<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>
329<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>
330
331<ul>
332
333<li>
334<p>Example:</p>
335
336<div class="source">
337<div class="source">
338<pre>let $v1 := float(&quot;NaN&quot;)
339let $v2 := float(&quot;INF&quot;)
340let $v3 := float(&quot;-INF&quot;)
341let $v4 := float(&quot;-2013.5&quot;)
342return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
343</pre></div></div></li>
344</ul>
345
346<ul>
347
348<li>
349<p>The expected result is:</p>
350
351<div class="source">
352<div class="source">
353<pre>{ &quot;v1&quot;: NaNf, &quot;v2&quot;: Infinityf, &quot;v3&quot;: -Infinityf, &quot;v4&quot;: -2013.5f }
354</pre></div></div></li>
355</ul></div>
356<div class="section">
357<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>
358<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>
359
360<ul>
361
362<li>
363<p>Example:</p>
364
365<div class="source">
366<div class="source">
367<pre>let $v1 := double(&quot;NaN&quot;)
368let $v2 := double(&quot;INF&quot;)
369let $v3 := double(&quot;-INF&quot;)
370let $v4 := double(&quot;-2013.593823748327284&quot;)
371return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
372</pre></div></div></li>
373</ul>
374
375<ul>
376
377<li>
378<p>The expected result is:</p>
379
380<div class="source">
381<div class="source">
382<pre>{ &quot;v1&quot;: NaNd, &quot;v2&quot;: Infinityd, &quot;v3&quot;: -Infinityd, &quot;v4&quot;: -2013.5938237483274d }
383</pre></div></div></li>
384</ul></div>
385<div class="section">
386<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>
387<p><tt>string</tt> represents a sequence of characters.</p>
388
389<ul>
390
391<li>
392<p>Example:</p>
393
394<div class="source">
395<div class="source">
396<pre>let $v1 := string(&quot;This is a string.&quot;)
397let $v2 := string(&quot;\&quot;This is a quoted string\&quot;&quot;)
398return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
399</pre></div></div></li>
400</ul>
401
402<ul>
403
404<li>
405<p>The expected result is:</p>
406
407<div class="source">
408<div class="source">
409<pre>{ &quot;v1&quot;: &quot;This is a string.&quot;, &quot;v2&quot;: &quot;\&quot;This is a quoted string\&quot;&quot; }
410</pre></div></div></li>
411</ul></div>
412<div class="section">
413<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>
414<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>
415
416<ul>
417
418<li>
419<p>Example:</p>
420
421<div class="source">
422<div class="source">
423<pre>let $v1 := point(&quot;80.10d, -10E5&quot;)
424let $v2 := point(&quot;5.10E-10d, -10E5&quot;)
425return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
426</pre></div></div></li>
427</ul>
428
429<ul>
430
431<li>
432<p>The expected result is:</p>
433
434<div class="source">
435<div class="source">
436<pre>{ &quot;v1&quot;: point(&quot;80.1,-1000000.0&quot;), &quot;v2&quot;: point(&quot;5.1E-10,-1000000.0&quot;) }
437</pre></div></div></li>
438</ul></div>
439<div class="section">
440<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>
441<p><tt>line</tt> consists of two points that represent the start and the end points of a line segment.</p>
442
443<ul>
444
445<li>
446<p>Example:</p>
447
448<div class="source">
449<div class="source">
450<pre>let $v1 := line(&quot;10.1234,11.1e-1 +10.2E-2,-11.22&quot;)
451let $v2 := line(&quot;0.1234,-1.00e-10 +10.5E-2,-01.02&quot;)
452return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
453</pre></div></div></li>
454</ul>
455
456<ul>
457
458<li>
459<p>The expected result is:</p>
460
461<div class="source">
462<div class="source">
463<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;) }
464</pre></div></div></li>
465</ul></div>
466<div class="section">
467<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>
468<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>
469
470<ul>
471
472<li>
473<p>Example:</p>
474
475<div class="source">
476<div class="source">
477<pre>let $v1 := rectangle(&quot;5.1,11.8 87.6,15.6548&quot;)
478let $v2 := rectangle(&quot;0.1234,-1.00e-10 5.5487,0.48765&quot;)
479return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
480</pre></div></div></li>
481</ul>
482
483<ul>
484
485<li>
486<p>The expected result is:</p>
487
488<div class="source">
489<div class="source">
490<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;) }
491</pre></div></div></li>
492</ul></div>
493<div class="section">
494<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>
495<p><tt>circle</tt> consists of one point that represents the center of the circle and a radius of type <tt>double</tt>.</p>
496
497<ul>
498
499<li>
500<p>Example:</p>
501
502<div class="source">
503<div class="source">
504<pre>let $v1 := circle(&quot;10.1234,11.1e-1 +10.2E-2&quot;)
505let $v2 := circle(&quot;0.1234,-1.00e-10 +10.5E-2&quot;)
506return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
507</pre></div></div></li>
508</ul>
509
510<ul>
511
512<li>
513<p>The expected result is:</p>
514
515<div class="source">
516<div class="source">
517<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;) }
518</pre></div></div></li>
519</ul></div>
520<div class="section">
521<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>
522<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>
523
524<ul>
525
526<li>
527<p>Example:</p>
528
529<div class="source">
530<div class="source">
531<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;)
532let $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;)
533return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
534</pre></div></div></li>
535</ul>
536
537<ul>
538
539<li>
540<p>The expected result is:</p>
541
542<div class="source">
543<div class="source">
544<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;) }
545</pre></div></div></li>
546</ul></div>
547<div class="section">
548<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>
549<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>
550<p>A date value can be represented in two formats, extended format and basic format.</p>
551
552<ul>
553
554<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>
555
556<li>Basic format is in the format of <tt>[-]yyyymmdd</tt>.</li>
557
558<li>
559<p>Example:</p>
560
561<div class="source">
562<div class="source">
563<pre>let $v1 := date(&quot;2013-01-01&quot;)
564let $v2 := date(&quot;-19700101&quot;)
565return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
566</pre></div></div></li>
567</ul>
568
569<ul>
570
571<li>
572<p>The expected result is:</p>
573
574<div class="source">
575<div class="source">
576<pre>{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-1970-01-01&quot;) }
577</pre></div></div></li>
578</ul></div>
579<div class="section">
580<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>
581<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>
582<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>
583
584<ul>
585
586<li>
587<p>Example:</p>
588
589<div class="source">
590<div class="source">
591<pre>let $v1 := time(&quot;12:12:12.039Z&quot;)
592let $v2 := time(&quot;000000000-0800&quot;)
593return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
594</pre></div></div></li>
595</ul>
596
597<ul>
598
599<li>
600<p>The expected result is:</p>
601
602<div class="source">
603<div class="source">
604<pre>{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;08:00:00.000Z&quot;) }
605</pre></div></div></li>
606</ul></div>
607<div class="section">
608<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>
609<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>
610<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>
611<p>Millisecond field and timezone field are optional, as specified in the <tt>time</tt> type.</p>
612
613<ul>
614
615<li>
616<p>Example:</p>
617
618<div class="source">
619<div class="source">
620<pre>let $v1 := datetime(&quot;2013-01-01T12:12:12.039Z&quot;)
621let $v2 := datetime(&quot;-19700101T000000000-0800&quot;)
622return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
623</pre></div></div></li>
624</ul>
625
626<ul>
627
628<li>
629<p>The expected result is:</p>
630
631<div class="source">
632<div class="source">
633<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;) }
634</pre></div></div></li>
635</ul></div>
636<div class="section">
637<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>
638<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>
639<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>
640<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>
641<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>
642<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>
643
644<ul>
645
646<li>
647<p>Example:</p>
648
649<div class="source">
650<div class="source">
651<pre>let $v1 := duration(&quot;P100Y12MT12M&quot;)
652let $v2 := duration(&quot;-PT20.943S&quot;)
653return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
654</pre></div></div></li>
655</ul>
656
657<ul>
658
659<li>
660<p>The expected result is:</p>
661
662<div class="source">
663<div class="source">
664<pre>{ &quot;v1&quot;: duration(&quot;P101YT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) }
665</pre></div></div></li>
666</ul></div>
667<div class="section">
668<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>
669<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>
670
671<ul>
672
673<li>
674<p>Example:</p>
675
676<div class="source">
677<div class="source">
678<pre>let $v1 := interval-from-date(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))
679let $v2 := interval-from-time(time(&quot;00:01:01&quot;), time(&quot;213901049+0800&quot;))
680let $v3 := interval-from-datetime(datetime(&quot;2013-01-01T00:01:01&quot;), datetime(&quot;20130505T213901049+0800&quot;))
681return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3 }
682</pre></div></div></li>
683</ul>
684
685<ul>
686
687<li>
688<p>The expected result is:</p>
689
690<div class="source">
691<div class="source">
692<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;) }
693</pre></div></div></li>
694</ul></div>
695<div class="section">
696<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>
697<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>
698
699<ul>
700
701<li>
702<p>Example:</p>
703
704<div class="source">
705<div class="source">
706<pre>let $v1 := uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;)
707return { &quot;v1&quot;:$v1 }
708</pre></div></div></li>
709</ul>
710
711<ul>
712
713<li>
714<p>The expected result is:</p>
715
716<div class="source">
717<div class="source">
718<pre>{ &quot;v1&quot;: uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
719</pre></div></div></li>
720</ul></div></div>
721<div class="section">
722<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>
723<div class="section">
724<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>
725<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>
726<p>An example would be</p>
727
728<div class="source">
729<div class="source">
730<pre> { &quot;id&quot;: 213508, &quot;name&quot;: &quot;Alice Bob&quot; }
731</pre></div></div></div>
732<div class="section">
733<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>
734<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>
735<p>An example would be</p>
736
737<div class="source">
738<div class="source">
739<pre> [&quot;alice&quot;, 123, &quot;bob&quot;, null]
740</pre></div></div></div>
741<div class="section">
742<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>
743<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>
744<p>An example would be</p>
745
746<div class="source">
747<div class="source">
748<pre> {{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}}
749</pre></div></div></div></div>
750 </div>
751 </div>
752 </div>
753
754 <hr/>
755
756 <footer>
757 <div class="container-fluid">
758 <div class="row span12">Copyright &copy; 2016
759 <a href="http://www.apache.org/">The Apache Software Foundation</a>.
760 All Rights Reserved.
761
762 </div>
763
764 <?xml version="1.0" encoding="UTF-8"?>
765<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
766 feather logo, and the Apache AsterixDB project logo are either
767 registered trademarks or trademarks of The Apache Software
768 Foundation in the United States and other countries.
769 All other marks mentioned may be trademarks or registered
770 trademarks of their respective owners.</div>
771
772
773 </div>
774 </footer>
775 </body>
776</html>