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