blob: 9e7b87abf991f8e5e2154395f36e1e8a9d1e93cf [file] [log] [blame]
Ian Maxoned124d82015-05-29 18:44:11 -07001<!DOCTYPE html>
2<!--
Till Westmann0817a3f2015-06-03 21:08:18 -07003 | Generated by Apache Maven Doxia at 2015-05-31
Ian Maxoned124d82015-05-29 18:44:11 -07004 | 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" />
Till Westmann0817a3f2015-06-03 21:08:18 -070010 <meta name="Date-Revision-yyyymmdd" content="20150531" />
Ian Maxoned124d82015-05-29 18:44:11 -070011 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB - </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 </head>
22 <body class="topBarDisabled">
23
24
25
26
27 <div class="container-fluid">
28 <div id="banner">
29 <div class="pull-left">
30 <a href=".././" id="bannerLeft">
31 <img src="../images/asterixlogo.png" alt="AsterixDB"/>
32 </a>
33 </div>
34 <div class="pull-right"> <a href="http://incubator.apache.org/" id="bannerRight">
35 <img src="../images/egg-logo.png" alt="Apache Software Foundation Incubator"/>
36 </a>
37 </div>
38 <div class="clear"><hr/></div>
39 </div>
40
41 <div id="breadcrumbs">
42 <ul class="breadcrumb">
43
44
Till Westmann0817a3f2015-06-03 21:08:18 -070045 <li id="publishDate">Last Published: 2015-05-31</li>
Ian Maxoned124d82015-05-29 18:44:11 -070046
47
48
49 <li id="projectVersion" class="pull-right">Version: 0.8.7-SNAPSHOT</li>
50
51 <li class="divider pull-right">|</li>
52
53 <li class="pull-right"> <a href="../index.html" title="Home">
54 Home</a>
55 </li>
56
57 </ul>
58 </div>
59
60
61 <div class="row-fluid">
62 <div id="leftColumn" class="span3">
63 <div class="well sidebar-nav">
64
65
66 <ul class="nav nav-list">
67 <li class="nav-header">Apache Software Foundation</li>
68
69 <li>
70
71 <a href="http://www.apache.org/" class="externalLink" title="Home">
72 <i class="none"></i>
73 Home</a>
74 </li>
75
76 <li>
77
78 <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Donate">
79 <i class="none"></i>
80 Donate</a>
81 </li>
82
83 <li>
84
85 <a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
86 <i class="none"></i>
87 Thanks</a>
88 </li>
89
90 <li>
91
92 <a href="http://www.apache.org/security/" class="externalLink" title="Security">
93 <i class="none"></i>
94 Security</a>
95 </li>
96 <li class="nav-header">User Documentation</li>
97
98 <li>
99
100 <a href="../install.html" title="Installing and Managing AsterixDB using Managix">
101 <i class="none"></i>
102 Installing and Managing AsterixDB using Managix</a>
103 </li>
104
105 <li>
106
107 <a href="../aql/primer.html" title="AsterixDB 101: An ADM and AQL Primer">
108 <i class="none"></i>
109 AsterixDB 101: An ADM and AQL Primer</a>
110 </li>
111
112 <li>
113
114 <a href="../aql/primer-sql-like.html" title="AsterixDB 101: An ADM and AQL Primer (For SQL Fans)">
115 <i class="none"></i>
116 AsterixDB 101: An ADM and AQL Primer (For SQL Fans)</a>
117 </li>
118
119 <li>
120
121 <a href="../aql/js-sdk.html" title="AsterixDB Javascript SDK">
122 <i class="none"></i>
123 AsterixDB Javascript SDK</a>
124 </li>
125
126 <li class="active">
127
128 <a href="#"><i class="none"></i>Asterix Data Model (ADM)</a>
129 </li>
130
131 <li>
132
133 <a href="../aql/manual.html" title="Asterix Query Language (AQL)">
134 <i class="none"></i>
135 Asterix Query Language (AQL)</a>
136 </li>
137
138 <li>
139
140 <a href="../aql/functions.html" title="AQL Functions">
141 <i class="none"></i>
142 AQL Functions</a>
143 </li>
144
145 <li>
146
147 <a href="../aql/allens.html" title="AQL Allen's Relations Functions">
148 <i class="none"></i>
149 AQL Allen's Relations Functions</a>
150 </li>
151
152 <li>
153
154 <a href="../aql/similarity.html" title="AQL Support of Similarity Queries">
155 <i class="none"></i>
156 AQL Support of Similarity Queries</a>
157 </li>
158
159 <li>
160
161 <a href="../aql/externaldata.html" title="Accessing External Data">
162 <i class="none"></i>
163 Accessing External Data</a>
164 </li>
165
166 <li>
167
168 <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
169 <i class="none"></i>
170 Filter-Based LSM Index Acceleration</a>
171 </li>
172
173 <li>
174
175 <a href="../api.html" title="REST API to AsterixDB">
176 <i class="none"></i>
177 REST API to AsterixDB</a>
178 </li>
179 </ul>
180
181
182
183 <hr class="divider" />
184
185 <div id="poweredBy">
186 <div class="clear"></div>
187 <div class="clear"></div>
188 <div class="clear"></div>
189 <a href=".././" title="Hyracks" class="builtBy">
190 <img class="builtBy" alt="Hyracks" src="../images/hyrax_ts.png" />
191 </a>
192 </div>
193 </div>
194 </div>
195
196
197 <div id="bodyColumn" class="span9" >
198
199 <h1>Asterix Data Model (ADM)</h1>
200<div class="section">
201<h2><a name="toc" id="toc">Table of Contents</a><a name="Table_of_Contents"></a></h2>
202
203<ul>
204
205<li><a href="#PrimitiveTypes">Primitive Types</a>
206
207<ul>
208
209<li><a href="#PrimitiveTypesBoolean">Boolean</a></li>
210
211<li><a href="#PrimitiveTypesInt">Int8 / Int16 / Int32 / Int64</a></li>
212
213<li><a href="#PrimitiveTypesFloat">Float</a></li>
214
215<li><a href="#PrimitiveTypesDouble">Double</a></li>
216
217<li><a href="#PrimitiveTypesString">String</a></li>
218
219<li><a href="#PrimitiveTypesPoint">Point</a></li>
220
221<li><a href="#PrimitiveTypesLine">Line</a></li>
222
223<li><a href="#PrimitiveTypesRectangle">Rectangle</a></li>
224
225<li><a href="#PrimitiveTypesCircle">Circle</a></li>
226
227<li><a href="#PrimitiveTypesPolygon">Polygon</a></li>
228
229<li><a href="#PrimitiveTypesDate">Date</a></li>
230
231<li><a href="#PrimitiveTypesTime">Time</a></li>
232
233<li><a href="#PrimitiveTypesDateTime">Datetime</a></li>
234
235<li><a href="#PrimitiveTypesDuration">Duration/Year-month-duration/Day-time-duration</a></li>
236
237<li><a href="#PrimitiveTypesInterval">Interval</a></li>
238 </ul></li>
239
240<li><a href="#DerivedTypes">Derived Types</a>
241
242<ul>
243
244<li><a href="#DerivedTypesRecord">Record</a></li>
245
246<li><a href="#DerivedTypesOrderedList">OrderedList</a></li>
247
248<li><a href="#DerivedTypesUnorderedList">UnorderedList</a></li>
249 </ul></li>
250</ul>
251<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>
252<div class="section">
253<h2><a name="PrimitiveTypes" id="PrimitiveTypes">Primitive Types</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Primitive_Types_Back_to_TOC"></a></h2>
254<div class="section">
255<h3><a name="PrimitiveTypesBoolean" id="PrimitiveTypesBoolean">Boolean</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="BooleanBack_to_TOC"></a></h3>
256<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>
257
258<ul>
259
260<li>
261<p>Example:</p>
262
263<div class="source">
264<pre>let $t := true
265let $f := false
266return { &quot;true&quot;: $t, &quot;false&quot;: $f }
267</pre></div></li>
268</ul>
269
270<ul>
271
272<li>
273<p>The expected result is:</p>
274
275<div class="source">
276<pre>{ &quot;true&quot;: true, &quot;false&quot;: false }
277</pre></div></li>
278</ul></div>
279<div class="section">
280<h3><a name="PrimitiveTypesInt" id="PrimitiveTypesInt">Int8 / Int16 / Int32 / Int64</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Int8__Int16__Int32__Int64_Back_to_TOC"></a></h3>
281<p>Integer types using 8, 16, 32, or 64 bits. The ranges of these types are:</p>
282
283<ul>
284
285<li><tt>int8</tt>: -127 to 127</li>
286
287<li><tt>int16</tt>: -32767 to 32767</li>
288
289<li><tt>int32</tt>: -2147483647 to 2147483647</li>
290
291<li><tt>int64</tt>: -9223372036854775808 to 9223372036854775807</li>
292
293<li>
294<p>Example:</p>
295
296<div class="source">
297<pre>let $v8 := int8(&quot;125&quot;)
298let $v16 := int16(&quot;32765&quot;)
299let $v32 := 294967295
300let $v64 := int64(&quot;1700000000000000000&quot;)
301return { &quot;int8&quot;: $v8, &quot;int16&quot;: $v16, &quot;int32&quot;: $v32, &quot;int64&quot;: $v64}
302</pre></div></li>
303</ul>
304
305<ul>
306
307<li>
308<p>The expected result is:</p>
309
310<div class="source">
311<pre>{ &quot;int8&quot;: 125i8, &quot;int16&quot;: 32765i16, &quot;int32&quot;: 294967295, &quot;int64&quot;: 1700000000000000000i64 }
312</pre></div></li>
313</ul></div>
314<div class="section">
315<h3><a name="PrimitiveTypesFloat" id="PrimitiveTypesFloat">Float</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Float_Back_to_TOC"></a></h3>
316<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>
317
318<ul>
319
320<li>
321<p>Example:</p>
322
323<div class="source">
324<pre>let $v1 := float(&quot;NaN&quot;)
325let $v2 := float(&quot;INF&quot;)
326let $v3 := float(&quot;-INF&quot;)
327let $v4 := float(&quot;-2013.5&quot;)
328return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
329</pre></div></li>
330</ul>
331
332<ul>
333
334<li>
335<p>The expected result is:</p>
336
337<div class="source">
338<pre>{ &quot;v1&quot;: NaNf, &quot;v2&quot;: Infinityf, &quot;v3&quot;: -Infinityf, &quot;v4&quot;: -2013.5f }
339</pre></div></li>
340</ul></div>
341<div class="section">
342<h3><a name="PrimitiveTypesDouble" id="PrimitiveTypesDouble">Double</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Double_Back_to_TOC"></a></h3>
343<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>
344
345<ul>
346
347<li>
348<p>Example:</p>
349
350<div class="source">
351<pre>let $v1 := double(&quot;NaN&quot;)
352let $v2 := double(&quot;INF&quot;)
353let $v3 := double(&quot;-INF&quot;)
354let $v4 := double(&quot;-2013.593823748327284&quot;)
355return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3, &quot;v4&quot;: $v4 }
356</pre></div></li>
357</ul>
358
359<ul>
360
361<li>
362<p>The expected result is:</p>
363
364<div class="source">
365<pre>{ &quot;v1&quot;: NaNd, &quot;v2&quot;: Infinityd, &quot;v3&quot;: -Infinityd, &quot;v4&quot;: -2013.5938237483274d }
366</pre></div></li>
367</ul></div>
368<div class="section">
369<h3><a name="PrimitiveTypesString" id="PrimitiveTypesString">String</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="String_Back_to_TOC"></a></h3>
370<p><tt>string</tt> represents a sequence of characters.</p>
371
372<ul>
373
374<li>
375<p>Example:</p>
376
377<div class="source">
378<pre>let $v1 := string(&quot;This is a string.&quot;)
379let $v2 := string(&quot;\&quot;This is a quoted string\&quot;&quot;)
380return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
381</pre></div></li>
382</ul>
383
384<ul>
385
386<li>
387<p>The expected result is:</p>
388
389<div class="source">
390<pre>{ &quot;v1&quot;: &quot;This is a string.&quot;, &quot;v2&quot;: &quot;\&quot;This is a quoted string\&quot;&quot; }
391</pre></div></li>
392</ul></div>
393<div class="section">
394<h3><a name="PrimitiveTypesPoint" id="PrimitiveTypesPoint">Point</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Point_Back_to_TOC"></a></h3>
395<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>
396
397<ul>
398
399<li>
400<p>Example:</p>
401
402<div class="source">
403<pre>let $v1 := point(&quot;80.10d, -10E5&quot;)
404let $v2 := point(&quot;5.10E-10d, -10E5&quot;)
405return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
406</pre></div></li>
407</ul>
408
409<ul>
410
411<li>
412<p>The expected result is:</p>
413
414<div class="source">
415<pre>{ &quot;v1&quot;: point(&quot;80.1,-1000000.0&quot;), &quot;v2&quot;: point(&quot;5.1E-10,-1000000.0&quot;) }
416</pre></div></li>
417</ul></div>
418<div class="section">
419<h3><a name="PrimitiveTypesLine" id="PrimitiveTypesLine">Line</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Line_Back_to_TOC"></a></h3>
420<p><tt>line</tt> consists of two points that represent the start and the end points of a line segment.</p>
421
422<ul>
423
424<li>
425<p>Example:</p>
426
427<div class="source">
428<pre>let $v1 := line(&quot;10.1234,11.1e-1 +10.2E-2,-11.22&quot;)
429let $v2 := line(&quot;0.1234,-1.00e-10 +10.5E-2,-01.02&quot;)
430return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
431</pre></div></li>
432</ul>
433
434<ul>
435
436<li>
437<p>The expected result is:</p>
438
439<div class="source">
440<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;) }
441</pre></div></li>
442</ul></div>
443<div class="section">
444<h3><a name="PrimitiveTypesRectangle" id="PrimitiveTypesRectangle">Rectangle</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="RectangleBack_to_TOC"></a></h3>
445<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>
446
447<ul>
448
449<li>
450<p>Example:</p>
451
452<div class="source">
453<pre>let $v1 := rectangle(&quot;5.1,11.8 87.6,15.6548&quot;)
454let $v2 := rectangle(&quot;0.1234,-1.00e-10 5.5487,0.48765&quot;)
455return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
456</pre></div></li>
457</ul>
458
459<ul>
460
461<li>
462<p>The expected result is:</p>
463
464<div class="source">
465<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;) }
466</pre></div></li>
467</ul></div>
468<div class="section">
469<h3><a name="PrimitiveTypesCircle" id="PrimitiveTypesCircle">Circle</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="CircleBack_to_TOC"></a></h3>
470<p><tt>circle</tt> consists of one point that represents the center of the circle and a radius of type <tt>double</tt>.</p>
471
472<ul>
473
474<li>
475<p>Example:</p>
476
477<div class="source">
478<pre>let $v1 := circle(&quot;10.1234,11.1e-1 +10.2E-2&quot;)
479let $v2 := circle(&quot;0.1234,-1.00e-10 +10.5E-2&quot;)
480return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
481</pre></div></li>
482</ul>
483
484<ul>
485
486<li>
487<p>The expected result is:</p>
488
489<div class="source">
490<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;) }
491</pre></div></li>
492</ul></div>
493<div class="section">
494<h3><a name="PrimitiveTypesPolygon" id="PrimitiveTypesPolygon">Polygon</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="PolygonBack_to_TOC"></a></h3>
495<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>
496
497<ul>
498
499<li>
500<p>Example:</p>
501
502<div class="source">
503<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;)
504let $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;)
505return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
506</pre></div></li>
507</ul>
508
509<ul>
510
511<li>
512<p>The expected result is:</p>
513
514<div class="source">
515<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;) }
516</pre></div></li>
517</ul></div>
518<div class="section">
519<h3><a name="PrimitiveTypesDate" id="PrimitiveTypesDate">Date</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="DateBack_to_TOC"></a></h3>
520<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>
521<p>A date value can be represented in two formats, extended format and basic format.</p>
522
523<ul>
524
525<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>
526
527<li>Basic format is in the format of <tt>[-]yyyymmdd</tt>.</li>
528
529<li>
530<p>Example:</p>
531
532<div class="source">
533<pre>let $v1 := date(&quot;2013-01-01&quot;)
534let $v2 := date(&quot;-19700101&quot;)
535return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
536</pre></div></li>
537</ul>
538
539<ul>
540
541<li>
542<p>The expected result is:</p>
543
544<div class="source">
545<pre>{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-1970-01-01&quot;) }
546</pre></div></li>
547</ul></div>
548<div class="section">
549<h3><a name="PrimitiveTypesTime" id="PrimitiveTypesTime">Time</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="TimeBack_to_TOC"></a></h3>
550<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>
551<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>
552
553<ul>
554
555<li>
556<p>Example:</p>
557
558<div class="source">
559<pre>let $v1 := time(&quot;12:12:12.039Z&quot;)
560let $v2 := time(&quot;000000000-0800&quot;)
561return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
562</pre></div></li>
563</ul>
564
565<ul>
566
567<li>
568<p>The expected result is:</p>
569
570<div class="source">
571<pre>{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;08:00:00.000Z&quot;) }
572</pre></div></li>
573</ul></div>
574<div class="section">
575<h3><a name="PrimitiveTypesDateTime" id="PrimitiveTypesDateTime">Datetime</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="DatetimeBack_to_TOC"></a></h3>
576<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>
577<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>
578<p>Millisecond field and timezone field are optional, as specified in the <tt>time</tt> type.</p>
579
580<ul>
581
582<li>
583<p>Example:</p>
584
585<div class="source">
586<pre>let $v1 := datetime(&quot;2013-01-01T12:12:12.039Z&quot;)
587let $v2 := datetime(&quot;-19700101T000000000-0800&quot;)
588return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
589</pre></div></li>
590</ul>
591
592<ul>
593
594<li>
595<p>The expected result is:</p>
596
597<div class="source">
598<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;) }
599</pre></div></li>
600</ul></div>
601<div class="section">
602<h3><a name="PrimitiveTypesDuration" id="PrimitiveTypesDuration">Duration/Year-month-duration/Day-time-duration</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="DurationYear-month-durationDay-time-durationBack_to_TOC"></a></h3>
603<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>
604<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>
605<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>
606<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>
607<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>
608
609<ul>
610
611<li>
612<p>Example:</p>
613
614<div class="source">
615<pre>let $v1 := duration(&quot;P100Y12MT12M&quot;)
616let $v2 := duration(&quot;-PT20.943S&quot;)
617return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2 }
618</pre></div></li>
619</ul>
620
621<ul>
622
623<li>
624<p>The expected result is:</p>
625
626<div class="source">
627<pre>{ &quot;v1&quot;: duration(&quot;P101YT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) }
628</pre></div></li>
629</ul></div>
630<div class="section">
631<h3><a name="PrimitiveTypesInterval" id="PrimitiveTypesInterval">Interval</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="IntervalBack_to_TOC"></a></h3>
632<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>
633
634<ul>
635
636<li>
637<p>Example:</p>
638
639<div class="source">
640<pre>let $v1 := interval-from-date(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))
641let $v2 := interval-from-time(time(&quot;00:01:01&quot;), time(&quot;213901049+0800&quot;))
642let $v3 := interval-from-datetime(datetime(&quot;2013-01-01T00:01:01&quot;), datetime(&quot;20130505T213901049+0800&quot;))
643return { &quot;v1&quot;: $v1, &quot;v2&quot;: $v2, &quot;v3&quot;: $v3 }
644</pre></div></li>
645</ul>
646
647<ul>
648
649<li>
650<p>The expected result is:</p>
651
652<div class="source">
653<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;) }
654</pre></div></li>
655</ul></div></div>
656<div class="section">
657<h2><a name="DerivedTypes" id="DerivedTypes">Derived Types</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Derived_TypesBack_to_TOC"></a></h2>
658<div class="section">
659<h3><a name="DerivedTypesRecord" id="DerivedTypesRecord">Record</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="RecordBack_to_TOC"></a></h3>
660<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>
661<p>An example would be</p>
662
663<div class="source">
664<pre> { &quot;id&quot;: 213508, &quot;name&quot;: &quot;Alice Bob&quot; }
665</pre></div></div>
666<div class="section">
667<h3><a name="DerivedTypesOrderedList" id="DerivedTypesOrderedList">OrderedList</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="OrderedListBack_to_TOC"></a></h3>
668<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>
669<p>An example would be</p>
670
671<div class="source">
672<pre> [&quot;alice&quot;, 123, &quot;bob&quot;, null]
673</pre></div></div>
674<div class="section">
675<h3><a name="DerivedTypesUnorderedList" id="DerivedTypesUnorderedList">UnorderedList</a><font size="4"><a href="#toc">[Back to TOC]</a></font><a name="UnorderedListBack_to_TOC"></a></h3>
676<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>
677<p>An example would be</p>
678
679<div class="source">
680<pre> {{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}}
681</pre></div></div></div>
682 </div>
683 </div>
684 </div>
685
686 <hr/>
687
688 <footer>
689 <div class="container-fluid">
690 <div class="row span12">Copyright &copy; 2015.
691 All Rights Reserved.
692
693 </div>
694
695 <?xml version="1.0" encoding="UTF-8"?>
696<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
697 feather logo, and the Apache AsterixDB project logo are either
698 registered trademarks or trademarks of The Apache Software
699 Foundation in the United States and other countries.
700 All other marks mentioned may be trademarks or registered
701 trademarks of their respective owners.</div>
702
703
704 </div>
705 </footer>
706 </body>
707</html>