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