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