blob: d0eed6bd9ba20fa2f0a6e2c091c58da9330a05fb [file] [log] [blame]
Ian Maxon858061a2022-05-12 19:11:28 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/datamodel.md at 2022-05-12
4 | Rendered using Apache Maven Fluido Skin 1.7
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="20220512" />
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.7.min.css" />
14 <link rel="stylesheet" href="./css/site.css" />
15 <link rel="stylesheet" href="./css/print.css" media="print" />
16 <script type="text/javascript" src="./js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href="./" id="bannerLeft"><img src="images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2022-05-12</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.8</li>
31 <li class="pull-right"><a href="index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li class="active"><a href="#"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li><a href="sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="geo/quickstart.html" title="GIS Support Overview"><span class="none"></span>GIS Support Overview</a></li>
61 <li><a href="geo/functions.html" title="GIS Functions"><span class="none"></span>GIS Functions</a></li>
62 <li><a href="interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
63 <li><a href="spatial_join.html" title="Support of Spatial Joins"><span class="none"></span>Support of Spatial Joins</a></li>
64 <li><a href="sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
65 <li class="nav-header">Deprecated</li>
66 <li><a href="aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
67 <li><a href="aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
68 <li><a href="aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
69</ul>
70 <hr />
71 <div id="poweredBy">
72 <div class="clear"></div>
73 <div class="clear"></div>
74 <div class="clear"></div>
75 <div class="clear"></div>
76<a href="./" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="images/asterixlogo.png" /></a>
77 </div>
78 </div>
79 </div>
80 <div id="bodyColumn" class="span10" >
81<!--
82 ! Licensed to the Apache Software Foundation (ASF) under one
83 ! or more contributor license agreements. See the NOTICE file
84 ! distributed with this work for additional information
85 ! regarding copyright ownership. The ASF licenses this file
86 ! to you under the Apache License, Version 2.0 (the
87 ! "License"); you may not use this file except in compliance
88 ! with the License. You may obtain a copy of the License at
89 !
90 ! http://www.apache.org/licenses/LICENSE-2.0
91 !
92 ! Unless required by applicable law or agreed to in writing,
93 ! software distributed under the License is distributed on an
94 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
95 ! KIND, either express or implied. See the License for the
96 ! specific language governing permissions and limitations
97 ! under the License.
98 !-->
99<h1>The Asterix Data Model (ADM)</h1>
100<div class="section">
101<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
102<ul>
103
104<li><a href="#PrimitiveTypes">Primitive Types</a>
105<ul>
106
107<li><a href="#PrimitiveTypesBoolean">Boolean</a></li>
108<li><a href="#PrimitiveTypesString">String</a></li>
109<li><a href="#PrimitiveTypesInt">Tinyint / Smallint / Integer (Int) / Bigint</a></li>
110<li><a href="#PrimitiveTypesFloat">Float</a></li>
111<li><a href="#PrimitiveTypesDouble">Double (Double Precision)</a></li>
112<li><a href="#PrimitiveTypesBinary">Binary</a></li>
113<li><a href="#PrimitiveTypesPoint">Point</a></li>
114<li><a href="#PrimitiveTypesLine">Line</a></li>
115<li><a href="#PrimitiveTypesRectangle">Rectangle</a></li>
116<li><a href="#PrimitiveTypesCircle">Circle</a></li>
117<li><a href="#PrimitiveTypesPolygon">Polygon</a></li>
118<li><a href="#PrimitiveTypesDate">Date</a></li>
119<li><a href="#PrimitiveTypesTime">Time</a></li>
120<li><a href="#PrimitiveTypesDateTime">Datetime (Timestamp)</a></li>
121<li><a href="#PrimitiveTypesDuration">Duration/Year_month_duration/Day_time_duration</a></li>
122<li><a href="#PrimitiveTypesInterval">Interval</a></li>
123<li><a href="#PrimitiveTypesUUID">UUID</a></li>
124</ul>
125</li>
126<li><a href="#IncompleteInformationTypes">Incomplete Information Types</a>
127<ul>
128
129<li><a href="#IncompleteInformationTypesNull">Null</a></li>
130<li><a href="#IncompleteInformationTypesMissing">Missing</a></li>
131</ul>
132</li>
133<li><a href="#DerivedTypes">Derived Types</a>
134<ul>
135
136<li><a href="#DerivedTypesObject">Object</a></li>
137<li><a href="#DerivedTypesArray">Array</a></li>
138<li><a href="#DerivedTypesMultiset">Multiset</a></li>
139</ul>
140</li>
141</ul>
142<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>
143<p>The type names are case-insensitive, e.g., both <tt>BIGINT</tt> and <tt>bigint</tt> are acceptable.</p><!--
144 ! Licensed to the Apache Software Foundation (ASF) under one
145 ! or more contributor license agreements. See the NOTICE file
146 ! distributed with this work for additional information
147 ! regarding copyright ownership. The ASF licenses this file
148 ! to you under the Apache License, Version 2.0 (the
149 ! "License"); you may not use this file except in compliance
150 ! with the License. You may obtain a copy of the License at
151 !
152 ! http://www.apache.org/licenses/LICENSE-2.0
153 !
154 ! Unless required by applicable law or agreed to in writing,
155 ! software distributed under the License is distributed on an
156 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
157 ! KIND, either express or implied. See the License for the
158 ! specific language governing permissions and limitations
159 ! under the License.
160 !-->
161</div>
162<div class="section">
163<h2><a name="Primitive_Types"></a><a name="PrimitiveTypes" id="PrimitiveTypes">Primitive Types</a></h2>
164<div class="section">
165<h3><a name="Boolean"></a><a name="PrimitiveTypesBoolean" id="PrimitiveTypesBoolean">Boolean</a></h3>
166<p><tt>boolean</tt> data type can have one of the two values: <i>true</i> or <i>false</i>.</p>
167<ul>
168
169<li>
170
171<p>Example:</p>
172
173<div>
174<div>
175<pre class="source">{ &quot;true&quot;: true, &quot;false&quot;: false };
176</pre></div></div>
177</li>
178<li>
179
180<p>The expected result is:</p>
181
182<div>
183<div>
184<pre class="source">{ &quot;true&quot;: true, &quot;false&quot;: false }
185</pre></div></div>
186</li>
187</ul></div>
188<div class="section">
189<h3><a name="String"></a><a name="PrimitiveTypesString" id="PrimitiveTypesString">String</a></h3>
190<p><tt>string</tt> represents a sequence of characters. The total length of the sequence can be up to 2,147,483,648.</p>
191<ul>
192
193<li>
194
195<p>Example:</p>
196
197<div>
198<div>
199<pre class="source">{ &quot;v1&quot;: string(&quot;This is a string.&quot;), &quot;v2&quot;: string(&quot;\&quot;This is a quoted string\&quot;&quot;) };
200</pre></div></div>
201</li>
202<li>
203
204<p>The expected result is:</p>
205
206<div>
207<div>
208<pre class="source">{ &quot;v1&quot;: &quot;This is a string.&quot;, &quot;v2&quot;: &quot;\&quot;This is a quoted string\&quot;&quot; }
209</pre></div></div>
210</li>
211</ul><!--
212 ! Licensed to the Apache Software Foundation (ASF) under one
213 ! or more contributor license agreements. See the NOTICE file
214 ! distributed with this work for additional information
215 ! regarding copyright ownership. The ASF licenses this file
216 ! to you under the Apache License, Version 2.0 (the
217 ! "License"); you may not use this file except in compliance
218 ! with the License. You may obtain a copy of the License at
219 !
220 ! http://www.apache.org/licenses/LICENSE-2.0
221 !
222 ! Unless required by applicable law or agreed to in writing,
223 ! software distributed under the License is distributed on an
224 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
225 ! KIND, either express or implied. See the License for the
226 ! specific language governing permissions and limitations
227 ! under the License.
228 !-->
229</div>
230<div class="section">
231<h3><a name="Tinyint_.2F_Smallint_.2F_Integer_.28Int.29_.2F_Bigint"></a><a name="PrimitiveTypesInt" id="PrimitiveTypesInt">Tinyint / Smallint / Integer (Int) / Bigint</a></h3>
232<p>Integer types using 8, 16, 32, or 64 bits. The ranges of these types are:</p>
233<ul>
234
235<li><tt>tinyint</tt>: -128 to 127</li>
236<li><tt>smallint</tt>: -32768 to 32767</li>
237<li><tt>integer</tt>: -2147483648 to 2147483647</li>
238<li><tt>bigint</tt>: -9223372036854775808 to 9223372036854775807</li>
239</ul>
240<p><tt>int</tt> is an abbreviated alias for integer.</p>
241<ul>
242
243<li>
244
245<p>Example:</p>
246
247<div>
248<div>
249<pre class="source">{ &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;)};
250</pre></div></div>
251</li>
252<li>
253
254<p>The expected result is:</p>
255
256<div>
257<div>
258<pre class="source">{ &quot;tinyint&quot;: 125, &quot;smallint&quot;: 32765, &quot;integer&quot;: 294967295, &quot;bigint&quot;: 1700000000000000000 }
259</pre></div></div>
260</li>
261</ul></div>
262<div class="section">
263<h3><a name="Float"></a><a name="PrimitiveTypesFloat" id="PrimitiveTypesFloat">Float</a></h3>
264<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>
265<ul>
266
267<li>
268
269<p>Example:</p>
270
271<div>
272<div>
273<pre class="source">{ &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;) };
274</pre></div></div>
275</li>
276<li>
277
278<p>The expected result is:</p>
279
280<div>
281<div>
282<pre class="source">{ &quot;v1&quot;: &quot;NaN&quot;, &quot;v2&quot;: &quot;INF&quot;, &quot;v3&quot;: &quot;-INF&quot;, &quot;v4&quot;: -2013.5 }
283</pre></div></div>
284</li>
285</ul></div>
286<div class="section">
287<h3><a name="Double_.28double_precision.29"></a><a name="PrimitiveTypesDouble" id="PrimitiveTypesDouble">Double (double precision)</a></h3>
288<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>
289<ul>
290
291<li>
292
293<p>Example:</p>
294
295<div>
296<div>
297<pre class="source">{ &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; };
298</pre></div></div>
299</li>
300<li>
301
302<p>The expected result is:</p>
303
304<div>
305<div>
306<pre class="source">{ &quot;v1&quot;: &quot;NaN&quot;, &quot;v2&quot;: &quot;INF&quot;, &quot;v3&quot;: &quot;-INF&quot;, &quot;v4&quot;: -2013.5938237483274 }
307</pre></div></div>
308</li>
309</ul>
310<p><tt>Double precision</tt> is an alias of <tt>double</tt>.</p></div>
311<div class="section">
312<h3><a name="Binary"></a><a name="PrimitiveTypesBinary" id="PrimitiveTypesBinary">Binary</a></h3>
313<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>
314<ul>
315
316<li>
317
318<p>Example:</p>
319
320<div>
321<div>
322<pre class="source">{
323 &quot;hex1&quot; : hex(&quot;ABCDEF0123456789&quot;),
324 &quot;hex2&quot;: hex(&quot;abcdef0123456789&quot;),
325 &quot;base64_1&quot; : base64(&quot;0123456789qwertyui+/&quot;),
326 &quot;base64_2&quot; : base64('QXN0ZXJpeA==')
327};
328</pre></div></div>
329</li>
330<li>
331
332<p>The default output format is in <tt>hex</tt> format. Thus, the expected result is:</p>
333
334<div>
335<div>
336<pre class="source">{
337 &quot;hex1&quot;: hex(&quot;ABCDEF0123456789&quot;),
338 &quot;hex2&quot;: hex(&quot;ABCDEF0123456789&quot;),
339 &quot;base64_1&quot;: hex(&quot;D35DB7E39EBBF3DAB07ABB72BA2FBF&quot;),
340 &quot;base64_2&quot;: hex(&quot;41737465726978&quot;)
341}
342</pre></div></div>
343</li>
344</ul></div>
345<div class="section">
346<h3><a name="Point"></a><a name="PrimitiveTypesPoint" id="PrimitiveTypesPoint">Point</a></h3>
347<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>
348<ul>
349
350<li>
351
352<p>Example:</p>
353
354<div>
355<div>
356<pre class="source">{ &quot;v1&quot;: point(&quot;80.10d, -10E5&quot;), &quot;v2&quot;: point(&quot;5.10E-10d, -10E5&quot;) };
357</pre></div></div>
358</li>
359<li>
360
361<p>The expected result is:</p>
362
363<div>
364<div>
365<pre class="source">{ &quot;v1&quot;: point(&quot;80.1,-1000000.0&quot;), &quot;v2&quot;: point(&quot;5.1E-10,-1000000.0&quot;) }
366</pre></div></div>
367</li>
368</ul></div>
369<div class="section">
370<h3><a name="Line"></a><a name="PrimitiveTypesLine" id="PrimitiveTypesLine">Line</a></h3>
371<p><tt>line</tt> consists of two points that represent the start and the end points of a line segment.</p>
372<ul>
373
374<li>
375
376<p>Example:</p>
377
378<div>
379<div>
380<pre class="source">{ &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;) };
381</pre></div></div>
382</li>
383<li>
384
385<p>The expected result is:</p>
386
387<div>
388<div>
389<pre class="source">{ &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;) }
390</pre></div></div>
391</li>
392</ul></div>
393<div class="section">
394<h3><a name="Rectangle"></a><a name="PrimitiveTypesRectangle" id="PrimitiveTypesRectangle">Rectangle</a></h3>
395<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>
396<ul>
397
398<li>
399
400<p>Example:</p>
401
402<div>
403<div>
404<pre class="source">{ &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;) };
405</pre></div></div>
406</li>
407<li>
408
409<p>The expected result is:</p>
410
411<div>
412<div>
413<pre class="source">{ &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;) }
414</pre></div></div>
415</li>
416</ul></div>
417<div class="section">
418<h3><a name="Circle"></a><a name="PrimitiveTypesCircle" id="PrimitiveTypesCircle">Circle</a></h3>
419<p><tt>circle</tt> consists of one point that represents the center of the circle and a radius of type <tt>double</tt>.</p>
420<ul>
421
422<li>
423
424<p>Example:</p>
425
426<div>
427<div>
428<pre class="source">{ &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;) };
429</pre></div></div>
430</li>
431<li>
432
433<p>The expected result is:</p>
434
435<div>
436<div>
437<pre class="source">{ &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;) }
438</pre></div></div>
439</li>
440</ul></div>
441<div class="section">
442<h3><a name="Polygon"></a><a name="PrimitiveTypesPolygon" id="PrimitiveTypesPolygon">Polygon</a></h3>
443<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>
444<ul>
445
446<li>
447
448<p>Example:</p>
449
450<div>
451<div>
452<pre class="source">{
453 &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;),
454 &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;)
455};
456</pre></div></div>
457</li>
458<li>
459
460<p>The expected result is:</p>
461
462<div>
463<div>
464<pre class="source">{
465 &quot;v1&quot;: polygon(&quot;-1.2,130.0 -214000.0,2.15 -350.0,3.6 -0.0046,4.81&quot;),
466 &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;) }
467}
468</pre></div></div>
469</li>
470</ul></div>
471<div class="section">
472<h3><a name="Date"></a><a name="PrimitiveTypesDate" id="PrimitiveTypesDate">Date</a></h3>
473<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>
474<p>A date value can be represented in two formats, extended format and basic format.</p>
475<ul>
476
477<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>
478<li>Basic format is in the format of <tt>[-]yyyymmdd</tt>.</li>
479<li>
480
481<p>Example:</p>
482
483<div>
484<div>
485<pre class="source">{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-19700101&quot;) };
486</pre></div></div>
487</li>
488<li>
489
490<p>The expected result is:</p>
491
492<div>
493<div>
494<pre class="source">{ &quot;v1&quot;: date(&quot;2013-01-01&quot;), &quot;v2&quot;: date(&quot;-1970-01-01&quot;) }
495</pre></div></div>
496</li>
497</ul></div>
498<div class="section">
499<h3><a name="Time"></a><a name="PrimitiveTypesTime" id="PrimitiveTypesTime">Time</a></h3>
500<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>
501<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>
502<ul>
503
504<li>
505
506<p>Example:</p>
507
508<div>
509<div>
510<pre class="source">{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;000000000-0800&quot;) };
511</pre></div></div>
512</li>
513<li>
514
515<p>The expected result is:</p>
516
517<div>
518<div>
519<pre class="source">{ &quot;v1&quot;: time(&quot;12:12:12.039Z&quot;), &quot;v2&quot;: time(&quot;08:00:00.000Z&quot;) }
520</pre></div></div>
521</li>
522</ul></div>
523<div class="section">
524<h3><a name="Datetime_.28Timestamp.29"></a><a name="PrimitiveTypesDateTime" id="PrimitiveTypesDateTime">Datetime (Timestamp)</a></h3>
525<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>
526<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>
527<p>Millisecond field and timezone field are optional, as specified in the <tt>time</tt> type.</p>
528<ul>
529
530<li>
531
532<p>Example:</p>
533
534<div>
535<div>
536<pre class="source">{ &quot;v1&quot;: datetime(&quot;2013-01-01T12:12:12.039Z&quot;), &quot;v2&quot;: datetime(&quot;-19700101T000000000-0800&quot;) };
537</pre></div></div>
538</li>
539<li>
540
541<p>The expected result is:</p>
542
543<div>
544<div>
545<pre class="source">{ &quot;v1&quot;: datetime(&quot;2013-01-01T12:12:12.039Z&quot;), &quot;v2&quot;: datetime(&quot;-1970-01-01T08:00:00.000Z&quot;) }
546</pre></div></div>
547</li>
548</ul>
549<p><tt>timestamp</tt> is an alias of <tt>datetime</tt>.</p></div>
550<div class="section">
551<h3><a name="Duration.2FYear_month_duration.2FDay_time_duration"></a><a name="PrimitiveTypesDuration" id="PrimitiveTypesDuration">Duration/Year_month_duration/Day_time_duration</a></h3>
552<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>
553<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>
554<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>
555<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>
556<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>
557<ul>
558
559<li>
560
561<p>Example:</p>
562
563<div>
564<div>
565<pre class="source">{ &quot;v1&quot;: duration(&quot;P100Y12MT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) };
566</pre></div></div>
567</li>
568<li>
569
570<p>The expected result is:</p>
571
572<div>
573<div>
574<pre class="source">{ &quot;v1&quot;: duration(&quot;P101YT12M&quot;), &quot;v2&quot;: duration(&quot;-PT20.943S&quot;) }
575</pre></div></div>
576</li>
577</ul></div>
578<div class="section">
579<h3><a name="Interval"></a><a name="PrimitiveTypesInterval" id="PrimitiveTypesInterval">Interval</a></h3>
580<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>
581<ul>
582
583<li>
584
585<p>Example:</p>
586
587<div>
588<div>
589<pre class="source">{
590 &quot;v1&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;)),
591 &quot;v2&quot;: interval(time(&quot;00:01:01&quot;), time(&quot;213901049+0800&quot;)),
592 &quot;v3&quot;: interval(datetime(&quot;2013-01-01T00:01:01&quot;), datetime(&quot;20130505T213901049+0800&quot;))
593};
594</pre></div></div>
595</li>
596<li>
597
598<p>The expected result is:</p>
599
600<div>
601<div>
602<pre class="source">{
603 &quot;v1&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2013-05-05&quot;)),
604 &quot;v2&quot;: interval(time(&quot;00:01:01.000Z&quot;), time(&quot;13:39:01.049Z&quot;)),
605 &quot;v3&quot;: interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))
606}
607</pre></div></div>
608</li>
609</ul></div>
610<div class="section">
611<h3><a name="UUID"></a><a name="PrimitiveTypesUUID" id="PrimitiveTypesUUID">UUID</a></h3>
612<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>
613<ul>
614
615<li>
616
617<p>Example:</p>
618
619<div>
620<div>
621<pre class="source">return { &quot;v1&quot;:uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
622</pre></div></div>
623</li>
624<li>
625
626<p>The expected result is:</p>
627
628<div>
629<div>
630<pre class="source">{ &quot;v1&quot;: uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;) }
631</pre></div></div>
632</li>
633</ul><!--
634 ! Licensed to the Apache Software Foundation (ASF) under one
635 ! or more contributor license agreements. See the NOTICE file
636 ! distributed with this work for additional information
637 ! regarding copyright ownership. The ASF licenses this file
638 ! to you under the Apache License, Version 2.0 (the
639 ! "License"); you may not use this file except in compliance
640 ! with the License. You may obtain a copy of the License at
641 !
642 ! http://www.apache.org/licenses/LICENSE-2.0
643 !
644 ! Unless required by applicable law or agreed to in writing,
645 ! software distributed under the License is distributed on an
646 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
647 ! KIND, either express or implied. See the License for the
648 ! specific language governing permissions and limitations
649 ! under the License.
650 !-->
651</div></div>
652<div class="section">
653<h2><a name="Incomplete_Information_Types"></a><a name="IncompleteInformationTypes" id="IncompleteInformationTypes">Incomplete Information Types</a></h2>
654<div class="section">
655<h3><a name="Null"></a><a name="IncompleteInformationTypesNull" id="IncompleteInformationTypesNull">Null</a></h3>
656<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>
657<ul>
658
659<li>
660
661<p>Example:</p>
662
663<div>
664<div>
665<pre class="source">{ &quot;field&quot;: null };
666</pre></div></div>
667</li>
668<li>
669
670<p>The expected result is:</p>
671
672<div>
673<div>
674<pre class="source">{ &quot;field&quot;: null }
675</pre></div></div>
676</li>
677</ul></div>
678<div class="section">
679<h3><a name="Missing"></a><a name="IncompleteInformationTypesMissing" id="IncompleteInformationTypesMissing">Missing</a></h3>
680<p><tt>missing</tt> indicates that a name-value pair is missing from an object. If a missing name-value pair is accessed, an empty result value is returned by the query.</p>
681<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>
682<ul>
683
684<li>
685
686<p>Example:</p>
687
688<div>
689<div>
690<pre class="source">{ &quot;field&quot;: missing };
691</pre></div></div>
692</li>
693<li>
694
695<p>The expected result is:</p>
696
697<div>
698<div>
699<pre class="source">{ }
700</pre></div></div>
701</li>
702</ul>
703<p>Since a field with value <tt>missing</tt> means the field is absent, we get an empty object.</p><!--
704 ! Licensed to the Apache Software Foundation (ASF) under one
705 ! or more contributor license agreements. See the NOTICE file
706 ! distributed with this work for additional information
707 ! regarding copyright ownership. The ASF licenses this file
708 ! to you under the Apache License, Version 2.0 (the
709 ! "License"); you may not use this file except in compliance
710 ! with the License. You may obtain a copy of the License at
711 !
712 ! http://www.apache.org/licenses/LICENSE-2.0
713 !
714 ! Unless required by applicable law or agreed to in writing,
715 ! software distributed under the License is distributed on an
716 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
717 ! KIND, either express or implied. See the License for the
718 ! specific language governing permissions and limitations
719 ! under the License.
720 !-->
721</div></div>
722<div class="section">
723<h2><a name="Derived_Types"></a><a name="DerivedTypes" id="DerivedTypes">Derived Types</a></h2>
724<div class="section">
725<h3><a name="Object"></a><a name="DerivedTypesObject" id="DerivedTypesObject">Object</a></h3>
726<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>
727
728<div>
729<div>
730<pre class="source"> create type SoldierType as open {
731 name: string?,
732 rank: string,
733 serialno: int
734 };
735</pre></div></div>
736
737<p>Syntactically, object constructors are surrounded by curly braces &#x201c;{&#x2026;}&#x201d;. Some examples of legitimate instances of the above type include:</p>
738
739<div>
740<div>
741<pre class="source"> { &quot;name&quot;: &quot;Joe Blow&quot;, &quot;rank&quot;: &quot;Sergeant&quot;, &quot;serialno&quot;: 1234567 }
742 { &quot;rank&quot;: &quot;Private&quot;, &quot;serialno&quot;: 9876543 }
743 { &quot;name&quot;: &quot;Sally Forth&quot;, &quot;rank&quot;: &quot;Major&quot;, &quot;serialno&quot;: 2345678, &quot;gender&quot;: &quot;F&quot; }
744</pre></div></div>
745
746<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>
747<div class="section">
748<h3><a name="Array"></a><a name="DerivedTypesArray" id="DerivedTypesArray">Array</a></h3>
749<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>
750<p>An example would be</p>
751
752<div>
753<div>
754<pre class="source"> [&quot;alice&quot;, 123, &quot;bob&quot;, null]
755</pre></div></div>
756</div>
757<div class="section">
758<h3><a name="Multiset"></a><a name="DerivedTypesMultiset" id="DerivedTypesMultiset">Multiset</a></h3>
759<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>
760<p>An example would be</p>
761
762<div>
763<div>
764<pre class="source"> {{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}}
765</pre></div></div></div></div>
766 </div>
767 </div>
768 </div>
769 <hr/>
770 <footer>
771 <div class="container-fluid">
772 <div class="row-fluid">
773<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
774 feather logo, and the Apache AsterixDB project logo are either
775 registered trademarks or trademarks of The Apache Software
776 Foundation in the United States and other countries.
777 All other marks mentioned may be trademarks or registered
778 trademarks of their respective owners.
779 </div>
780 </div>
781 </div>
782 </footer>
783 </body>
784</html>