blob: 3e00d9d92f7890885a7710c740d99eb983bc3508 [file] [log] [blame]
Ian Maxonbf2c56b2017-01-24 14:14:49 -08001<!DOCTYPE html>
2<!--
Ian Maxond5b11d82017-01-25 10:48:05 -08003 | Generated by Apache Maven Doxia at 2017-01-25
Ian Maxonbf2c56b2017-01-24 14:14:49 -08004 | 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" />
Ian Maxond5b11d82017-01-25 10:48:05 -080010 <meta name="Date-Revision-yyyymmdd" content="20170125" />
Ian Maxonbf2c56b2017-01-24 14:14:49 -080011 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; The 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 Maxonbf2c56b2017-01-24 14:14:49 -080022
Ian Maxonbf2c56b2017-01-24 14:14:49 -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="./" 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
Ian Maxond5b11d82017-01-25 10:48:05 -080045 <li id="publishDate">Last Published: 2017-01-25</li>
Ian Maxonbf2c56b2017-01-24 14:14:49 -080046
47
48
49 <li id="projectVersion" class="pull-right">Version: 0.9.0</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">Get Started - Installation</li>
68
69 <li>
70
71 <a href="ncservice.html" title="Option 1: using NCService">
72 <i class="none"></i>
73 Option 1: using NCService</a>
74 </li>
75
76 <li>
77
78 <a href="install.html" title="Option 2: using Managix">
79 <i class="none"></i>
80 Option 2: using Managix</a>
81 </li>
82
83 <li>
84
85 <a href="yarn.html" title="Option 3: using YARN">
86 <i class="none"></i>
87 Option 3: using YARN</a>
88 </li>
89 <li class="nav-header">AsterixDB Primer</li>
90
91 <li>
92
93 <a href="sqlpp/primer-sqlpp.html" title="Option 1: using SQL++">
94 <i class="none"></i>
95 Option 1: using SQL++</a>
96 </li>
97
98 <li>
99
100 <a href="aql/primer.html" title="Option 2: using AQL">
101 <i class="none"></i>
102 Option 2: using AQL</a>
103 </li>
104 <li class="nav-header">Data Model</li>
105
106 <li class="active">
107
108 <a href="#"><i class="none"></i>The Asterix Data Model</a>
109 </li>
110 <li class="nav-header">Queries - SQL++</li>
111
112 <li>
113
114 <a href="sqlpp/manual.html" title="The SQL++ Query Language">
115 <i class="none"></i>
116 The SQL++ Query Language</a>
117 </li>
118
119 <li>
120
121 <a href="sqlpp/builtins.html" title="Builtin Functions">
122 <i class="none"></i>
123 Builtin Functions</a>
124 </li>
125 <li class="nav-header">Queries - AQL</li>
126
127 <li>
128
129 <a href="aql/manual.html" title="The Asterix Query Language (AQL)">
130 <i class="none"></i>
131 The Asterix Query Language (AQL)</a>
132 </li>
133
134 <li>
135
136 <a href="aql/builtins.html" title="Builtin Functions">
137 <i class="none"></i>
138 Builtin Functions</a>
139 </li>
140 <li class="nav-header">Advanced Features</li>
141
142 <li>
143
144 <a href="aql/similarity.html" title="Support of Similarity Queries">
145 <i class="none"></i>
146 Support of Similarity Queries</a>
147 </li>
148
149 <li>
150
151 <a href="aql/fulltext.html" title="Support of Full-text Queries">
152 <i class="none"></i>
153 Support of Full-text Queries</a>
154 </li>
155
156 <li>
157
158 <a href="aql/externaldata.html" title="Accessing External Data">
159 <i class="none"></i>
160 Accessing External Data</a>
161 </li>
162
163 <li>
164
165 <a href="feeds/tutorial.html" title="Support for Data Ingestion">
166 <i class="none"></i>
167 Support for Data Ingestion</a>
168 </li>
169
170 <li>
171
172 <a href="udf.html" title="User Defined Functions">
173 <i class="none"></i>
174 User Defined Functions</a>
175 </li>
176
177 <li>
178
179 <a href="aql/filters.html" title="Filter-Based LSM Index Acceleration">
180 <i class="none"></i>
181 Filter-Based LSM Index Acceleration</a>
182 </li>
183 <li class="nav-header">API/SDK</li>
184
185 <li>
186
187 <a href="api.html" title="HTTP API">
188 <i class="none"></i>
189 HTTP API</a>
190 </li>
191 </ul>
192
193
194
195 <hr class="divider" />
196
197 <div id="poweredBy">
198 <div class="clear"></div>
199 <div class="clear"></div>
200 <div class="clear"></div>
201 <a href="./" title="AsterixDB" class="builtBy">
202 <img class="builtBy" alt="AsterixDB" src="images/asterixlogo.png" />
203 </a>
204 </div>
205 </div>
206 </div>
207
208
209 <div id="bodyColumn" class="span9" >
210
211 <!-- ! Licensed to the Apache Software Foundation (ASF) under one
212 ! or more contributor license agreements. See the NOTICE file
213 ! distributed with this work for additional information
214 ! regarding copyright ownership. The ASF licenses this file
215 ! to you under the Apache License, Version 2.0 (the
216 ! "License"); you may not use this file except in compliance
217 ! with the License. You may obtain a copy of the License at
218 !
219 ! http://www.apache.org/licenses/LICENSE-2.0
220 !
221 ! Unless required by applicable law or agreed to in writing,
222 ! software distributed under the License is distributed on an
223 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
224 ! KIND, either express or implied. See the License for the
225 ! specific language governing permissions and limitations
226 ! under the License.
227 ! --><h1>The Asterix Data Model (ADM)</h1>
228<div class="section">
229<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
230
231<ul>
232
233<li><a href="#PrimitiveTypes">Primitive Types</a>
234
235<ul>
236
237<li><a href="#PrimitiveTypesBoolean">Boolean</a></li>
238
239<li><a href="#PrimitiveTypesInt">Tinyint / Smallint / Integer (Int) / Bigint</a></li>
240
241<li><a href="#PrimitiveTypesFloat">Float</a></li>
242
243<li><a href="#PrimitiveTypesDouble">Double (Double Precision)</a></li>
244
245<li><a href="#PrimitiveTypesString">String</a></li>
246
247<li><a href="#PrimitiveTypesBinary">Binary</a></li>
248
249<li><a href="#PrimitiveTypesPoint">Point</a></li>
250
251<li><a href="#PrimitiveTypesLine">Line</a></li>
252
253<li><a href="#PrimitiveTypesRectangle">Rectangle</a></li>
254
255<li><a href="#PrimitiveTypesCircle">Circle</a></li>
256
257<li><a href="#PrimitiveTypesPolygon">Polygon</a></li>
258
259<li><a href="#PrimitiveTypesDate">Date</a></li>
260
261<li><a href="#PrimitiveTypesTime">Time</a></li>
262
263<li><a href="#PrimitiveTypesDateTime">Datetime (Timestamp)</a></li>
264
265<li><a href="#PrimitiveTypesDuration">Duration/Year_month_duration/Day_time_duration</a></li>
266
267<li><a href="#PrimitiveTypesInterval">Interval</a></li>
268
269<li><a href="#PrimitiveTypesUUID">UUID</a></li>
270 </ul></li>
271
272<li><a href="#IncompleteInformationTypesTypes">Incomplete Information Types</a>
273
274<ul>
275
276<li><a href="#IncompleteInformationTypesNull">Null</a></li>
277
278<li><a href="#IncompleteInformationTypesMissing">Missing</a></li>
279 </ul></li>
280
281<li><a href="#DerivedTypes">Derived Types</a>
282
283<ul>
284
285<li><a href="#DerivedTypesObject">Object</a></li>
286
287<li><a href="#DerivedTypesArray">Array</a></li>
288
289<li><a href="#DerivedTypesMultiset">Multiset</a></li>
290 </ul></li>
291</ul>
292<p>An instance of Asterix data model (ADM) can be a <i><i>primitive type</i></i> (<tt>boolean</tt>, <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, <tt>bigint</tt>, <tt>string</tt>, <tt>float</tt>, <tt>double</tt>, <tt>date</tt>, <tt>time</tt>, <tt>datetime</tt>, etc.), a <i><i>special type</i></i> (<tt>null</tt> or <tt>missing</tt>), or a <i><i>derived type</i></i>.</p>
293<p>The type names are case-insensitive, e.g., both <tt>BIGINT</tt> and <tt>bigint</tt> are acceptable.</p></div>
294<div class="section">
295<h2><a name="Primitive_Types"></a><a name="PrimitiveTypes" id="PrimitiveTypes">Primitive Types</a></h2>
296<div class="section">
297<h3><a name="Boolean"></a><a name="PrimitiveTypesBoolean" id="PrimitiveTypesBoolean">Boolean</a></h3>
298<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>
299
300<ul>
301
302<li>
303<p>Example:</p>
304
305<div class="source">
306<div class="source">
307<pre>{ &quot;true&quot;: true, &quot;false&quot;: false };
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;true&quot;: true, &quot;false&quot;: false }
319</pre></div></div></li>
320</ul></div>
321<div class="section">
322<h3><a name="Tinyint__Smallint__Integer_Int__Bigint"></a><a name="PrimitiveTypesInt" id="PrimitiveTypesInt">Tinyint / Smallint / Integer (Int) / Bigint</a></h3>
323<p>Integer types using 8, 16, 32, or 64 bits. The ranges of these types are:</p>
324
325<ul>
326
327<li><tt>tinyint</tt>: -127 to 127</li>
328
329<li><tt>smallint</tt>: -32767 to 32767</li>
330
331<li><tt>integer</tt>: -2147483647 to 2147483647</li>
332
333<li><tt>bigint</tt>: -9223372036854775808 to 9223372036854775807</li>
334</ul>
335<p><tt>int</tt> is an abbreviated alias for integer.</p>
336
337<ul>
338
339<li>
340<p>Example:</p>
341
342<div class="source">
343<div class="source">
344<pre>{ &quot;tinyint&quot;: tiny(&quot;125&quot;), &quot;smallint&quot;: smallint(&quot;32765&quot;), &quot;integer&quot;: 294967295, &quot;bigint&quot;: bigint(&quot;1700000000000000000&quot;)};
345</pre></div></div></li>
346</ul>
347
348<ul>
349
350<li>
351<p>The expected result is:</p>
352
353<div class="source">
354<div class="source">
355<pre>{ &quot;tinyint&quot;: 125, &quot;smallint&quot;: 32765, &quot;integer&quot;: 294967295, &quot;bigint&quot;: 17000000 }
356</pre></div></div></li>
357</ul></div>
358<div class="section">
359<h3><a name="Float"></a><a name="PrimitiveTypesFloat" id="PrimitiveTypesFloat">Float</a></h3>
360<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>
361
362<ul>
363
364<li>
365<p>Example:</p>
366
367<div class="source">
368<div class="source">
369<pre>{ &quot;v1&quot;: float(&quot;NaN&quot;), &quot;v2&quot;: float(&quot;INF&quot;), &quot;v3&quot;: float(&quot;-INF&quot;), &quot;v4&quot;: float(&quot;-2013.5&quot;) };
370</pre></div></div></li>
371</ul>
372
373<ul>
374
375<li>
376<p>The expected result is:</p>
377
378<div class="source">
379<div class="source">
380<pre>{ &quot;v1&quot;: NaN, &quot;v2&quot;: Infinity, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -2013.5 }
381</pre></div></div></li>
382</ul></div>
383<div class="section">
384<h3><a name="Double_double_precision"></a><a name="PrimitiveTypesDouble" id="PrimitiveTypesDouble">Double (double precision)</a></h3>
385<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>
386
387<ul>
388
389<li>
390<p>Example:</p>
391
392<div class="source">
393<div class="source">
394<pre>{ &quot;v1&quot;: double(&quot;NaN&quot;), &quot;v2&quot;: double(&quot;INF&quot;), &quot;v3&quot;: double(&quot;-INF&quot;), &quot;v4&quot;: &quot;-2013.593823748327284&quot; };
395</pre></div></div></li>
396</ul>
397
398<ul>
399
400<li>
401<p>The expected result is:</p>
402
403<div class="source">
404<div class="source">
405<pre>{ &quot;v1&quot;: NaN, &quot;v2&quot;: Infinity, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -2013.5938237483274 }
406</pre></div></div></li>
407</ul>
408<p><tt>Double precision</tt> is an alias of <tt>double</tt>.</p></div>
409<div class="section">
410<h3><a name="String"></a><a name="PrimitiveTypesString" id="PrimitiveTypesString">String</a></h3>
411<p><tt>string</tt> represents a sequence of characters. The total length of the sequence can be up to 2,147,483,648.</p>
412
413<ul>
414
415<li>
416<p>Example:</p>
417
418<div class="source">
419<div class="source">
420<pre>{ &quot;v1&quot;: string(&quot;This is a string.&quot;), &quot;v2&quot;: string(&quot;\&quot;This is a quoted string\&quot;&quot;) };
421</pre></div></div></li>
422</ul>
423
424<ul>
425
426<li>
427<p>The expected result is:</p>
428
429<div class="source">
430<div class="source">
431<pre>{ &quot;v1&quot;: &quot;This is a string.&quot;, &quot;v2&quot;: &quot;\&quot;This is a quoted string\&quot;&quot; }
432</pre></div></div></li>
433</ul></div>
434<div class="section">
435<h3><a name="Binary"></a><a name="PrimitiveTypesBinary" id="PrimitiveTypesBinary">Binary</a></h3>
436<p><tt>binary</tt> represents a sequence of bytes. It can be constructed from a <tt>hex</tt> or a <tt>base64</tt> string sequence. The total length of the byte sequence can be up to 2,147,483,648.</p>
437
438<ul>
439
440<li>
441<p>Example:</p>
442
443<div class="source">
444<div class="source">
445<pre>{
446 &quot;hex1&quot; : hex(&quot;ABCDEF0123456789&quot;),
447 &quot;hex2&quot;: hex(&quot;abcdef0123456789&quot;),
448 &quot;base64_1&quot; : base64(&quot;0123456789qwertyui+/&quot;),
449 &quot;base64_2&quot; : base64('QXN0ZXJpeA==')
450};
451</pre></div></div></li>
452
453<li>
454<p>The default output format is in <tt>hex</tt> format. Thus, the expected result is:</p>
455
456<div class="source">
457<div class="source">
458<pre>{
459 &quot;hex1&quot;: hex(&quot;ABCDEF0123456789&quot;),
460 &quot;hex2&quot;: hex(&quot;ABCDEF0123456789&quot;),
461 &quot;base64_1&quot;: hex(&quot;D35DB7E39EBBF3DAB07ABB72BA2FBF&quot;),
462 &quot;base64_2&quot;: hex(&quot;41737465726978&quot;)
463}
464</pre></div></div></li>
465</ul></div>
466<div class="section">
467<h3><a name="Point"></a><a name="PrimitiveTypesPoint" id="PrimitiveTypesPoint">Point</a></h3>
468<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>
469
470<ul>
471
472<li>
473<p>Example:</p>
474
475<div class="source">
476<div class="source">
477<pre>{ &quot;v1&quot;: point(&quot;80.10d, -10E5&quot;), &quot;v2&quot;: point(&quot;5.10E-10d, -10E5&quot;) };
478</pre></div></div></li>
479</ul>
480
481<ul>
482
483<li>
484<p>The expected result is:</p>
485
486<div class="source">
487<div class="source">
488<pre>{ &quot;v1&quot;: point(&quot;80.1,-1000000.0&quot;), &quot;v2&quot;: point(&quot;5.1E-10,-1000000.0&quot;) }
489</pre></div></div></li>
490</ul></div>
491<div class="section">
492<h3><a name="Line"></a><a name="PrimitiveTypesLine" id="PrimitiveTypesLine">Line</a></h3>
493<p><tt>line</tt> consists of two points that represent the start and the end points of a line segment.</p>
494
495<ul>
496
497<li>
498<p>Example:</p>
499
500<div class="source">
501<div class="source">
502<pre>{ &quot;v1&quot;: line(&quot;10.1234,11.1e-1 +10.2E-2,-11.22&quot;), &quot;v2&quot;: line(&quot;0.1234,-1.00e-10 +10.5E-2,-01.02&quot;) };
503</pre></div></div></li>
504</ul>
505
506<ul>
507
508<li>
509<p>The expected result is:</p>
510
511<div class="source">
512<div class="source">
513<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;) }
514</pre></div></div></li>
515</ul></div>
516<div class="section">
517<h3><a name="Rectangle"></a><a name="PrimitiveTypesRectangle" id="PrimitiveTypesRectangle">Rectangle</a></h3>
518<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>
519
520<ul>
521
522<li>
523<p>Example:</p>
524
525<div class="source">
526<div class="source">
527<pre>{ &quot;v1&quot;: rectangle(&quot;5.1,11.8 87.6,15.6548&quot;), &quot;v2&quot;: rectangle(&quot;0.1234,-1.00e-10 5.5487,0.48765&quot;) };
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;: 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;) }
539</pre></div></div></li>
540</ul></div>
541<div class="section">
542<h3><a name="Circle"></a><a name="PrimitiveTypesCircle" id="PrimitiveTypesCircle">Circle</a></h3>
543<p><tt>circle</tt> consists of one point that represents the center of the circle and a radius of type <tt>double</tt>.</p>
544
545<ul>
546
547<li>
548<p>Example:</p>
549
550<div class="source">
551<div class="source">
552<pre>{ &quot;v1&quot;: circle(&quot;10.1234,11.1e-1 +10.2E-2&quot;), &quot;v2&quot;: circle(&quot;0.1234,-1.00e-10 +10.5E-2&quot;) };
553</pre></div></div></li>
554</ul>
555
556<ul>
557
558<li>
559<p>The expected result is:</p>
560
561<div class="source">
562<div class="source">
563<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;) }
564</pre></div></div></li>
565</ul></div>
566<div class="section">
567<h3><a name="Polygon"></a><a name="PrimitiveTypesPolygon" id="PrimitiveTypesPolygon">Polygon</a></h3>
568<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>
569
570<ul>
571
572<li>
573<p>Example:</p>
574
575<div class="source">
576<div class="source">
577<pre>{
578 &quot;v1&quot;: polygon(&quot;-1.2,+1.3e2 -2.14E+5,2.15 -3.5e+2,03.6 -4.6E-3,+4.81&quot;),
579 &quot;v2&quot;: 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;)
580};
581</pre></div></div></li>
582</ul>
583
584<ul>
585
586<li>
587<p>The expected result is:</p>
588
589<div class="source">
590<div class="source">
591<pre>{
592 &quot;v1&quot;: polygon(&quot;-1.2,130.0 -214000.0,2.15 -350.0,3.6 -0.0046,4.81&quot;),
593 &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;) }
594}
595</pre></div></div></li>
596</ul></div>
597<div class="section">
598<h3><a name="Date"></a><a name="PrimitiveTypesDate" id="PrimitiveTypesDate">Date</a></h3>
599<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>
600<p>A date value can be represented in two formats, extended format and basic format.</p>
601
602<ul>
603
604<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>
605
606<li>Basic format is in the format of <tt>[-]yyyymmdd</tt>.</li>
607
608<li>
609<p>Example:</p>
610
611<div class="source">
612<div class="source">
613<pre>{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-19700101&quot;) };
614</pre></div></div></li>
615</ul>
616
617<ul>
618
619<li>
620<p>The expected result is:</p>
621
622<div class="source">
623<div class="source">
624<pre>{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-1970-01-01&quot;) }
625</pre></div></div></li>
626</ul></div>
627<div class="section">
628<h3><a name="Time"></a><a name="PrimitiveTypesTime" id="PrimitiveTypesTime">Time</a></h3>
629<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>
630<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>
631
632<ul>
633
634<li>
635<p>Example:</p>
636
637<div class="source">
638<div class="source">
639<pre>{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;000000000-0800&quot;) };
640</pre></div></div></li>
641</ul>
642
643<ul>
644
645<li>
646<p>The expected result is:</p>
647
648<div class="source">
649<div class="source">
650<pre>{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;08:00:00.000Z&quot;) }
651</pre></div></div></li>
652</ul></div>
653<div class="section">
654<h3><a name="Datetime_Timestamp"></a><a name="PrimitiveTypesDateTime" id="PrimitiveTypesDateTime">Datetime (Timestamp)</a></h3>
655<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>
656<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>
657<p>Millisecond field and timezone field are optional, as specified in the <tt>time</tt> type.</p>
658
659<ul>
660
661<li>
662<p>Example:</p>
663
664<div class="source">
665<div class="source">
666<pre>{ &quot;v1&quot;: datetime(&quot;2013-01-01T12:12:12.039Z&quot;), &quot;v2&quot;: datetime(&quot;-19700101T000000000-0800&quot;) };
667</pre></div></div></li>
668</ul>
669
670<ul>
671
672<li>
673<p>The expected result is:</p>
674
675<div class="source">
676<div class="source">
677<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;) }
678</pre></div></div></li>
679</ul>
680<p><tt>timestamp</tt> is an alias of <tt>datetime</tt>.</p></div>
681<div class="section">
682<h3><a name="DurationYear_month_durationDay_time_duration"></a><a name="PrimitiveTypesDuration" id="PrimitiveTypesDuration">Duration/Year_month_duration/Day_time_duration</a></h3>
683<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>
684<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>
685<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>
686<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>
687<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>
688
689<ul>
690
691<li>
692<p>Example:</p>
693
694<div class="source">
695<div class="source">
696<pre>{ &quot;v1&quot;: duration(&quot;P100Y12MT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) };
697</pre></div></div></li>
698</ul>
699
700<ul>
701
702<li>
703<p>The expected result is:</p>
704
705<div class="source">
706<div class="source">
707<pre>{ &quot;v1&quot;: duration(&quot;P101YT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) }
708</pre></div></div></li>
709</ul></div>
710<div class="section">
711<h3><a name="Interval"></a><a name="PrimitiveTypesInterval" id="PrimitiveTypesInterval">Interval</a></h3>
712<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>
713
714<ul>
715
716<li>
717<p>Example:</p>
718
719<div class="source">
720<div class="source">
721<pre>{
722 &quot;v1&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;)),
723 &quot;v2&quot;: interval(time(&quot;00:01:01&quot;), time(&quot;213901049+0800&quot;)),
724 &quot;v3&quot;: interval(datetime(&quot;2013-01-01T00:01:01&quot;), datetime(&quot;20130505T213901049+0800&quot;))
725};
726</pre></div></div></li>
727</ul>
728
729<ul>
730
731<li>
732<p>The expected result is:</p>
733
734<div class="source">
735<div class="source">
736<pre>{
737 &quot;v1&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2013-05-05&quot;)),
738 &quot;v2&quot;: interval(time(&quot;00:01:01.000Z&quot;), time(&quot;13:39:01.049Z&quot;)),
739 &quot;v3&quot;: interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))
740}
741</pre></div></div></li>
742</ul></div>
743<div class="section">
744<h3><a name="UUID"></a><a name="PrimitiveTypesUUID" id="PrimitiveTypesUUID">UUID</a></h3>
745<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>
746
747<ul>
748
749<li>
750<p>Example:</p>
751
752<div class="source">
753<div class="source">
754<pre>return { &quot;v1&quot;:uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
755</pre></div></div></li>
756</ul>
757
758<ul>
759
760<li>
761<p>The expected result is:</p>
762
763<div class="source">
764<div class="source">
765<pre>{ &quot;v1&quot;: uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
766</pre></div></div></li>
767</ul></div></div>
768<div class="section">
769<h2><a name="Incomplete_Information_Types"></a><a name="IncompleteInformationTypes" id="IncompleteInformationTypes">Incomplete Information Types</a></h2>
770<div class="section">
771<h3><a name="Null"></a><a name="IncompleteInformationTypesNull" id="IncompleteInformationTypesNull">Null</a></h3>
772<p><tt>null</tt> is a special value that is often used to represent an unknown value. For example, a user might not be able to know the value of a field and let it be <tt>null</tt>.</p>
773
774<ul>
775
776<li>
777<p>Example:</p>
778
779<div class="source">
780<div class="source">
781<pre>{ &quot;field&quot;: null };
782</pre></div></div></li>
783</ul>
784
785<ul>
786
787<li>
788<p>The expected result is:</p>
789
790<div class="source">
791<div class="source">
792<pre>{ &quot;field&quot;: null }
793</pre></div></div></li>
794</ul></div>
795<div class="section">
796<h3><a name="Missing"></a><a name="IncompleteInformationTypesMissing" id="IncompleteInformationTypesMissing">Missing</a></h3>
797<p><tt>missing</tt> represents a missing name-value pair in a object. If the referenced field does not exist, an empty result value is returned by the query.</p>
798<p>As neither the data model nor the system enforces homogeneity for datasets or collections, items in a dataset or collection can be of heterogeneous types and so a field can be present in one object and <tt>missing</tt> in another.</p>
799
800<ul>
801
802<li>
803<p>Example:</p>
804
805<div class="source">
806<div class="source">
807<pre>{ &quot;field&quot;: missing };
808</pre></div></div></li>
809</ul>
810
811<ul>
812
813<li>
814<p>The expected result is:</p>
815
816<div class="source">
817<div class="source">
818<pre>{ }
819</pre></div></div></li>
820</ul>
821<p>Since a field with value <tt>missing</tt> means the field is absent, we get an empty object.</p></div></div>
822<div class="section">
823<h2><a name="Derived_Types"></a><a name="DerivedTypes" id="DerivedTypes">Derived Types</a></h2>
824<div class="section">
825<h3><a name="Object"></a><a name="DerivedTypesObject" id="DerivedTypesObject">Object</a></h3>
826<p>A <tt>object</tt> contains a set of &#xfb01;elds, where each &#xfb01;eld is described by its name and type. A object type is either open or closed. Open objects can contain &#xfb01;elds that are not part of the type de&#xfb01;nition, while closed objects cannot. Syntactically, object constructors are surrounded by curly braces &#x201c;{&#x2026;}&#x201d;.</p>
827<p>An example would be</p>
828
829<div class="source">
830<div class="source">
831<pre> { &quot;id&quot;: 213508, &quot;name&quot;: &quot;Alice Bob&quot; }
832</pre></div></div></div>
833<div class="section">
834<h3><a name="Array"></a><a name="DerivedTypesArray" id="DerivedTypesArray">Array</a></h3>
835<p>An <tt>array</tt> is a container that holds a fixed number of values. Array constructors are denoted by brackets: &#x201c;[&#x2026;]&#x201d;.</p>
836<p>An example would be</p>
837
838<div class="source">
839<div class="source">
840<pre> [&quot;alice&quot;, 123, &quot;bob&quot;, null]
841</pre></div></div></div>
842<div class="section">
843<h3><a name="Multiset"></a><a name="DerivedTypesMultiset" id="DerivedTypesMultiset">Multiset</a></h3>
844<p>A <tt>multiset</tt> is a generalization of the concept of a set that, unlike a set, allows multiple instances of the multiset&#x2019;s elements. Multiset constructors are denoted by two opening curly braces followed by data and two closing curly braces, like &#x201c;{{&#x2026;}}&#x201d;.</p>
845<p>An example would be</p>
846
847<div class="source">
848<div class="source">
849<pre> {{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}}
850</pre></div></div></div></div>
851 </div>
852 </div>
853 </div>
854
855 <hr/>
856
857 <footer>
858 <div class="container-fluid">
859 <div class="row span12">Copyright &copy; 2017
860 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
861 All Rights Reserved.
862
863 </div>
864
865 <?xml version="1.0" encoding="UTF-8"?>
866<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
867 feather logo, and the Apache AsterixDB project logo are either
868 registered trademarks or trademarks of The Apache Software
869 Foundation in the United States and other countries.
870 All other marks mentioned may be trademarks or registered
871 trademarks of their respective owners.</div>
872
873
874 </div>
875 </footer>
876 </body>
877</html>