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