blob: b5efbd7f327ede9359bf307269a99033803a6d04 [file] [log] [blame]
Ian Maxoned124d82015-05-29 18:44:11 -07001<!DOCTYPE html>
2<!--
Till Westmann0817a3f2015-06-03 21:08:18 -07003 | Generated by Apache Maven Doxia at 2015-05-31
Ian Maxoned124d82015-05-29 18:44:11 -07004 | 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" />
Till Westmann0817a3f2015-06-03 21:08:18 -070010 <meta name="Date-Revision-yyyymmdd" content="20150531" />
Ian Maxoned124d82015-05-29 18:44:11 -070011 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB - </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 </head>
22 <body class="topBarDisabled">
23
24
25
26
27 <div class="container-fluid">
28 <div id="banner">
29 <div class="pull-left">
30 <a href=".././" id="bannerLeft">
31 <img src="../images/asterixlogo.png" alt="AsterixDB"/>
32 </a>
33 </div>
34 <div class="pull-right"> <a href="http://incubator.apache.org/" id="bannerRight">
35 <img src="../images/egg-logo.png" alt="Apache Software Foundation Incubator"/>
36 </a>
37 </div>
38 <div class="clear"><hr/></div>
39 </div>
40
41 <div id="breadcrumbs">
42 <ul class="breadcrumb">
43
44
Till Westmann0817a3f2015-06-03 21:08:18 -070045 <li id="publishDate">Last Published: 2015-05-31</li>
Ian Maxoned124d82015-05-29 18:44:11 -070046
47
48
49 <li id="projectVersion" class="pull-right">Version: 0.8.7-SNAPSHOT</li>
50
51 <li class="divider pull-right">|</li>
52
53 <li class="pull-right"> <a href="../index.html" title="Home">
54 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">Apache Software Foundation</li>
68
69 <li>
70
71 <a href="http://www.apache.org/" class="externalLink" title="Home">
72 <i class="none"></i>
73 Home</a>
74 </li>
75
76 <li>
77
78 <a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Donate">
79 <i class="none"></i>
80 Donate</a>
81 </li>
82
83 <li>
84
85 <a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
86 <i class="none"></i>
87 Thanks</a>
88 </li>
89
90 <li>
91
92 <a href="http://www.apache.org/security/" class="externalLink" title="Security">
93 <i class="none"></i>
94 Security</a>
95 </li>
96 <li class="nav-header">User Documentation</li>
97
98 <li>
99
100 <a href="../install.html" title="Installing and Managing AsterixDB using Managix">
101 <i class="none"></i>
102 Installing and Managing AsterixDB using Managix</a>
103 </li>
104
105 <li>
106
107 <a href="../aql/primer.html" title="AsterixDB 101: An ADM and AQL Primer">
108 <i class="none"></i>
109 AsterixDB 101: An ADM and AQL Primer</a>
110 </li>
111
112 <li>
113
114 <a href="../aql/primer-sql-like.html" title="AsterixDB 101: An ADM and AQL Primer (For SQL Fans)">
115 <i class="none"></i>
116 AsterixDB 101: An ADM and AQL Primer (For SQL Fans)</a>
117 </li>
118
119 <li>
120
121 <a href="../aql/js-sdk.html" title="AsterixDB Javascript SDK">
122 <i class="none"></i>
123 AsterixDB Javascript SDK</a>
124 </li>
125
126 <li>
127
128 <a href="../aql/datamodel.html" title="Asterix Data Model (ADM)">
129 <i class="none"></i>
130 Asterix Data Model (ADM)</a>
131 </li>
132
133 <li>
134
135 <a href="../aql/manual.html" title="Asterix Query Language (AQL)">
136 <i class="none"></i>
137 Asterix Query Language (AQL)</a>
138 </li>
139
140 <li>
141
142 <a href="../aql/functions.html" title="AQL Functions">
143 <i class="none"></i>
144 AQL Functions</a>
145 </li>
146
147 <li class="active">
148
149 <a href="#"><i class="none"></i>AQL Allen's Relations Functions</a>
150 </li>
151
152 <li>
153
154 <a href="../aql/similarity.html" title="AQL Support of Similarity Queries">
155 <i class="none"></i>
156 AQL Support of Similarity Queries</a>
157 </li>
158
159 <li>
160
161 <a href="../aql/externaldata.html" title="Accessing External Data">
162 <i class="none"></i>
163 Accessing External Data</a>
164 </li>
165
166 <li>
167
168 <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
169 <i class="none"></i>
170 Filter-Based LSM Index Acceleration</a>
171 </li>
172
173 <li>
174
175 <a href="../api.html" title="REST API to AsterixDB">
176 <i class="none"></i>
177 REST API to AsterixDB</a>
178 </li>
179 </ul>
180
181
182
183 <hr class="divider" />
184
185 <div id="poweredBy">
186 <div class="clear"></div>
187 <div class="clear"></div>
188 <div class="clear"></div>
189 <a href=".././" title="Hyracks" class="builtBy">
190 <img class="builtBy" alt="Hyracks" src="../images/hyrax_ts.png" />
191 </a>
192 </div>
193 </div>
194 </div>
195
196
197 <div id="bodyColumn" class="span9" >
198
199 <h1>AsterixDB Temporal Functions: Allen&#x2019;s Relations</h1>
200<div class="section">
201<h2><a name="toc" id="toc">Table of Contents</a><a name="Table_of_Contents"></a></h2>
202
203<ul>
204
205<li><a href="#AboutAllensRelations">About Allen&#x2019;s Relations</a></li>
206
207<li><a href="#AllensRelatonsFunctions">Allen&#x2019;s Relations Functions</a></li>
208</ul></div>
209<div class="section">
210<h2><a name="AboutAllensRelations" id="AboutAllensRelations">About Allen&#x2019;s Relations</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="About_Allens_Relations_Back_to_TOC"></a></h2>
211<p>AsterixDB supports Allen&#x2019;s relations over interval types. Allen&#x2019;s relations are also called Allen&#x2019;s interval algebra. There are totally 13 base relations described by this algebra, and all of them are supported in AsterixDB (note that <tt>interval-equals</tt> is supported by the <tt>=</tt> comparison symbol so there is no extra function for it). </p>
212<p>A detailed description of Allen&#x2019;s relations can be found from its <a class="externalLink" href="http://en.wikipedia.org/wiki/Allen&apos;s_interval_algebra">wikipedia entry</a>. </p></div>
213<div class="section">
214<h2><a name="AllensRelatonsFunctions" id="AllensRelatonsFunctions">Allen&#x2019;s Relations Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font><a name="Allens_Relations_Functions_Back_to_TOC"></a></h2>
215<div class="section">
216<h3>interval-before, interval-after<a name="interval-before_interval-after"></a></h3>
217
218<ul>
219
220<li>
221<p>Syntax:</p>
222
223<div class="source">
224<pre>interval-before(interval1, interval2)
225interval-after(interval1, interval2)
226</pre></div></li>
227
228<li>
229<p>These two functions check whether an interval happens before/after another interval. </p></li>
230
231<li>Arguments:
232
233<ul>
234
235<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
236 </ul></li>
237
238<li>
239<p>Return Value:</p>
240<p>A <tt>boolean</tt> value. Specifically, <tt>interval-before(interval1, interval2)</tt> is true if and only if <tt>interval1.end &lt; interval2.start</tt>, and <tt>interval-after(interval1, interval2)</tt> is true if and only if <tt>interval1.start &gt; interval2.end</tt>. If any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
241
242<li>
243<p>Examples:</p>
244
245<div class="source">
246<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
247let $itv2 := interval-from-date(&quot;2005-05-01&quot;, &quot;2012-09-09&quot;)
248return {&quot;interval-before&quot;: interval-before($itv1, $itv2), &quot;interval-after&quot;: interval-after($itv2, $itv1)}
249</pre></div></li>
250
251<li>
252<p>The expected result is:</p>
253
254<div class="source">
255<pre>{ &quot;interval-before&quot;: true, &quot;interval-after&quot;: true }
256</pre></div></li>
257</ul></div>
258<div class="section">
259<h3>interval-covers, interval-covered-by<a name="interval-covers_interval-covered-by"></a></h3>
260
261<ul>
262
263<li>
264<p>Syntax:</p>
265
266<div class="source">
267<pre>interval-covers(interval1, interval2)
268interval-covered-by(interval1, interval2)
269</pre></div></li>
270
271<li>
272<p>These two functions check whether one interval covers the other interval.</p></li>
273
274<li>Arguments:
275
276<ul>
277
278<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
279 </ul></li>
280
281<li>
282<p>Return Value:</p>
283<p>A <tt>boolean</tt> value. Specifically, <tt>interval-covers(interval1, interval2)</tt> is true if and only if</p>
284
285<div class="source">
286<pre>interval1.start &lt;= interval2.start
287AND interval1.end &gt;= interval2.end
288</pre></div>
289<p><tt>interval-covered-by(interval1, interval2)</tt> is true if and only if</p>
290
291<div class="source">
292<pre>interval2.start &lt;= interval1.start
293AND interval2.end &gt;= interval1.end
294</pre></div>
295<p>For both functions, if any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
296
297<li>
298<p>Examples:</p>
299
300<div class="source">
301<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
302let $itv2 := interval-from-date(&quot;2000-03-01&quot;, &quot;2004-09-09&quot;)
303let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
304let $itv4 := interval-from-date(&quot;2004-09-10&quot;, &quot;2012-08-01&quot;)
305return {&quot;interval-covers&quot;: interval-covers($itv1, $itv2), &quot;interval-covered-by&quot;: interval-covered-by($itv3, $itv4)}
306</pre></div></li>
307
308<li>
309<p>The expected result is:</p>
310
311<div class="source">
312<pre>{ &quot;interval-covers&quot;: true, &quot;interval-covered-by&quot;: true }
313</pre></div></li>
314</ul></div>
315<div class="section">
316<h3>interval-overlaps, interval-overlapped-by<a name="interval-overlaps_interval-overlapped-by"></a></h3>
317
318<ul>
319
320<li>
321<p>Syntax:</p>
322
323<div class="source">
324<pre>interval-overlaps(interval1, interval2)
325interval-overlapped-by(interval1, interval2)
326</pre></div></li>
327
328<li>
329<p>These functions check whether two intervals overlap with each other.</p></li>
330
331<li>Arguments:
332
333<ul>
334
335<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
336 </ul></li>
337
338<li>
339<p>Return Value:</p>
340<p>A <tt>boolean</tt> value. Specifically, <tt>interval-overlaps(interval1, interval2)</tt> is true if and only if</p>
341
342<div class="source">
343<pre>interval1.start &lt; interval2.start
344AND interval2.end &gt; interval1.end
345AND interval1.end &gt; interval2.start
346</pre></div>
347<p><tt>interval-overlapped-by(interval1, interval2)</tt> is true if and only if</p>
348
349<div class="source">
350<pre>interval2.start &lt; interval1.start
351AND interval1.end &gt; interval2.end
352AND interval2.end &gt; interval1.start
353</pre></div>
354<p>For all these functions, if any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p>
355<p>Note that <tt>interval-overlaps</tt> and <tt>interval-overlapped-by</tt> are following the Allen&#x2019;s relations on the definition of overlap.</p></li>
356
357<li>
358<p>Examples:</p>
359
360<div class="source">
361<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
362let $itv2 := interval-from-date(&quot;2004-05-01&quot;, &quot;2012-09-09&quot;)
363let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
364let $itv4 := interval-from-date(&quot;2004-09-10&quot;, &quot;2006-12-31&quot;)
365return {&quot;overlaps&quot;: interval-overlaps($itv1, $itv2),
366 &quot;overlapped-by&quot;: interval-overlapped-by($itv3, $itv4)}
367</pre></div></li>
368
369<li>
370<p>The expected result is:</p>
371
372<div class="source">
373<pre>{ &quot;overlaps&quot;: true, &quot;overlapped-by&quot;: true }
374</pre></div></li>
375</ul></div>
376<div class="section">
377<h3>interval-overlapping<a name="interval-overlapping"></a></h3>
378<p>Note that <tt>interval-overlapping</tt> is not an Allen&#x2019;s Relation, but syntactic sugar we added for the case that the intersect of two intervals is not empty. Basically this function returns true if any of these functions return true: <tt>interval-overlaps</tt>, <tt>interval-overlapped-by</tt>, <tt>interval-covers</tt>, or <tt>interval-covered-by</tt>.</p>
379
380<ul>
381
382<li>
383<p>Syntax:</p>
384
385<div class="source">
386<pre>interval-overlapping(interval1, interval2)
387</pre></div></li>
388
389<li>
390<p>This functions check whether two intervals share any points with each other. </p></li>
391
392<li>Arguments:
393
394<ul>
395
396<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
397 </ul></li>
398
399<li>
400<p>Return Value:</p>
401<p>A <tt>boolean</tt> value. Specifically, <tt>interval-overlapping(interval1, interval2)</tt> is true if</p>
402
403<div class="source">
404<pre>(interval2.start &gt;= interval1.start
405AND interval2.start &lt; interval1.end)
406OR
407(interval2.end &gt; interval1.start
408AND interval2.end &lt;= interval1.end)
409</pre></div>
410<p>If any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
411
412<li>
413<p>Examples:</p>
414
415<div class="source">
416<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
417let $itv2 := interval-from-date(&quot;2004-05-01&quot;, &quot;2012-09-09&quot;)
418let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
419let $itv4 := interval-from-date(&quot;2004-09-10&quot;, &quot;2006-12-31&quot;)
420return {&quot;overlapping1&quot;: interval-overlapping($itv1, $itv2),
421 &quot;overlapping2&quot;: interval-overlapping($itv3, $itv4)}
422</pre></div></li>
423
424<li>
425<p>The expected result is:</p>
426
427<div class="source">
428<pre>{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
429</pre></div></li>
430</ul></div>
431<div class="section">
432<h3>interval-meets, interval-met-by<a name="interval-meets_interval-met-by"></a></h3>
433
434<ul>
435
436<li>
437<p>Syntax:</p>
438
439<div class="source">
440<pre>interval-meets(interval1, interval2)
441interval-met-by(interval1, interval2)
442</pre></div></li>
443
444<li>
445<p>These two functions check whether an interval meets with another interval. </p></li>
446
447<li>Arguments:
448
449<ul>
450
451<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
452 </ul></li>
453
454<li>
455<p>Return Value:</p>
456<p>A <tt>boolean</tt> value. Specifically, <tt>interval-meets(interval1, interval2)</tt> is true if and only if <tt>interval1.end = interval2.start</tt>, and <tt>interval-met-by(interval1, interval2)</tt> is true if and only if <tt>interval1.start = interval2.end</tt>. If any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
457
458<li>
459<p>Examples:</p>
460
461<div class="source">
462<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
463let $itv2 := interval-from-date(&quot;2005-01-01&quot;, &quot;2012-09-09&quot;)
464let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
465let $itv4 := interval-from-date(&quot;2004-09-10&quot;, &quot;2006-08-01&quot;)
466return {&quot;meets&quot;: interval-meets($itv1, $itv2), &quot;metby&quot;: interval-met-by($itv3, $itv4)}
467</pre></div></li>
468
469<li>
470<p>The expected result is:</p>
471
472<div class="source">
473<pre>{ &quot;meets&quot;: true, &quot;metby&quot;: true }
474</pre></div></li>
475</ul></div>
476<div class="section">
477<h3>interval-starts, interval-started-by<a name="interval-starts_interval-started-by"></a></h3>
478
479<ul>
480
481<li>
482<p>Syntax:</p>
483
484<div class="source">
485<pre>interval-starts(interval1, interval2)
486interval-started-by(interval1, interval2)
487</pre></div></li>
488
489<li>
490<p>These two functions check whether one interval starts with the other interval.</p></li>
491
492<li>Arguments:
493
494<ul>
495
496<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
497 </ul></li>
498
499<li>
500<p>Return Value:</p>
501<p>A <tt>boolean</tt> value. Specifically, <tt>interval-starts(interval1, interval2)</tt> returns true if and only if</p>
502
503<div class="source">
504<pre>interval1.start = interval2.start
505AND interval1.end &lt;= interval2.end
506</pre></div>
507<p><tt>interval-started-by(interval1, interval2)</tt> returns true if and only if</p>
508
509<div class="source">
510<pre>interval1.start = interval2.start
511AND interval2.end &lt;= interval1.end
512</pre></div>
513<p>For both functions, if any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
514
515<li>
516<p>Examples:</p>
517
518<div class="source">
519<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
520let $itv2 := interval-from-date(&quot;2000-01-01&quot;, &quot;2012-09-09&quot;)
521let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
522let $itv4 := interval-from-date(&quot;2006-08-01&quot;, &quot;2006-08-01&quot;)
523return {&quot;interval-starts&quot;: interval-starts($itv1, $itv2), &quot;interval-started-by&quot;: interval-started-by($itv3, $itv4)}
524</pre></div></li>
525
526<li>
527<p>The expected result is:</p>
528
529<div class="source">
530<pre>{ &quot;interval-starts&quot;: true, &quot;interval-started-by&quot;: true }
531</pre></div></li>
532</ul></div>
533<div class="section">
534<h3>interval-ends, interval-ended-by<a name="interval-ends_interval-ended-by"></a></h3>
535
536<ul>
537
538<li>
539<p>Syntax:</p>
540
541<div class="source">
542<pre>interval-ends(interval1, interval2)
543interval-ended-by(interval1, interval2)
544</pre></div></li>
545
546<li>
547<p>These two functions check whether one interval ends with the other interval.</p></li>
548
549<li>Arguments:
550
551<ul>
552
553<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
554 </ul></li>
555
556<li>
557<p>Return Value:</p>
558<p>A <tt>boolean</tt> value. Specifically, <tt>interval-ends(interval1, interval2)</tt> returns true if and only if</p>
559
560<div class="source">
561<pre>interval1.end = interval2.end
562AND interval1.start &gt;= interval2.start
563</pre></div>
564<p><tt>interval-ended-by(interval1, interval2)</tt> returns true if and only if</p>
565
566<div class="source">
567<pre>interval2.end = interval1.end
568AND interval2.start &gt;= interval1.start
569</pre></div>
570<p>For both functions, if any of the two inputs is <tt>null</tt>, <tt>null</tt> is returned.</p></li>
571
572<li>
573<p>Examples:</p>
574
575<div class="source">
576<pre>let $itv1 := interval-from-date(&quot;2000-01-01&quot;, &quot;2005-01-01&quot;)
577let $itv2 := interval-from-date(&quot;1998-01-01&quot;, &quot;2005-01-01&quot;)
578let $itv3 := interval-from-date(&quot;2006-08-01&quot;, &quot;2007-03-01&quot;)
579let $itv4 := interval-from-date(&quot;2006-09-10&quot;, &quot;2007-03-01&quot;)
580return {&quot;interval-ends&quot;: interval-ends($itv1, $itv2), &quot;interval-ended-by&quot;: interval-ended-by($itv3, $itv4) }
581</pre></div></li>
582
583<li>
584<p>The expected result is:</p>
585
586<div class="source">
587<pre>{ &quot;interval-ends&quot;: true, &quot;interval-ended-by&quot;: true }
588</pre></div></li>
589</ul></div></div>
590 </div>
591 </div>
592 </div>
593
594 <hr/>
595
596 <footer>
597 <div class="container-fluid">
598 <div class="row span12">Copyright &copy; 2015.
599 All Rights Reserved.
600
601 </div>
602
603 <?xml version="1.0" encoding="UTF-8"?>
604<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
605 feather logo, and the Apache AsterixDB project logo are either
606 registered trademarks or trademarks of The Apache Software
607 Foundation in the United States and other countries.
608 All other marks mentioned may be trademarks or registered
609 trademarks of their respective owners.</div>
610
611
612 </div>
613 </footer>
614 </body>
615</html>