blob: 1eb513729033a35afc050fb7f53379417eaa0cdb [file] [log] [blame]
Ian Maxond5b11d82017-01-25 10:48:05 -08001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia at 2017-01-25
4 | Rendered using Apache Maven Fluido Skin 1.3.0
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20170125" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; Builtin Functions</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
22<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
23 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
24 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
25 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
26
27 ga('create', 'UA-41536543-1', 'uci.edu');
28 ga('send', 'pageview');</script>
29
30 </head>
31 <body class="topBarDisabled">
32
33
34
35
36 <div class="container-fluid">
37 <div id="banner">
38 <div class="pull-left">
39 <a href=".././" id="bannerLeft">
40 <img src="../images/asterixlogo.png" alt="AsterixDB"/>
41 </a>
42 </div>
43 <div class="pull-right"> </div>
44 <div class="clear"><hr/></div>
45 </div>
46
47 <div id="breadcrumbs">
48 <ul class="breadcrumb">
49
50
51 <li id="publishDate">Last Published: 2017-01-25</li>
52
53
54
55 <li id="projectVersion" class="pull-right">Version: 0.9.0</li>
56
57 <li class="divider pull-right">|</li>
58
59 <li class="pull-right"> <a href="../index.html" title="Documentation Home">
60 Documentation Home</a>
61 </li>
62
63 </ul>
64 </div>
65
66
67 <div class="row-fluid">
68 <div id="leftColumn" class="span3">
69 <div class="well sidebar-nav">
70
71
72 <ul class="nav nav-list">
73 <li class="nav-header">Get Started - Installation</li>
74
75 <li>
76
77 <a href="../ncservice.html" title="Option 1: using NCService">
78 <i class="none"></i>
79 Option 1: using NCService</a>
80 </li>
81
82 <li>
83
84 <a href="../install.html" title="Option 2: using Managix">
85 <i class="none"></i>
86 Option 2: using Managix</a>
87 </li>
88
89 <li>
90
91 <a href="../yarn.html" title="Option 3: using YARN">
92 <i class="none"></i>
93 Option 3: using YARN</a>
94 </li>
95 <li class="nav-header">AsterixDB Primer</li>
96
97 <li>
98
99 <a href="../sqlpp/primer-sqlpp.html" title="Option 1: using SQL++">
100 <i class="none"></i>
101 Option 1: using SQL++</a>
102 </li>
103
104 <li>
105
106 <a href="../aql/primer.html" title="Option 2: using AQL">
107 <i class="none"></i>
108 Option 2: using AQL</a>
109 </li>
110 <li class="nav-header">Data Model</li>
111
112 <li>
113
114 <a href="../datamodel.html" title="The Asterix Data Model">
115 <i class="none"></i>
116 The Asterix Data Model</a>
117 </li>
118 <li class="nav-header">Queries - SQL++</li>
119
120 <li>
121
122 <a href="../sqlpp/manual.html" title="The SQL++ Query Language">
123 <i class="none"></i>
124 The SQL++ Query Language</a>
125 </li>
126
127 <li>
128
129 <a href="../sqlpp/builtins.html" title="Builtin Functions">
130 <i class="none"></i>
131 Builtin Functions</a>
132 </li>
133 <li class="nav-header">Queries - AQL</li>
134
135 <li>
136
137 <a href="../aql/manual.html" title="The Asterix Query Language (AQL)">
138 <i class="none"></i>
139 The Asterix Query Language (AQL)</a>
140 </li>
141
142 <li class="active">
143
144 <a href="#"><i class="none"></i>Builtin Functions</a>
145 </li>
146 <li class="nav-header">Advanced Features</li>
147
148 <li>
149
150 <a href="../aql/similarity.html" title="Support of Similarity Queries">
151 <i class="none"></i>
152 Support of Similarity Queries</a>
153 </li>
154
155 <li>
156
157 <a href="../aql/fulltext.html" title="Support of Full-text Queries">
158 <i class="none"></i>
159 Support of Full-text Queries</a>
160 </li>
161
162 <li>
163
164 <a href="../aql/externaldata.html" title="Accessing External Data">
165 <i class="none"></i>
166 Accessing External Data</a>
167 </li>
168
169 <li>
170
171 <a href="../feeds/tutorial.html" title="Support for Data Ingestion">
172 <i class="none"></i>
173 Support for Data Ingestion</a>
174 </li>
175
176 <li>
177
178 <a href="../udf.html" title="User Defined Functions">
179 <i class="none"></i>
180 User Defined Functions</a>
181 </li>
182
183 <li>
184
185 <a href="../aql/filters.html" title="Filter-Based LSM Index Acceleration">
186 <i class="none"></i>
187 Filter-Based LSM Index Acceleration</a>
188 </li>
189 <li class="nav-header">API/SDK</li>
190
191 <li>
192
193 <a href="../api.html" title="HTTP API">
194 <i class="none"></i>
195 HTTP API</a>
196 </li>
197 </ul>
198
199
200
201 <hr class="divider" />
202
203 <div id="poweredBy">
204 <div class="clear"></div>
205 <div class="clear"></div>
206 <div class="clear"></div>
207 <a href=".././" title="AsterixDB" class="builtBy">
208 <img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" />
209 </a>
210 </div>
211 </div>
212 </div>
213
214
215 <div id="bodyColumn" class="span9" >
216
217 <!-- ! Licensed to the Apache Software Foundation (ASF) under one
218 ! or more contributor license agreements. See the NOTICE file
219 ! distributed with this work for additional information
220 ! regarding copyright ownership. The ASF licenses this file
221 ! to you under the Apache License, Version 2.0 (the
222 ! "License"); you may not use this file except in compliance
223 ! with the License. You may obtain a copy of the License at
224 !
225 ! http://www.apache.org/licenses/LICENSE-2.0
226 !
227 ! Unless required by applicable law or agreed to in writing,
228 ! software distributed under the License is distributed on an
229 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
230 ! KIND, either express or implied. See the License for the
231 ! specific language governing permissions and limitations
232 ! under the License.
233 ! --><h1>Builtin Functions</h1>
234<div class="section">
235<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
236
237<ul>
238
239<li><a href="#NumericFunctions">Numeric Functions</a></li>
240
241<li><a href="#StringFunctions">String Functions</a></li>
242
243<li><a href="#BinaryFunctions">Binary Functions</a></li>
244
245<li><a href="#SpatialFunctions">Spatial Functions</a></li>
246
247<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
248
249<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
250
251<li><a href="#TemporalFunctions">Temporal Functions</a></li>
252
253<li><a href="#ObjectFunctions">Object Functions</a></li>
254
255<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
256
257<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
258
259<li><a href="#TypeFunctions">Type Functions</a></li>
260
261<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
262</ul>
263<p>The system provides various classes of functions to support operations on numeric, string, spatial, and temporal data. This document explains how to use these functions. <!-- ! Licensed to the Apache Software Foundation (ASF) under one
264 ! or more contributor license agreements. See the NOTICE file
265 ! distributed with this work for additional information
266 ! regarding copyright ownership. The ASF licenses this file
267 ! to you under the Apache License, Version 2.0 (the
268 ! "License"); you may not use this file except in compliance
269 ! with the License. You may obtain a copy of the License at
270 !
271 ! http://www.apache.org/licenses/LICENSE-2.0
272 !
273 ! Unless required by applicable law or agreed to in writing,
274 ! software distributed under the License is distributed on an
275 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
276 ! KIND, either express or implied. See the License for the
277 ! specific language governing permissions and limitations
278 ! under the License.
279 ! --></p></div>
280<div class="section">
281<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
282<div class="section">
283<h3><a name="abs"></a>abs</h3>
284
285<ul>
286
287<li>
288<p>Syntax:</p>
289
290<div class="source">
291<div class="source">
292<pre>abs(numeric_value)
293</pre></div></div></li>
294
295<li>
296<p>Computes the absolute value of the argument.</p></li>
297
298<li>Arguments:
299
300<ul>
301
302<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
303 </ul></li>
304
305<li>Return Value:
306
307<ul>
308
309<li>The absolute value of the argument with the same type as the input argument,</li>
310
311<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
312
313<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
314
315<li>any other non-numeric input value will cause a type error.</li>
316 </ul></li>
317
318<li>
319<p>Example:</p>
320
321<div class="source">
322<div class="source">
323<pre>{ &quot;v1&quot;: abs(2013), &quot;v2&quot;: abs(-4036), &quot;v3&quot;: abs(0), &quot;v4&quot;: abs(float(&quot;-2013.5&quot;)), &quot;v5&quot;: abs(double(&quot;-2013.593823748327284&quot;)) };
324</pre></div></div></li>
325</ul>
326
327<ul>
328
329<li>
330<p>The expected result is:</p>
331
332<div class="source">
333<div class="source">
334<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: 4036, &quot;v3&quot;: 0, &quot;v4&quot;: 2013.5, &quot;v5&quot;: 2013.5938237483274 }
335</pre></div></div></li>
336</ul></div>
337<div class="section">
338<h3><a name="acos"></a>acos</h3>
339
340<ul>
341
342<li>
343<p>Syntax:</p>
344
345<div class="source">
346<div class="source">
347<pre>acos(numeric_value)
348</pre></div></div></li>
349
350<li>
351<p>Computes the arc cosine value of the argument.</p></li>
352
353<li>Arguments:
354
355<ul>
356
357<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
358 </ul></li>
359
360<li>Return Value:
361
362<ul>
363
364<li>the <tt>double</tt> arc cosine in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
365
366<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
367
368<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
369
370<li>any other non-numeric input value will cause a type error,</li>
371
372<li>NaN for other legitimate numeric values.</li>
373 </ul></li>
374
375<li>
376<p>Example:</p>
377
378<div class="source">
379<div class="source">
380<pre>{ &quot;v1&quot;: acos(1), &quot;v2&quot;: acos(2), &quot;v3&quot;: acos(0), &quot;v4&quot;: acos(float(&quot;0.5&quot;)), &quot;v5&quot;: acos(double(&quot;-0.5&quot;)) };
381</pre></div></div></li>
382</ul>
383
384<ul>
385
386<li>
387<p>The expected result is:</p>
388
389<div class="source">
390<div class="source">
391<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: NaN, &quot;v3&quot;: 1.5707963267948966, &quot;v4&quot;: 1.0471975511965979, &quot;v5&quot;: 2.0943951023931957 }
392</pre></div></div></li>
393</ul></div>
394<div class="section">
395<h3><a name="asin"></a>asin</h3>
396
397<ul>
398
399<li>
400<p>Syntax:</p>
401
402<div class="source">
403<div class="source">
404<pre>asin(numeric_value)
405</pre></div></div></li>
406
407<li>
408<p>Computes the arc sine value of the argument.</p></li>
409
410<li>Arguments:
411
412<ul>
413
414<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
415 </ul></li>
416
417<li>Return Value:
418
419<ul>
420
421<li>the <tt>double</tt> arc sin in radians for the argument, if the argument is in the range of -1 (inclusive) to 1 (inclusive),</li>
422
423<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
424
425<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
426
427<li>any other non-numeric input value will cause a type error,</li>
428
429<li>NaN for other legitimate numeric values.</li>
430 </ul></li>
431
432<li>
433<p>Example:</p>
434
435<div class="source">
436<div class="source">
437<pre>{ &quot;v1&quot;: asin(1), &quot;v2&quot;: asin(2), &quot;v3&quot;: asin(0), &quot;v4&quot;: asin(float(&quot;0.5&quot;)), &quot;v5&quot;: asin(double(&quot;-0.5&quot;)) };
438</pre></div></div></li>
439</ul>
440
441<ul>
442
443<li>
444<p>The expected result is:</p>
445
446<div class="source">
447<div class="source">
448<pre>{ &quot;v1&quot;: 1.5707963267948966, &quot;v2&quot;: NaN, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5235987755982989, &quot;v5&quot;: -0.5235987755982989 }
449</pre></div></div></li>
450</ul></div>
451<div class="section">
452<h3><a name="atan"></a>atan</h3>
453
454<ul>
455
456<li>
457<p>Syntax:</p>
458
459<div class="source">
460<div class="source">
461<pre>atan(numeric_value)
462</pre></div></div></li>
463
464<li>
465<p>Computes the arc tangent value of the argument.</p></li>
466
467<li>Arguments:
468
469<ul>
470
471<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
472 </ul></li>
473
474<li>Return Value:
475
476<ul>
477
478<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
479
480<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
481
482<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
483
484<li>any other non-numeric input value will cause a type error.</li>
485 </ul></li>
486
487<li>
488<p>Example:</p>
489
490<div class="source">
491<div class="source">
492<pre>{ &quot;v1&quot;: atan(1), &quot;v2&quot;: atan(2), &quot;v3&quot;: atan(0), &quot;v4&quot;: atan(float(&quot;0.5&quot;)), &quot;v5&quot;: atan(double(&quot;1000&quot;)) };
493</pre></div></div></li>
494</ul>
495
496<ul>
497
498<li>
499<p>The expected result is:</p>
500
501<div class="source">
502<div class="source">
503<pre>{ &quot;v1&quot;: 0.7853981633974483, &quot;v2&quot;: 1.1071487177940904, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.4636476090008061, &quot;v5&quot;: 1.5697963271282298 }
504</pre></div></div></li>
505</ul></div>
506<div class="section">
507<h3><a name="atan2"></a>atan2</h3>
508
509<ul>
510
511<li>
512<p>Syntax:</p>
513
514<div class="source">
515<div class="source">
516<pre>atan2(numeric_value1, numeric_value2)
517</pre></div></div></li>
518
519<li>
520<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p></li>
521
522<li>Arguments:
523
524<ul>
525
526<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
527
528<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
529 </ul></li>
530
531<li>Return Value:
532
533<ul>
534
535<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
536
537<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
538
539<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
540
541<li>any other non-numeric input value will cause a type error.</li>
542 </ul></li>
543
544<li>
545<p>Example:</p>
546
547<div class="source">
548<div class="source">
549<pre>{ &quot;v1&quot;: atan2(1, 2), &quot;v2&quot;: atan2(0, 4), &quot;v3&quot;: atan2(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
550</pre></div></div></li>
551</ul>
552
553<ul>
554
555<li>
556<p>The expected result is:</p>
557
558<div class="source">
559<div class="source">
560<pre>{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
561</pre></div></div></li>
562</ul></div>
563<div class="section">
564<h3><a name="ceil"></a>ceil</h3>
565
566<ul>
567
568<li>
569<p>Syntax:</p>
570
571<div class="source">
572<div class="source">
573<pre>ceil(numeric_value)
574</pre></div></div></li>
575
576<li>
577<p>Computes the smallest (closest to negative infinity) number with no fractional part that is not less than the value of the argument. If the argument is already equal to mathematical integer, then the result is the same as the argument.</p></li>
578
579<li>Arguments:
580
581<ul>
582
583<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
584 </ul></li>
585
586<li>Return Value:
587
588<ul>
589
590<li>The ceiling value for the given number in the same type as the input argument,</li>
591
592<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
593
594<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
595
596<li>any other non-numeric input value will cause a type error.</li>
597 </ul></li>
598
599<li>
600<p>Example:</p>
601
602<div class="source">
603<div class="source">
604<pre>{
605 &quot;v1&quot;: ceil(2013),
606 &quot;v2&quot;: ceil(-4036),
607 &quot;v3&quot;: ceil(0.3),
608 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
609 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
610};
611</pre></div></div></li>
612</ul>
613
614<ul>
615
616<li>
617<p>The expected result is:</p>
618
619<div class="source">
620<div class="source">
621<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2013.0 }
622</pre></div></div></li>
623</ul></div>
624<div class="section">
625<h3><a name="cos"></a>cos</h3>
626
627<ul>
628
629<li>
630<p>Syntax:</p>
631
632<div class="source">
633<div class="source">
634<pre>cos(numeric_value)
635</pre></div></div></li>
636
637<li>
638<p>Computes the cosine value of the argument.</p></li>
639
640<li>Arguments:
641
642<ul>
643
644<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
645 </ul></li>
646
647<li>Return Value:
648
649<ul>
650
651<li>the <tt>double</tt> cosine value for the argument,</li>
652
653<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
654
655<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
656
657<li>any other non-numeric input value will cause a type error.</li>
658 </ul></li>
659
660<li>
661<p>Example:</p>
662
663<div class="source">
664<div class="source">
665<pre>{ &quot;v1&quot;: cos(1), &quot;v2&quot;: cos(2), &quot;v3&quot;: cos(0), &quot;v4&quot;: cos(float(&quot;0.5&quot;)), &quot;v5&quot;: cos(double(&quot;1000&quot;)) };
666</pre></div></div></li>
667</ul>
668
669<ul>
670
671<li>
672<p>The expected result is:</p>
673
674<div class="source">
675<div class="source">
676<pre>{ &quot;v1&quot;: 0.5403023058681398, &quot;v2&quot;: -0.4161468365471424, &quot;v3&quot;: 1.0, &quot;v4&quot;: 0.8775825618903728, &quot;v5&quot;: 0.562379076290703 }
677</pre></div></div></li>
678</ul></div>
679<div class="section">
680<h3><a name="exp"></a>exp</h3>
681
682<ul>
683
684<li>
685<p>Syntax:</p>
686
687<div class="source">
688<div class="source">
689<pre>exp(numeric_value)
690</pre></div></div></li>
691
692<li>
693<p>Computes e<sup>numeric_value</sup>.</p></li>
694
695<li>Arguments:
696
697<ul>
698
699<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
700 </ul></li>
701
702<li>Return Value:
703
704<ul>
705
706<li>e<sup>numeric_value</sup>,</li>
707
708<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
709
710<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
711
712<li>any other non-numeric input value will cause a type error.</li>
713 </ul></li>
714
715<li>
716<p>Example:</p>
717
718<div class="source">
719<div class="source">
720<pre>{ &quot;v1&quot;: exp(1), &quot;v2&quot;: exp(2), &quot;v3&quot;: exp(0), &quot;v4&quot;: exp(float(&quot;0.5&quot;)), &quot;v5&quot;: exp(double(&quot;1000&quot;)) };
721</pre></div></div></li>
722</ul>
723
724<ul>
725
726<li>
727<p>The expected result is:</p>
728
729<div class="source">
730<div class="source">
731<pre>{ &quot;v1&quot;: 2.718281828459045, &quot;v2&quot;: 7.38905609893065, &quot;v3&quot;: 1.0, &quot;v4&quot;: 1.6487212707001282, &quot;v5&quot;: Infinity }
732</pre></div></div></li>
733</ul></div>
734<div class="section">
735<h3><a name="floor"></a>floor</h3>
736
737<ul>
738
739<li>
740<p>Syntax:</p>
741
742<div class="source">
743<div class="source">
744<pre>floor(numeric_value)
745</pre></div></div></li>
746
747<li>
748<p>Computes the largest (closest to positive infinity) number with no fractional part that is not greater than the value. If the argument is already equal to mathematical integer, then the result is the same as the argument.</p></li>
749
750<li>Arguments:
751
752<ul>
753
754<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
755 </ul></li>
756
757<li>Return Value:
758
759<ul>
760
761<li>The floor value for the given number in the same type as the input argument,</li>
762
763<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
764
765<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
766
767<li>any other non-numeric input value will cause a type error.</li>
768 </ul></li>
769
770<li>
771<p>Example:</p>
772
773<div class="source">
774<div class="source">
775<pre>{
776 &quot;v1&quot;: floor(2013),
777 &quot;v2&quot;: floor(-4036),
778 &quot;v3&quot;: floor(0.8),
779 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
780 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
781};
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;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 0.0, &quot;v4&quot;: -2014.0, &quot;v5&quot;: -2014.0 }
793</pre></div></div></li>
794</ul></div>
795<div class="section">
796<h3><a name="ln"></a>ln</h3>
797
798<ul>
799
800<li>
801<p>Syntax:</p>
802
803<div class="source">
804<div class="source">
805<pre>ln(numeric_value)
806</pre></div></div></li>
807
808<li>
809<p>Computes log<sub>e</sub>numeric_value.</p></li>
810
811<li>Arguments:
812
813<ul>
814
815<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
816 </ul></li>
817
818<li>Return Value:
819
820<ul>
821
822<li>log<sub>e</sub>numeric_value,</li>
823
824<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
825
826<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
827
828<li>any other non-numeric input value will cause a type error.</li>
829 </ul></li>
830
831<li>
832<p>Example:</p>
833
834<div class="source">
835<div class="source">
836<pre>{ &quot;v1&quot;: ln(1), &quot;v2&quot;: ln(2), &quot;v3&quot;: ln(0), &quot;v4&quot;: ln(float(&quot;0.5&quot;)), &quot;v5&quot;: ln(double(&quot;1000&quot;)) };
837</pre></div></div></li>
838</ul>
839
840<ul>
841
842<li>
843<p>The expected result is:</p>
844
845<div class="source">
846<div class="source">
847<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.6931471805599453, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -0.6931471805599453, &quot;v5&quot;: 6.907755278982137 }
848</pre></div></div></li>
849</ul></div>
850<div class="section">
851<h3><a name="log"></a>log</h3>
852
853<ul>
854
855<li>
856<p>Syntax:</p>
857
858<div class="source">
859<div class="source">
860<pre>log(numeric_value)
861</pre></div></div></li>
862
863<li>
864<p>Computes log<sub>10</sub>numeric_value.</p></li>
865
866<li>Arguments:
867
868<ul>
869
870<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
871 </ul></li>
872
873<li>Return Value:
874
875<ul>
876
877<li>log<sub>10</sub>numeric_value,</li>
878
879<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
880
881<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
882
883<li>any other non-numeric input value will cause a type error.</li>
884 </ul></li>
885
886<li>
887<p>Example:</p>
888
889<div class="source">
890<div class="source">
891<pre>{ &quot;v1&quot;: log(1), &quot;v2&quot;: log(2), &quot;v3&quot;: log(0), &quot;v4&quot;: log(float(&quot;0.5&quot;)), &quot;v5&quot;: log(double(&quot;1000&quot;)) };
892</pre></div></div></li>
893
894<li>
895<p>The expected result is:</p>
896
897<div class="source">
898<div class="source">
899<pre>{ &quot;v1&quot;: 0.0, &quot;v2&quot;: 0.3010299956639812, &quot;v3&quot;: -Infinity, &quot;v4&quot;: -0.3010299956639812, &quot;v5&quot;: 3.0 }
900</pre></div></div></li>
901</ul></div>
902<div class="section">
903<h3><a name="power"></a>power</h3>
904
905<ul>
906
907<li>
908<p>Syntax:</p>
909
910<div class="source">
911<div class="source">
912<pre>power(numeric_value1, numeric_value2)
913</pre></div></div></li>
914
915<li>
916<p>Computes numeric_value1<sup>numeric_value2</sup>.</p></li>
917
918<li>Arguments:
919
920<ul>
921
922<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
923
924<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
925 </ul></li>
926
927<li>Return Value:
928
929<ul>
930
931<li>numeric_value1<sup>numeric_value2</sup>,</li>
932
933<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
934
935<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
936
937<li>any other non-numeric input value will cause a type error.</li>
938 </ul></li>
939
940<li>
941<p>Example:</p>
942
943<div class="source">
944<div class="source">
945<pre>{ &quot;v1&quot;: power(1, 2), &quot;v3&quot;: power(0, 4), &quot;v4&quot;: power(float(&quot;0.5&quot;), double(&quot;-0.5&quot;)) };
946</pre></div></div></li>
947</ul>
948
949<ul>
950
951<li>
952<p>The expected result is:</p>
953
954<div class="source">
955<div class="source">
956<pre>{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
957</pre></div></div></li>
958</ul></div>
959<div class="section">
960<h3><a name="round"></a>round</h3>
961
962<ul>
963
964<li>
965<p>Syntax:</p>
966
967<div class="source">
968<div class="source">
969<pre>round(numeric_value)
970</pre></div></div></li>
971
972<li>
973<p>Computes the number with no fractional part that is closest (and also closest to positive infinity) to the argument.</p></li>
974
975<li>Arguments:
976
977<ul>
978
979<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
980 </ul></li>
981
982<li>Return Value:
983
984<ul>
985
986<li>The rounded value for the given number in the same type as the input argument,</li>
987
988<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
989
990<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
991
992<li>any other non-numeric input value will cause a type error.</li>
993 </ul></li>
994
995<li>
996<p>Example:</p>
997
998<div class="source">
999<div class="source">
1000<pre>{
1001 &quot;v1&quot;: round(2013),
1002 &quot;v2&quot;: round(-4036),
1003 &quot;v3&quot;: round(0.8),
1004 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1005 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1006};
1007</pre></div></div></li>
1008</ul>
1009
1010<ul>
1011
1012<li>
1013<p>The expected result is:</p>
1014
1015<div class="source">
1016<div class="source">
1017<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0 }
1018</pre></div></div></li>
1019</ul></div>
1020<div class="section">
1021<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1022
1023<ul>
1024
1025<li>
1026<p>Syntax:</p>
1027
1028<div class="source">
1029<div class="source">
1030<pre>round_half_to_even(numeric_value, [precision])
1031</pre></div></div></li>
1032
1033<li>
1034<p>Computes the closest numeric value to <tt>numeric_value</tt> that is a multiple of ten to the power of minus <tt>precision</tt>. <tt>precision</tt> is optional and by default value <tt>0</tt> is used.</p></li>
1035
1036<li>Arguments:
1037
1038<ul>
1039
1040<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1041
1042<li><tt>precision</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> field representing the number of digits in the fraction of the the result</li>
1043 </ul></li>
1044
1045<li>Return Value:
1046
1047<ul>
1048
1049<li>The rounded value for the given number in the same type as the input argument,</li>
1050
1051<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1052
1053<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1054
1055<li>a type error will be raised if:
1056
1057<ul>
1058
1059<li>the first argument is any other non-numeric value,</li>
1060
1061<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1062 </ul></li>
1063 </ul></li>
1064
1065<li>
1066<p>Example:</p>
1067
1068<div class="source">
1069<div class="source">
1070<pre>{
1071 &quot;v1&quot;: round_half_to_even(2013),
1072 &quot;v2&quot;: round_half_to_even(-4036),
1073 &quot;v3&quot;: round_half_to_even(0.8),
1074 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1075 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1076 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1077 &quot;v7&quot;: round_half_to_even(2013, 4),
1078 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1079};
1080</pre></div></div></li>
1081</ul>
1082
1083<ul>
1084
1085<li>
1086<p>The expected result is:</p>
1087
1088<div class="source">
1089<div class="source">
1090<pre>{ &quot;v1&quot;: 2013, &quot;v2&quot;: -4036, &quot;v3&quot;: 1.0, &quot;v4&quot;: -2013.0, &quot;v5&quot;: -2014.0, &quot;v6&quot;: -2013.89, &quot;v7&quot;: 2013, &quot;v8&quot;: -2013.256 }
1091</pre></div></div></li>
1092</ul></div>
1093<div class="section">
1094<h3><a name="sign"></a>sign</h3>
1095
1096<ul>
1097
1098<li>
1099<p>Syntax:</p>
1100
1101<div class="source">
1102<div class="source">
1103<pre>sign(numeric_value)
1104</pre></div></div></li>
1105
1106<li>
1107<p>Computes the sign of the argument.</p></li>
1108
1109<li>Arguments:
1110
1111<ul>
1112
1113<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1114 </ul></li>
1115
1116<li>Return Value:
1117
1118<ul>
1119
1120<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1121
1122<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1123
1124<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1125
1126<li>any other non-numeric input value will cause a type error.</li>
1127 </ul></li>
1128
1129<li>
1130<p>Example:</p>
1131
1132<div class="source">
1133<div class="source">
1134<pre>{ &quot;v1&quot;: sign(1), &quot;v2&quot;: sign(2), &quot;v3&quot;: sign(0), &quot;v4&quot;: sign(float(&quot;0.5&quot;)), &quot;v5&quot;: sign(double(&quot;-1000&quot;)) };
1135</pre></div></div></li>
1136</ul>
1137
1138<ul>
1139
1140<li>
1141<p>The expected result is:</p>
1142
1143<div class="source">
1144<div class="source">
1145<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1146</pre></div></div></li>
1147</ul></div>
1148<div class="section">
1149<h3><a name="sin"></a>sin</h3>
1150
1151<ul>
1152
1153<li>
1154<p>Syntax:</p>
1155
1156<div class="source">
1157<div class="source">
1158<pre>sin(numeric_value)
1159</pre></div></div></li>
1160
1161<li>
1162<p>Computes the sine value of the argument.</p></li>
1163
1164<li>Arguments:
1165
1166<ul>
1167
1168<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1169 </ul></li>
1170
1171<li>Return Value:
1172
1173<ul>
1174
1175<li>the <tt>double</tt> sine value for the argument,</li>
1176
1177<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1178
1179<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1180
1181<li>any other non-numeric input value will cause a type error.</li>
1182 </ul></li>
1183
1184<li>
1185<p>Example:</p>
1186
1187<div class="source">
1188<div class="source">
1189<pre>{ &quot;v1&quot;: sin(1), &quot;v2&quot;: sin(2), &quot;v3&quot;: sin(0), &quot;v4&quot;: sin(float(&quot;0.5&quot;)), &quot;v5&quot;: sin(double(&quot;1000&quot;)) };
1190</pre></div></div></li>
1191</ul>
1192
1193<ul>
1194
1195<li>
1196<p>The expected result is:</p>
1197
1198<div class="source">
1199<div class="source">
1200<pre>{ &quot;v1&quot;: 0.8414709848078965, &quot;v2&quot;: 0.9092974268256817, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.479425538604203, &quot;v5&quot;: 0.8268795405320025 }
1201</pre></div></div></li>
1202</ul></div>
1203<div class="section">
1204<h3><a name="sqrt"></a>sqrt</h3>
1205
1206<ul>
1207
1208<li>
1209<p>Syntax:</p>
1210
1211<div class="source">
1212<div class="source">
1213<pre>sqrt(numeric_value)
1214</pre></div></div></li>
1215
1216<li>
1217<p>Computes the square root of the argument.</p></li>
1218
1219<li>Arguments:
1220
1221<ul>
1222
1223<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1224 </ul></li>
1225
1226<li>Return Value:
1227
1228<ul>
1229
1230<li>the <tt>double</tt> square root value for the argument,</li>
1231
1232<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1233
1234<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1235
1236<li>any other non-numeric input value will cause a type error.</li>
1237 </ul></li>
1238
1239<li>
1240<p>Example:</p>
1241
1242<div class="source">
1243<div class="source">
1244<pre>{ &quot;v1&quot;: sqrt(1), &quot;v2&quot;: sqrt(2), &quot;v3&quot;: sqrt(0), &quot;v4&quot;: sqrt(float(&quot;0.5&quot;)), &quot;v5&quot;: sqrt(double(&quot;1000&quot;)) };
1245</pre></div></div></li>
1246</ul>
1247
1248<ul>
1249
1250<li>
1251<p>The expected result is:</p>
1252
1253<div class="source">
1254<div class="source">
1255<pre>{ &quot;v1&quot;: 1.0, &quot;v2&quot;: 1.4142135623730951, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.7071067811865476, &quot;v5&quot;: 31.622776601683793 }
1256</pre></div></div></li>
1257</ul></div>
1258<div class="section">
1259<h3><a name="tan"></a>tan</h3>
1260
1261<ul>
1262
1263<li>
1264<p>Syntax:</p>
1265
1266<div class="source">
1267<div class="source">
1268<pre>tan(numeric_value)
1269</pre></div></div></li>
1270
1271<li>
1272<p>Computes the tangent value of the argument.</p></li>
1273
1274<li>Arguments:
1275
1276<ul>
1277
1278<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1279 </ul></li>
1280
1281<li>Return Value:
1282
1283<ul>
1284
1285<li>the <tt>double</tt> tangent value for the argument,</li>
1286
1287<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1288
1289<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1290
1291<li>any other non-numeric input value will cause a type error.</li>
1292 </ul></li>
1293
1294<li>
1295<p>Example:</p>
1296
1297<div class="source">
1298<div class="source">
1299<pre>{ &quot;v1&quot;: tan(1), &quot;v2&quot;: tan(2), &quot;v3&quot;: tan(0), &quot;v4&quot;: tan(float(&quot;0.5&quot;)), &quot;v5&quot;: tan(double(&quot;1000&quot;)) };
1300</pre></div></div></li>
1301</ul>
1302
1303<ul>
1304
1305<li>
1306<p>The expected result is:</p>
1307
1308<div class="source">
1309<div class="source">
1310<pre>{ &quot;v1&quot;: 1.5574077246549023, &quot;v2&quot;: -2.185039863261519, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5463024898437905, &quot;v5&quot;: 1.4703241557027185 }
1311</pre></div></div></li>
1312</ul></div>
1313<div class="section">
1314<h3><a name="trunc"></a>trunc</h3>
1315
1316<ul>
1317
1318<li>
1319<p>Syntax:</p>
1320
1321<div class="source">
1322<div class="source">
1323<pre>trunc(numeric_value, number_digits)
1324</pre></div></div></li>
1325
1326<li>
1327<p>Truncates the number to the given number of integer digits to the right of the decimal point (left if digits is negative). Digits is 0 if not given.</p></li>
1328
1329<li>Arguments:
1330
1331<ul>
1332
1333<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
1334
1335<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1336 </ul></li>
1337
1338<li>Return Value:
1339
1340<ul>
1341
1342<li>the <tt>double</tt> tangent value for the argument,</li>
1343
1344<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1345
1346<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1347
1348<li>a type error will be raised if:
1349
1350<ul>
1351
1352<li>the first argument is any other non-numeric value,</li>
1353
1354<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1355 </ul></li>
1356 </ul></li>
1357
1358<li>
1359<p>Example:</p>
1360
1361<div class="source">
1362<div class="source">
1363<pre>{ &quot;v1&quot;: trunc(1, 1), &quot;v2&quot;: trunc(2, -2), &quot;v3&quot;: trunc(0.122, 2), &quot;v4&quot;: trunc(float(&quot;11.52&quot;), -1), &quot;v5&quot;: trunc(double(&quot;1000.5252&quot;), 3) };
1364</pre></div></div></li>
1365</ul>
1366
1367<ul>
1368
1369<li>
1370<p>The expected result is:</p>
1371
1372<div class="source">
1373<div class="source">
1374<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: 2, &quot;v3&quot;: 0.12, &quot;v4&quot;: 10.0, &quot;v5&quot;: 1000.525 }
1375</pre></div></div></li>
1376</ul>
1377<!-- ! Licensed to the Apache Software Foundation (ASF) under one
1378 ! or more contributor license agreements. See the NOTICE file
1379 ! distributed with this work for additional information
1380 ! regarding copyright ownership. The ASF licenses this file
1381 ! to you under the Apache License, Version 2.0 (the
1382 ! "License"); you may not use this file except in compliance
1383 ! with the License. You may obtain a copy of the License at
1384 !
1385 ! http://www.apache.org/licenses/LICENSE-2.0
1386 !
1387 ! Unless required by applicable law or agreed to in writing,
1388 ! software distributed under the License is distributed on an
1389 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1390 ! KIND, either express or implied. See the License for the
1391 ! specific language governing permissions and limitations
1392 ! under the License.
1393 ! --></div></div>
1394<div class="section">
1395<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1396<div class="section">
1397<h3><a name="concat"></a>concat</h3>
1398
1399<ul>
1400
1401<li>
1402<p>Syntax:</p>
1403
1404<div class="source">
1405<div class="source">
1406<pre>concat(string1, string2, ...)
1407</pre></div></div></li>
1408
1409<li>
1410<p>Returns a concatenated string from arguments.</p></li>
1411
1412<li>Arguments:
1413
1414<ul>
1415
1416<li><tt>string1</tt>: a string value,</li>
1417
1418<li><tt>string2</tt>: a string value,</li>
1419
1420<li>&#x2026;.</li>
1421 </ul></li>
1422
1423<li>Return Value:
1424
1425<ul>
1426
1427<li>a concatenated string from arguments,</li>
1428
1429<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1430
1431<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1432
1433<li>any other non-string input value will cause a type error.</li>
1434 </ul></li>
1435
1436<li>
1437<p>Example:</p>
1438
1439<div class="source">
1440<div class="source">
1441<pre>concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1442</pre></div></div></li>
1443</ul>
1444
1445<ul>
1446
1447<li>
1448<p>The expected result is:</p>
1449
1450<div class="source">
1451<div class="source">
1452<pre>&quot;test driven development&quot;
1453</pre></div></div></li>
1454</ul></div>
1455<div class="section">
1456<h3><a name="contains"></a>contains</h3>
1457
1458<ul>
1459
1460<li>
1461<p>Syntax:</p>
1462
1463<div class="source">
1464<div class="source">
1465<pre>contains(string, substring_to_contain)
1466</pre></div></div></li>
1467
1468<li>
1469<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p></li>
1470
1471<li>Arguments:
1472
1473<ul>
1474
1475<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1476
1477<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1478 </ul></li>
1479
1480<li>Return Value:
1481
1482<ul>
1483
1484<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1485
1486<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1487
1488<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1489
1490<li>any other non-string input value will cause a type error,</li>
1491
1492<li><tt>false</tt> otherwise.</li>
1493 </ul></li>
1494
1495<li>
1496<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p></li>
1497
1498<li>
1499<p>Example:</p>
1500
1501<div class="source">
1502<div class="source">
1503<pre>{ &quot;v1&quot;: contains(&quot;I like iphone&quot;, &quot;phone&quot;), &quot;v2&quot;: contains(&quot;one&quot;, &quot;phone&quot;) };
1504</pre></div></div></li>
1505</ul>
1506
1507<ul>
1508
1509<li>
1510<p>The expected result is:</p>
1511
1512<div class="source">
1513<div class="source">
1514<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1515</pre></div></div></li>
1516</ul></div>
1517<div class="section">
1518<h3><a name="ends_with"></a>ends_with</h3>
1519
1520<ul>
1521
1522<li>
1523<p>Syntax:</p>
1524
1525<div class="source">
1526<div class="source">
1527<pre>ends_with(string, substring_to_end_with)
1528</pre></div></div></li>
1529
1530<li>
1531<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p></li>
1532
1533<li>Arguments:
1534
1535<ul>
1536
1537<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1538
1539<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1540 </ul></li>
1541
1542<li>Return Value:
1543
1544<ul>
1545
1546<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1547
1548<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1549
1550<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1551
1552<li>any other non-string input value will cause a type error,</li>
1553
1554<li><tt>false</tt> otherwise.</li>
1555 </ul></li>
1556
1557<li>
1558<p>Example:</p>
1559
1560<div class="source">
1561<div class="source">
1562<pre>{
1563 &quot;v1&quot;: ends_with(&quot; love sprint its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1564 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1565};
1566</pre></div></div></li>
1567</ul>
1568
1569<ul>
1570
1571<li>
1572<p>The expected result is:</p>
1573
1574<div class="source">
1575<div class="source">
1576<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1577</pre></div></div></li>
1578</ul></div>
1579<div class="section">
1580<h3><a name="initcap_or_title"></a>initcap (or title)</h3>
1581
1582<ul>
1583
1584<li>
1585<p>Syntax:</p>
1586
1587<div class="source">
1588<div class="source">
1589<pre>initcap(string)
1590</pre></div></div></li>
1591
1592<li>
1593<p>Converts a given string <tt>string</tt> so that the first letter of each word is uppercase and every other letter is lowercase. The function has an alias called &#x201c;title&#x201d;.</p></li>
1594
1595<li>Arguments:
1596
1597<ul>
1598
1599<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1600 </ul></li>
1601
1602<li>Return Value:
1603
1604<ul>
1605
1606<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1607
1608<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1609
1610<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1611
1612<li>any other non-string input value will cause a type error.</li>
1613 </ul></li>
1614
1615<li>
1616<p>Example:</p>
1617
1618<div class="source">
1619<div class="source">
1620<pre>{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1621</pre></div></div></li>
1622</ul>
1623
1624<ul>
1625
1626<li>
1627<p>The expected result is:</p>
1628
1629<div class="source">
1630<div class="source">
1631<pre>{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1632</pre></div></div></li>
1633</ul></div>
1634<div class="section">
1635<h3><a name="length"></a>length</h3>
1636
1637<ul>
1638
1639<li>
1640<p>Syntax:</p>
1641
1642<div class="source">
1643<div class="source">
1644<pre>length(string)
1645</pre></div></div></li>
1646
1647<li>
1648<p>Returns the length of the string <tt>string</tt>.</p></li>
1649
1650<li>Arguments:
1651
1652<ul>
1653
1654<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1655 </ul></li>
1656
1657<li>Return Value:
1658
1659<ul>
1660
1661<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1662
1663<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1664
1665<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1666
1667<li>any other non-string input value will cause a type error.</li>
1668 </ul></li>
1669
1670<li>
1671<p>Example:</p>
1672
1673<div class="source">
1674<div class="source">
1675<pre>length(&quot;test string&quot;);
1676</pre></div></div></li>
1677</ul>
1678
1679<ul>
1680
1681<li>
1682<p>The expected result is:</p>
1683
1684<div class="source">
1685<div class="source">
1686<pre>11
1687</pre></div></div></li>
1688</ul></div>
1689<div class="section">
1690<h3><a name="lower"></a>lower</h3>
1691
1692<ul>
1693
1694<li>
1695<p>Syntax:</p>
1696
1697<div class="source">
1698<div class="source">
1699<pre>lower(string)
1700</pre></div></div></li>
1701
1702<li>
1703<p>Converts a given string <tt>string</tt> to its lowercase form.</p></li>
1704
1705<li>Arguments:
1706
1707<ul>
1708
1709<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1710 </ul></li>
1711
1712<li>Return Value:
1713
1714<ul>
1715
1716<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1717
1718<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1719
1720<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1721
1722<li>any other non-string input value will cause a type error.</li>
1723 </ul></li>
1724
1725<li>
1726<p>Example:</p>
1727
1728<div class="source">
1729<div class="source">
1730<pre>lower(&quot;ASTERIXDB&quot;);
1731</pre></div></div></li>
1732</ul>
1733
1734<ul>
1735
1736<li>
1737<p>The expected result is:</p>
1738
1739<div class="source">
1740<div class="source">
1741<pre>&quot;asterixdb&quot;
1742</pre></div></div></li>
1743</ul></div>
1744<div class="section">
1745<h3><a name="ltrim"></a>ltrim</h3>
1746
1747<ul>
1748
1749<li>
1750<p>Syntax:</p>
1751
1752<div class="source">
1753<div class="source">
1754<pre>ltrim(string[, chars]);
1755</pre></div></div></li>
1756
1757<li>
1758<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p></li>
1759
1760<li>Arguments:
1761
1762<ul>
1763
1764<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1765
1766<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1767 </ul></li>
1768
1769<li>Return Value:
1770
1771<ul>
1772
1773<li>a trimmed, new <tt>string</tt>,</li>
1774
1775<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1776
1777<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1778
1779<li>any other non-string input value will cause a type error.</li>
1780 </ul></li>
1781</ul>
1782
1783<ul>
1784
1785<li>
1786<p>Example:</p>
1787
1788<div class="source">
1789<div class="source">
1790<pre>ltrim(&quot;me like iphone&quot;, &quot;eml&quot;);
1791</pre></div></div></li>
1792</ul>
1793
1794<ul>
1795
1796<li>
1797<p>The expected result is:</p>
1798
1799<div class="source">
1800<div class="source">
1801<pre>&quot; like iphone&quot;
1802</pre></div></div></li>
1803</ul></div>
1804<div class="section">
1805<h3><a name="position"></a>position</h3>
1806
1807<ul>
1808
1809<li>
1810<p>Syntax:</p>
1811
1812<div class="source">
1813<div class="source">
1814<pre>position(string, string_pattern)
1815</pre></div></div></li>
1816
1817<li>
1818<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>.</p></li>
1819
1820<li>Arguments:
1821
1822<ul>
1823
1824<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern,</li>
1825
1826<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
1827 </ul></li>
1828
1829<li>Return Value:
1830
1831<ul>
1832
1833<li>the first position that <tt>string_pattern</tt> appears within <tt>string</tt>, or -1 if it does not appear,</li>
1834
1835<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1836
1837<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1838
1839<li>any other non-string input value will cause a type error.</li>
1840 </ul></li>
1841
1842<li>
1843<p>Example:</p>
1844
1845<div class="source">
1846<div class="source">
1847<pre>{
1848 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
1849 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;)
1850};
1851</pre></div></div></li>
1852</ul>
1853
1854<ul>
1855
1856<li>
1857<p>The expected result is:</p>
1858
1859<div class="source">
1860<div class="source">
1861<pre>{ &quot;v1&quot;: 2, &quot;v2&quot;: -1 }
1862</pre></div></div></li>
1863</ul></div>
1864<div class="section">
1865<h3><a name="regexp_contains"></a>regexp_contains</h3>
1866
1867<ul>
1868
1869<li>
1870<p>Syntax:</p>
1871
1872<div class="source">
1873<div class="source">
1874<pre>regexp_contains(string, string_pattern[, string_flags])
1875</pre></div></div></li>
1876
1877<li>
1878<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p></li>
1879
1880<li>Arguments:
1881
1882<ul>
1883
1884<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern,</li>
1885
1886<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched,</li>
1887
1888<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
1889
1890<ul>
1891
1892<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
1893 </ul></li>
1894 </ul></li>
1895
1896<li>Return Value:
1897
1898<ul>
1899
1900<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>,</li>
1901
1902<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1903
1904<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1905
1906<li>any other non-string input value will cause a type error,</li>
1907
1908<li><tt>false</tt> otherwise.</li>
1909 </ul></li>
1910
1911<li>
1912<p>Example:</p>
1913
1914<div class="source">
1915<div class="source">
1916<pre>{
1917 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
1918 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
1919}
1920</pre></div></div></li>
1921</ul>
1922
1923<ul>
1924
1925<li>
1926<p>The expected result is:</p>
1927
1928<div class="source">
1929<div class="source">
1930<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1931</pre></div></div></li>
1932</ul></div>
1933<div class="section">
1934<h3><a name="regexp_like"></a>regexp_like</h3>
1935
1936<ul>
1937
1938<li>
1939<p>Syntax:</p>
1940
1941<div class="source">
1942<div class="source">
1943<pre>regexp_like(string, string_pattern[, string_flags])
1944</pre></div></div></li>
1945
1946<li>
1947<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p></li>
1948
1949<li>Arguments:
1950
1951<ul>
1952
1953<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern,</li>
1954
1955<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained,</li>
1956
1957<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
1958
1959<ul>
1960
1961<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
1962 </ul></li>
1963 </ul></li>
1964
1965<li>Return Value:
1966
1967<ul>
1968
1969<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>,</li>
1970
1971<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1972
1973<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1974
1975<li>any other non-string input value will cause a type error,</li>
1976
1977<li><tt>false</tt> otherwise.</li>
1978 </ul></li>
1979
1980<li>
1981<p>Example:</p>
1982
1983<div class="source">
1984<div class="source">
1985<pre>{
1986 &quot;v1&quot;: regexp_like(&quot; can't stand at&amp;t the network is horrible:(&quot;, &quot;.*at&amp;t.*&quot;),
1987 &quot;v2&quot;: regexp_like(&quot;at&amp;t&quot;, &quot;.*att.*&quot;)
1988};
1989</pre></div></div></li>
1990
1991<li>
1992<p>The expected result is:</p>
1993
1994<div class="source">
1995<div class="source">
1996<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1997</pre></div></div></li>
1998</ul></div>
1999<div class="section">
2000<h3><a name="regexp_position"></a>regexp_position</h3>
2001
2002<ul>
2003
2004<li>
2005<p>Syntax:</p>
2006
2007<div class="source">
2008<div class="source">
2009<pre>regexp_position(string, string_pattern[, string_flags])
2010</pre></div></div></li>
2011
2012<li>
2013<p>Returns first position of the regular expression <tt>string_pattern</tt> (a Java regular expression pattern) within <tt>string</tt>.</p></li>
2014
2015<li>Arguments:
2016
2017<ul>
2018
2019<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern,</li>
2020
2021<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched,</li>
2022
2023<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2024
2025<ul>
2026
2027<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2028 </ul></li>
2029 </ul></li>
2030
2031<li>Return Value:
2032
2033<ul>
2034
2035<li>the first position that the regular expression <tt>string_pattern</tt> appears in <tt>string</tt>, or -1 if it does not appear.</li>
2036
2037<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2038
2039<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2040
2041<li>any other non-string input value will cause a type error.</li>
2042 </ul></li>
2043
2044<li>
2045<p>Example:</p>
2046
2047<div class="source">
2048<div class="source">
2049<pre>{
2050 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2051 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;)
2052};
2053</pre></div></div></li>
2054</ul>
2055
2056<ul>
2057
2058<li>
2059<p>The expected result is:</p>
2060
2061<div class="source">
2062<div class="source">
2063<pre>{ &quot;v1&quot;: 0, &quot;v2&quot;: -1 }
2064</pre></div></div></li>
2065</ul></div>
2066<div class="section">
2067<h3><a name="regexp_replace"></a>regexp_replace</h3>
2068
2069<ul>
2070
2071<li>
2072<p>Syntax:</p>
2073
2074<div class="source">
2075<div class="source">
2076<pre>regexp_replace(string, string_pattern, string_replacement[, string_flags])
2077</pre></div></div></li>
2078
2079<li>
2080<p>Checks whether the string <tt>string</tt> matches the given regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern), and replace the matched pattern <tt>string_pattern</tt> with the new pattern <tt>string_replacement</tt>.</p></li>
2081
2082<li>Arguments:
2083
2084<ul>
2085
2086<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern,</li>
2087
2088<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched,</li>
2089
2090<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement,</li>
2091
2092<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2093
2094<ul>
2095
2096<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2097 </ul></li>
2098 </ul></li>
2099
2100<li>Return Value:
2101
2102<ul>
2103
2104<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2105
2106<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2107
2108<li>any other non-string input value will cause a type error,</li>
2109
2110<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2111 </ul></li>
2112
2113<li>
2114<p>Example:</p>
2115
2116<div class="source">
2117<div class="source">
2118<pre>regexp_replace(&quot; like iphone the voicemail_service is awesome&quot;, &quot; like iphone&quot;, &quot;like android&quot;)
2119</pre></div></div></li>
2120</ul>
2121
2122<ul>
2123
2124<li>
2125<p>The expected result is:</p>
2126
2127<div class="source">
2128<div class="source">
2129<pre>&quot;like android the voicemail_service is awesome&quot;
2130</pre></div></div></li>
2131</ul></div>
2132<div class="section">
2133<h3><a name="repeat"></a>repeat</h3>
2134
2135<ul>
2136
2137<li>
2138<p>Syntax:</p>
2139
2140<div class="source">
2141<div class="source">
2142<pre>repeat(string, n)
2143</pre></div></div></li>
2144
2145<li>
2146<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p></li>
2147
2148<li>Arguments:
2149
2150<ul>
2151
2152<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2153
2154<li><tt>offset</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the starting offset of the substring in <tt>string</tt>.</li>
2155 </ul></li>
2156
2157<li>Return Value:
2158
2159<ul>
2160
2161<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2162
2163<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2164
2165<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2166
2167<li>a type error will be raised if:
2168
2169<ul>
2170
2171<li>the first argument is any other non-string value,</li>
2172
2173<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2174 </ul></li>
2175 </ul></li>
2176
2177<li>
2178<p>Example:</p>
2179
2180<div class="source">
2181<div class="source">
2182<pre>repeat(&quot;test&quot;, 3);
2183</pre></div></div></li>
2184</ul>
2185
2186<ul>
2187
2188<li>
2189<p>The expected result is:</p>
2190
2191<div class="source">
2192<div class="source">
2193<pre>&quot;testtesttest&quot;
2194</pre></div></div></li>
2195</ul></div>
2196<div class="section">
2197<h3><a name="rtrim"></a>rtrim</h3>
2198
2199<ul>
2200
2201<li>
2202<p>Syntax:</p>
2203
2204<div class="source">
2205<div class="source">
2206<pre>rtrim(string[, chars]);
2207</pre></div></div></li>
2208
2209<li>
2210<p>Returns a new string with all trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p></li>
2211
2212<li>Arguments:
2213
2214<ul>
2215
2216<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2217
2218<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2219 </ul></li>
2220
2221<li>Return Value:
2222
2223<ul>
2224
2225<li>a trimmed, new <tt>string</tt>,</li>
2226
2227<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2228
2229<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2230
2231<li>any other non-string input value will cause a type error.</li>
2232 </ul></li>
2233</ul>
2234
2235<ul>
2236
2237<li>
2238<p>Example:</p>
2239
2240<div class="source">
2241<div class="source">
2242<pre>{
2243 &quot;v1&quot;: rtrim(&quot;i like iphone&quot;, &quot;iphone&quot;),
2244 &quot;v2&quot;: rtrim(&quot;i like iphone&quot;, &quot;oneiph&quot;)
2245};
2246</pre></div></div></li>
2247
2248<li>
2249<p>The expected result is:</p>
2250
2251<div class="source">
2252<div class="source">
2253<pre>{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like &quot; }
2254</pre></div></div></li>
2255</ul></div>
2256<div class="section">
2257<h3><a name="split"></a>split</h3>
2258
2259<ul>
2260
2261<li>
2262<p>Syntax:</p>
2263
2264<div class="source">
2265<div class="source">
2266<pre>split(string, sep)
2267</pre></div></div></li>
2268
2269<li>
2270<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p></li>
2271
2272<li>Arguments:
2273
2274<ul>
2275
2276<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2277 </ul></li>
2278
2279<li>Return Value:
2280
2281<ul>
2282
2283<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2284
2285<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2286
2287<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2288
2289<li>any other non-string input value will cause a type error.</li>
2290 </ul></li>
2291
2292<li>
2293<p>Example:</p>
2294
2295<div class="source">
2296<div class="source">
2297<pre>split(&quot;test driven development&quot;, &quot; &quot;);
2298</pre></div></div></li>
2299</ul>
2300
2301<ul>
2302
2303<li>
2304<p>The expected result is:</p>
2305
2306<div class="source">
2307<div class="source">
2308<pre>[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2309</pre></div></div></li>
2310</ul></div>
2311<div class="section">
2312<h3><a name="starts_with"></a>starts_with</h3>
2313
2314<ul>
2315
2316<li>
2317<p>Syntax:</p>
2318
2319<div class="source">
2320<div class="source">
2321<pre>starts_with(string, substring_to_start_with)
2322</pre></div></div></li>
2323
2324<li>
2325<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p></li>
2326
2327<li>Arguments:
2328
2329<ul>
2330
2331<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2332
2333<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2334 </ul></li>
2335
2336<li>Return Value:
2337
2338<ul>
2339
2340<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2341
2342<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2343
2344<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2345
2346<li>any other non-string input value will cause a type error,</li>
2347
2348<li><tt>false</tt> otherwise.</li>
2349 </ul></li>
2350
2351<li>
2352<p>Example:</p>
2353
2354<div class="source">
2355<div class="source">
2356<pre>{
2357 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2358 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2359};
2360</pre></div></div></li>
2361</ul>
2362
2363<ul>
2364
2365<li>
2366<p>The expected result is:</p>
2367
2368<div class="source">
2369<div class="source">
2370<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2371</pre></div></div></li>
2372</ul></div>
2373<div class="section">
2374<h3><a name="string_concat"></a>string_concat</h3>
2375
2376<ul>
2377
2378<li>
2379<p>Syntax:</p>
2380
2381<div class="source">
2382<div class="source">
2383<pre>string_concat(array)
2384</pre></div></div></li>
2385
2386<li>
2387<p>Concatenates an array of strings <tt>array</tt> into a single string.</p></li>
2388
2389<li>Arguments:
2390
2391<ul>
2392
2393<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of <tt>string</tt>s (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
2394 </ul></li>
2395
2396<li>Return Value:
2397
2398<ul>
2399
2400<li>the concatenated <tt>string</tt> value,</li>
2401
2402<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2403
2404<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2405
2406<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2407
2408<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
2409
2410<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2411 </ul></li>
2412
2413<li>
2414<p>Example:</p>
2415
2416<div class="source">
2417<div class="source">
2418<pre>string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2419</pre></div></div></li>
2420</ul>
2421
2422<ul>
2423
2424<li>
2425<p>The expected result is:</p>
2426
2427<div class="source">
2428<div class="source">
2429<pre>&quot;ASTERIX ROCKS!&quot;
2430</pre></div></div></li>
2431</ul></div>
2432<div class="section">
2433<h3><a name="string_join"></a>string_join</h3>
2434
2435<ul>
2436
2437<li>
2438<p>Syntax:</p>
2439
2440<div class="source">
2441<div class="source">
2442<pre>string_join(array, string)
2443</pre></div></div></li>
2444
2445<li>
2446<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p></li>
2447
2448<li>Arguments:
2449
2450<ul>
2451
2452<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
2453
2454<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
2455 </ul></li>
2456
2457<li>Return Value:
2458
2459<ul>
2460
2461<li>the joined <tt>string</tt>,</li>
2462
2463<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2464
2465<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2466
2467<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
2468
2469<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
2470
2471<li>a type error will be raised if:
2472
2473<ul>
2474
2475<li>the first argument is any other non-array value, or contains any other non-string value,</li>
2476
2477<li>or, the second argument is any other non-string value.</li>
2478 </ul></li>
2479 </ul></li>
2480
2481<li>
2482<p>Example:</p>
2483
2484<div class="source">
2485<div class="source">
2486<pre>string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
2487</pre></div></div></li>
2488</ul>
2489
2490<ul>
2491
2492<li>
2493<p>The expected result is:</p>
2494
2495<div class="source">
2496<div class="source">
2497<pre>&quot;ASTERIX!! ROCKS~&quot;
2498</pre></div></div></li>
2499</ul></div>
2500<div class="section">
2501<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
2502
2503<ul>
2504
2505<li>
2506<p>Syntax:</p>
2507
2508<div class="source">
2509<div class="source">
2510<pre>string_to_codepoint(string)
2511</pre></div></div></li>
2512
2513<li>
2514<p>Converts the string <tt>string</tt> to its code_based representation.</p></li>
2515
2516<li>Arguments:
2517
2518<ul>
2519
2520<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
2521 </ul></li>
2522
2523<li>Return Value:
2524
2525<ul>
2526
2527<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
2528
2529<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2530
2531<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2532
2533<li>any other non-string input value will cause a type error.</li>
2534 </ul></li>
2535
2536<li>
2537<p>Example:</p>
2538
2539<div class="source">
2540<div class="source">
2541<pre>string_to_codepoint(&quot;Hello ASTERIX!&quot;);
2542</pre></div></div></li>
2543</ul>
2544
2545<ul>
2546
2547<li>
2548<p>The expected result is:</p>
2549
2550<div class="source">
2551<div class="source">
2552<pre>[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
2553</pre></div></div></li>
2554</ul></div>
2555<div class="section">
2556<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
2557
2558<ul>
2559
2560<li>
2561<p>Syntax:</p>
2562
2563<div class="source">
2564<div class="source">
2565<pre>codepoint_to_string(array)
2566</pre></div></div></li>
2567
2568<li>
2569<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p></li>
2570
2571<li>Arguments:
2572
2573<ul>
2574
2575<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
2576 </ul></li>
2577
2578<li>Return Value:
2579
2580<ul>
2581
2582<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
2583
2584<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2585
2586<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2587
2588<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2589
2590<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
2591
2592<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2593 </ul></li>
2594
2595<li>
2596<p>Example:</p>
2597
2598<div class="source">
2599<div class="source">
2600<pre>codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
2601</pre></div></div></li>
2602</ul>
2603
2604<ul>
2605
2606<li>
2607<p>The expected result is:</p>
2608
2609<div class="source">
2610<div class="source">
2611<pre>&quot;Hello ASTERIX!&quot;
2612</pre></div></div></li>
2613</ul></div>
2614<div class="section">
2615<h3><a name="substr"></a>substr</h3>
2616
2617<ul>
2618
2619<li>
2620<p>Syntax:</p>
2621
2622<div class="source">
2623<div class="source">
2624<pre>substr(string, offset[, length])
2625</pre></div></div></li>
2626
2627<li>
2628<p>Returns the substring from the given string <tt>string</tt> based on the given start offset <tt>offset</tt> with the optional <tt>length</tt>.</p></li>
2629
2630<li>Arguments:
2631
2632<ul>
2633
2634<li><tt>string</tt> : a <tt>string</tt> to be extracted,</li>
2635
2636<li><tt>offset</tt> : an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the starting offset of the substring in <tt>string</tt>,</li>
2637
2638<li><tt>length</tt> : (Optional) an an <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value as the length of the substring.</li>
2639 </ul></li>
2640
2641<li>Return Value:
2642
2643<ul>
2644
2645<li>a <tt>string</tt> that represents the substring,</li>
2646
2647<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2648
2649<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2650
2651<li>a type error will be raised if:
2652
2653<ul>
2654
2655<li>the first argument is any other non-string value,</li>
2656
2657<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>,</li>
2658
2659<li>or, the third argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> if the argument is present.</li>
2660 </ul></li>
2661 </ul></li>
2662
2663<li>
2664<p>Example:</p>
2665
2666<div class="source">
2667<div class="source">
2668<pre>substr(&quot;test string&quot;, 6, 3);
2669</pre></div></div></li>
2670</ul>
2671
2672<ul>
2673
2674<li>
2675<p>The expected result is:</p>
2676
2677<div class="source">
2678<div class="source">
2679<pre>&quot;str&quot;
2680</pre></div></div></li>
2681</ul></div>
2682<div class="section">
2683<h3><a name="substring_before"></a>substring_before</h3>
2684
2685<ul>
2686
2687<li>
2688<p>Syntax:</p>
2689
2690<div class="source">
2691<div class="source">
2692<pre>substring_before(string, string_pattern)
2693</pre></div></div></li>
2694
2695<li>
2696<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p></li>
2697
2698<li>Arguments:
2699
2700<ul>
2701
2702<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2703
2704<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
2705 </ul></li>
2706
2707<li>Return Value:
2708
2709<ul>
2710
2711<li>a <tt>string</tt> that represents the substring,</li>
2712
2713<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2714
2715<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2716
2717<li>any other non-string input value will cause a type error.</li>
2718 </ul></li>
2719
2720<li>
2721<p>Example:</p>
2722
2723<div class="source">
2724<div class="source">
2725<pre>substring_before(&quot; like iphone&quot;, &quot;iphone&quot;);
2726</pre></div></div></li>
2727</ul>
2728
2729<ul>
2730
2731<li>
2732<p>The expected result is:</p>
2733
2734<div class="source">
2735<div class="source">
2736<pre>&quot; like &quot;
2737</pre></div></div></li>
2738</ul></div>
2739<div class="section">
2740<h3><a name="substring_after"></a>substring_after</h3>
2741
2742<ul>
2743
2744<li>
2745<p>Syntax:</p>
2746<p>substring_after(string, string_pattern);</p></li>
2747
2748<li>
2749<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p></li>
2750
2751<li>Arguments:
2752
2753<ul>
2754
2755<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2756
2757<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
2758 </ul></li>
2759
2760<li>Return Value:
2761
2762<ul>
2763
2764<li>a <tt>string</tt> that represents the substring,</li>
2765
2766<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2767
2768<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2769
2770<li>any other non-string input value will cause a type error.</li>
2771 </ul></li>
2772</ul>
2773
2774<ul>
2775
2776<li>
2777<p>Example:</p>
2778
2779<div class="source">
2780<div class="source">
2781<pre>substring_after(&quot; like iphone&quot;, &quot;iph&quot;);
2782</pre></div></div></li>
2783</ul>
2784
2785<ul>
2786
2787<li>
2788<p>The expected result is:</p>
2789
2790<div class="source">
2791<div class="source">
2792<pre>&quot;one&quot;
2793</pre></div></div></li>
2794</ul></div>
2795<div class="section">
2796<h3><a name="trim"></a>trim</h3>
2797
2798<ul>
2799
2800<li>
2801<p>Syntax:</p>
2802
2803<div class="source">
2804<div class="source">
2805<pre>trim(string[, chars]);
2806</pre></div></div></li>
2807
2808<li>
2809<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p></li>
2810
2811<li>Arguments:
2812
2813<ul>
2814
2815<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2816
2817<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2818 </ul></li>
2819
2820<li>Return Value:
2821
2822<ul>
2823
2824<li>a trimmed, new <tt>string</tt>,</li>
2825
2826<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2827
2828<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2829
2830<li>any other non-string input value will cause a type error.</li>
2831 </ul></li>
2832</ul>
2833
2834<ul>
2835
2836<li>
2837<p>Example:</p>
2838
2839<div class="source">
2840<div class="source">
2841<pre>trim(&quot;i like iphone&quot;, &quot;iphoen&quot;);
2842</pre></div></div></li>
2843</ul>
2844
2845<ul>
2846
2847<li>
2848<p>The expected result is:</p>
2849
2850<div class="source">
2851<div class="source">
2852<pre>&quot; like &quot;
2853</pre></div></div></li>
2854</ul></div>
2855<div class="section">
2856<h3><a name="upper"></a>upper</h3>
2857
2858<ul>
2859
2860<li>
2861<p>Syntax:</p>
2862
2863<div class="source">
2864<div class="source">
2865<pre>upper(string)
2866</pre></div></div></li>
2867
2868<li>
2869<p>Converts a given string <tt>string</tt> to its uppercase form.</p></li>
2870
2871<li>Arguments:
2872
2873<ul>
2874
2875<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2876 </ul></li>
2877
2878<li>Return Value:
2879
2880<ul>
2881
2882<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2883
2884<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2885
2886<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2887
2888<li>any other non-string input value will cause a type error.</li>
2889 </ul></li>
2890
2891<li>
2892<p>Example:</p>
2893
2894<div class="source">
2895<div class="source">
2896<pre>upper(&quot;hello&quot;)
2897</pre></div></div></li>
2898</ul>
2899
2900<ul>
2901
2902<li>
2903<p>The expected result is:</p>
2904
2905<div class="source">
2906<div class="source">
2907<pre>&quot;HELLO&quot;
2908</pre></div></div></li>
2909</ul>
2910<!-- ! Licensed to the Apache Software Foundation (ASF) under one
2911 ! or more contributor license agreements. See the NOTICE file
2912 ! distributed with this work for additional information
2913 ! regarding copyright ownership. The ASF licenses this file
2914 ! to you under the Apache License, Version 2.0 (the
2915 ! "License"); you may not use this file except in compliance
2916 ! with the License. You may obtain a copy of the License at
2917 !
2918 ! http://www.apache.org/licenses/LICENSE-2.0
2919 !
2920 ! Unless required by applicable law or agreed to in writing,
2921 ! software distributed under the License is distributed on an
2922 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2923 ! KIND, either express or implied. See the License for the
2924 ! specific language governing permissions and limitations
2925 ! under the License.
2926 ! --></div></div>
2927<div class="section">
2928<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
2929<div class="section">
2930<h3><a name="parse_binary"></a>parse_binary</h3>
2931
2932<ul>
2933
2934<li>
2935<p>Syntax:</p>
2936<p>parse_binary(string, encoding)</p></li>
2937
2938<li>
2939<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p></li>
2940
2941<li>Arguments:
2942
2943<ul>
2944
2945<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
2946
2947<li><tt>encoding</tt> : a string notation specifies the encoding type of the given <tt>string</tt>. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
2948 </ul></li>
2949
2950<li>Return Value:
2951
2952<ul>
2953
2954<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
2955
2956<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2957
2958<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2959
2960<li>any other non-string input value will cause a type error.</li>
2961 </ul></li>
2962
2963<li>
2964<p>Example:</p>
2965<p>[ parse_binary(&#x201c;ABCDEF0123456789&#x201d;,&#x201c;hex&#x201d;), parse_binary(&#x201c;abcdef0123456789&#x201d;,&#x201c;HEX&#x201d;), parse_binary(&#x2018;QXN0ZXJpeAE=&#x2019;,&#x201c;base64&#x201d;) ];</p></li>
2966
2967<li>
2968<p>The expected result is:</p>
2969<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p></li>
2970</ul></div>
2971<div class="section">
2972<h3><a name="print_binary"></a>print_binary</h3>
2973
2974<ul>
2975
2976<li>
2977<p>Syntax:</p>
2978<p>print_binary(binary, encoding)</p></li>
2979
2980<li>
2981<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p></li>
2982
2983<li>Arguments:
2984
2985<ul>
2986
2987<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
2988
2989<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
2990 </ul></li>
2991
2992<li>Return Value:
2993
2994<ul>
2995
2996<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
2997
2998<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2999
3000<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3001
3002<li>any other non-string input value will cause a type error.</li>
3003 </ul></li>
3004
3005<li>
3006<p>Example:</p>
3007
3008<div class="source">
3009<div class="source">
3010<pre>[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3011</pre></div></div></li>
3012
3013<li>
3014<p>The expected result are:</p>
3015
3016<div class="source">
3017<div class="source">
3018<pre>[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3019</pre></div></div></li>
3020</ul></div>
3021<div class="section">
3022<h3><a name="binary_length"></a>binary_length</h3>
3023
3024<ul>
3025
3026<li>
3027<p>Syntax:</p>
3028<p>binary_length(binary)</p></li>
3029
3030<li>
3031<p>Returns the number of bytes storing the binary data.</p></li>
3032
3033<li>Arguments:
3034
3035<ul>
3036
3037<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3038 </ul></li>
3039
3040<li>Return Value:
3041
3042<ul>
3043
3044<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3045
3046<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3047
3048<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3049
3050<li>any other non-binary input value will cause a type error.</li>
3051 </ul></li>
3052
3053<li>
3054<p>Example:</p>
3055
3056<div class="source">
3057<div class="source">
3058<pre>binary_length(hex(&quot;00AA&quot;))
3059</pre></div></div></li>
3060
3061<li>
3062<p>The expected result is:</p>
3063<p>2</p></li>
3064</ul></div>
3065<div class="section">
3066<h3><a name="sub_binary"></a>sub_binary</h3>
3067
3068<ul>
3069
3070<li>
3071<p>Syntax:</p>
3072<p>sub_binary(binary, offset[, length])</p></li>
3073
3074<li>
3075<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p></li>
3076
3077<li>Arguments:
3078
3079<ul>
3080
3081<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3082
3083<li><tt>offset</tt> : a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the starting offset of the sub binary in <tt>binary</tt>,</li>
3084
3085<li><tt>length</tt> : (Optional) a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt> value as the length of the sub binary.</li>
3086 </ul></li>
3087
3088<li>Return Value:
3089
3090<ul>
3091
3092<li>a <tt>binary</tt> that represents the sub binary,</li>
3093
3094<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3095
3096<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3097
3098<li>a type error will be raised if:
3099
3100<ul>
3101
3102<li>the first argument is any other non-binary value,</li>
3103
3104<li>or, the second argument is any other non-integer value,</li>
3105
3106<li>or, the third argument is any other non-integer value, if it is present.</li>
3107 </ul></li>
3108 </ul></li>
3109
3110<li>
3111<p>Example:</p>
3112
3113<div class="source">
3114<div class="source">
3115<pre>sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3116</pre></div></div></li>
3117
3118<li>
3119<p>The expected result is</p>
3120
3121<div class="source">
3122<div class="source">
3123<pre>hex(&quot;DD&quot;)
3124</pre></div></div></li>
3125</ul></div>
3126<div class="section">
3127<h3><a name="binary_concat"></a>binary_concat</h3>
3128
3129<ul>
3130
3131<li>
3132<p>Syntax:</p>
3133<p>binary_concat(array)</p></li>
3134
3135<li>
3136<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p></li>
3137
3138<li>Arguments:
3139
3140<ul>
3141
3142<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of binaries (could be <tt>null</tt> or <tt>missing</tt>) to be concatenated.</li>
3143 </ul></li>
3144
3145<li>Return Value :
3146
3147<ul>
3148
3149<li>the concatenated <tt>binary</tt> value,</li>
3150
3151<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3152
3153<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3154
3155<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3156
3157<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
3158
3159<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3160 </ul></li>
3161
3162<li>
3163<p>Example:</p>
3164<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p></li>
3165
3166<li>
3167<p>The expected result is</p>
3168<p>hex(&#x201c;4242&#x201d;)</p></li>
3169</ul>
3170<!-- ! Licensed to the Apache Software Foundation (ASF) under one
3171 ! or more contributor license agreements. See the NOTICE file
3172 ! distributed with this work for additional information
3173 ! regarding copyright ownership. The ASF licenses this file
3174 ! to you under the Apache License, Version 2.0 (the
3175 ! "License"); you may not use this file except in compliance
3176 ! with the License. You may obtain a copy of the License at
3177 !
3178 ! http://www.apache.org/licenses/LICENSE-2.0
3179 !
3180 ! Unless required by applicable law or agreed to in writing,
3181 ! software distributed under the License is distributed on an
3182 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3183 ! KIND, either express or implied. See the License for the
3184 ! specific language governing permissions and limitations
3185 ! under the License.
3186 ! --></div></div>
3187<div class="section">
3188<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3189<div class="section">
3190<h3><a name="create_point"></a>create_point</h3>
3191
3192<ul>
3193
3194<li>
3195<p>Syntax:</p>
3196
3197<div class="source">
3198<div class="source">
3199<pre>create_point(x, y)
3200</pre></div></div></li>
3201
3202<li>
3203<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p></li>
3204
3205<li>Arguments:</li>
3206
3207<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3208
3209<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3210
3211<li>Return Value:</li>
3212
3213<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3214
3215<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3216
3217<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3218
3219<li>any other non-double input value will cause a type error.</li>
3220
3221<li>
3222<p>Example:</p>
3223
3224<div class="source">
3225<div class="source">
3226<pre>{ &quot;point&quot;: create_point(30.0,70.0) };
3227</pre></div></div></li>
3228</ul>
3229
3230<ul>
3231
3232<li>
3233<p>The expected result is:</p>
3234
3235<div class="source">
3236<div class="source">
3237<pre>{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3238</pre></div></div></li>
3239</ul></div>
3240<div class="section">
3241<h3><a name="create_line"></a>create_line</h3>
3242
3243<ul>
3244
3245<li>
3246<p>Syntax:</p>
3247
3248<div class="source">
3249<div class="source">
3250<pre>create_line(point1, point2)
3251</pre></div></div></li>
3252
3253<li>
3254<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p></li>
3255
3256<li>Arguments:
3257
3258<ul>
3259
3260<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3261
3262<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3263 </ul></li>
3264
3265<li>Return Value:
3266
3267<ul>
3268
3269<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3270
3271<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3272
3273<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3274
3275<li>any other non-point input value will cause a type error.</li>
3276 </ul></li>
3277
3278<li>
3279<p>Example:</p>
3280
3281<div class="source">
3282<div class="source">
3283<pre>{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3284</pre></div></div></li>
3285</ul>
3286
3287<ul>
3288
3289<li>
3290<p>The expected result is:</p>
3291
3292<div class="source">
3293<div class="source">
3294<pre>{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3295</pre></div></div></li>
3296</ul></div>
3297<div class="section">
3298<h3><a name="create_rectangle"></a>create_rectangle</h3>
3299
3300<ul>
3301
3302<li>
3303<p>Syntax:</p>
3304
3305<div class="source">
3306<div class="source">
3307<pre>create_rectangle(point1, point2)
3308</pre></div></div></li>
3309
3310<li>
3311<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p></li>
3312
3313<li>Arguments:
3314
3315<ul>
3316
3317<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3318
3319<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3320 </ul></li>
3321
3322<li>Return Value:
3323
3324<ul>
3325
3326<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3327
3328<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3329
3330<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3331
3332<li>any other non-point input value will cause a type error.</li>
3333 </ul></li>
3334
3335<li>
3336<p>Example:</p>
3337
3338<div class="source">
3339<div class="source">
3340<pre>{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3341</pre></div></div></li>
3342</ul>
3343
3344<ul>
3345
3346<li>
3347<p>The expected result is:</p>
3348
3349<div class="source">
3350<div class="source">
3351<pre>{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3352</pre></div></div></li>
3353</ul></div>
3354<div class="section">
3355<h3><a name="create_circle"></a>create_circle</h3>
3356
3357<ul>
3358
3359<li>
3360<p>Syntax:</p>
3361
3362<div class="source">
3363<div class="source">
3364<pre>create_circle(point, radius)
3365</pre></div></div></li>
3366
3367<li>
3368<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p></li>
3369
3370<li>Arguments:
3371
3372<ul>
3373
3374<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3375
3376<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3377 </ul></li>
3378
3379<li>Return Value:
3380
3381<ul>
3382
3383<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3384
3385<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3386
3387<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3388
3389<li>a type error will be raised if:
3390
3391<ul>
3392
3393<li>the first argument is any other non-point value,</li>
3394
3395<li>or, the second argument is any other non-double value.</li>
3396 </ul></li>
3397 </ul></li>
3398
3399<li>
3400<p>Example:</p>
3401
3402<div class="source">
3403<div class="source">
3404<pre>{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3405</pre></div></div></li>
3406</ul>
3407
3408<ul>
3409
3410<li>
3411<p>The expected result is:</p>
3412
3413<div class="source">
3414<div class="source">
3415<pre>{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3416</pre></div></div></li>
3417</ul></div>
3418<div class="section">
3419<h3><a name="create_polygon"></a>create_polygon</h3>
3420
3421<ul>
3422
3423<li>
3424<p>Syntax:</p>
3425
3426<div class="source">
3427<div class="source">
3428<pre>create_polygon(array)
3429</pre></div></div></li>
3430
3431<li>
3432<p>Creates the primitive type <tt>polygon</tt> using the double values provided in the argument <tt>array</tt>. Each two consecutive double values represent a point starting from the first double value in the array. Note that at least six double values should be specified, meaning a total of three points.</p></li>
3433
3434<li>Arguments:
3435
3436<ul>
3437
3438<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3439 </ul></li>
3440
3441<li>Return Value:
3442
3443<ul>
3444
3445<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3446
3447<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3448
3449<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3450
3451<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3452
3453<li><tt>null</tt> if any element in the input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
3454
3455<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3456 </ul></li>
3457</ul>
3458
3459<ul>
3460
3461<li>
3462<p>Example:</p>
3463
3464<div class="source">
3465<div class="source">
3466<pre>{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3467</pre></div></div></li>
3468</ul>
3469
3470<ul>
3471
3472<li>
3473<p>The expected result is:</p>
3474
3475<div class="source">
3476<div class="source">
3477<pre>{ &quot;polygon&quot;: polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;) }
3478</pre></div></div></li>
3479</ul></div>
3480<div class="section">
3481<h3><a name="get_xget_y"></a>get_x/get_y</h3>
3482
3483<ul>
3484
3485<li>
3486<p>Syntax:</p>
3487
3488<div class="source">
3489<div class="source">
3490<pre>get_x(point) or get_y(point)
3491</pre></div></div></li>
3492
3493<li>
3494<p>Returns the x or y coordinates of a point <tt>point</tt>.</p></li>
3495
3496<li>Arguments:
3497
3498<ul>
3499
3500<li><tt>point</tt> : a <tt>point</tt>.</li>
3501 </ul></li>
3502
3503<li>Return Value:
3504
3505<ul>
3506
3507<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3508
3509<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3510
3511<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3512
3513<li>any other non-point input value will cause a type error.</li>
3514 </ul></li>
3515
3516<li>
3517<p>Example:</p>
3518
3519<div class="source">
3520<div class="source">
3521<pre>{ &quot;x_coordinate&quot;: get_x(create_point(2.3,5.0)), &quot;y_coordinate&quot;: get_y(create_point(2.3,5.0)) };
3522</pre></div></div></li>
3523</ul>
3524
3525<ul>
3526
3527<li>
3528<p>The expected result is:</p>
3529
3530<div class="source">
3531<div class="source">
3532<pre>{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3533</pre></div></div></li>
3534</ul></div>
3535<div class="section">
3536<h3><a name="get_points"></a>get_points</h3>
3537
3538<ul>
3539
3540<li>
3541<p>Syntax:</p>
3542
3543<div class="source">
3544<div class="source">
3545<pre>get_points(spatial_object)
3546</pre></div></div></li>
3547
3548<li>
3549<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p></li>
3550
3551<li>Arguments:
3552
3553<ul>
3554
3555<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3556 </ul></li>
3557
3558<li>Return Value:
3559
3560<ul>
3561
3562<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3563
3564<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3565
3566<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3567
3568<li>any other non-spatial-object input value will cause a type error.</li>
3569 </ul></li>
3570
3571<li>
3572<p>Example:</p>
3573
3574<div class="source">
3575<div class="source">
3576<pre>get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3577</pre></div></div></li>
3578
3579<li>
3580<p>The expected result is:</p>
3581
3582<div class="source">
3583<div class="source">
3584<pre>[ point(&quot;1.0,1.0&quot;), point(&quot;2.0,2.0&quot;), point(&quot;3.0,3.0&quot;), point(&quot;4.0,4.0&quot;) ]
3585</pre></div></div></li>
3586</ul></div>
3587<div class="section">
3588<h3><a name="get_centerget_radius"></a>get_center/get_radius</h3>
3589
3590<ul>
3591
3592<li>
3593<p>Syntax:</p>
3594
3595<div class="source">
3596<div class="source">
3597<pre>get_center(circle_expression) or get_radius(circle_expression)
3598</pre></div></div></li>
3599
3600<li>
3601<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p></li>
3602
3603<li>Arguments:
3604
3605<ul>
3606
3607<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3608 </ul></li>
3609
3610<li>Return Value:
3611
3612<ul>
3613
3614<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3615
3616<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3617
3618<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3619
3620<li>any other non-circle input value will cause a type error.</li>
3621 </ul></li>
3622
3623<li>
3624<p>Example:</p>
3625
3626<div class="source">
3627<div class="source">
3628<pre>{
3629 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3630 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3631};
3632</pre></div></div></li>
3633</ul>
3634
3635<ul>
3636
3637<li>
3638<p>The expected result is:</p>
3639
3640<div class="source">
3641<div class="source">
3642<pre>{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3643</pre></div></div></li>
3644</ul></div>
3645<div class="section">
3646<h3><a name="spatial_distance"></a>spatial_distance</h3>
3647
3648<ul>
3649
3650<li>
3651<p>Syntax:</p>
3652
3653<div class="source">
3654<div class="source">
3655<pre>spatial_distance(point1, point2)
3656</pre></div></div></li>
3657
3658<li>
3659<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p></li>
3660
3661<li>Arguments:
3662
3663<ul>
3664
3665<li><tt>point1</tt> : a <tt>point</tt>.</li>
3666
3667<li><tt>point2</tt> : a <tt>point</tt>.</li>
3668 </ul></li>
3669
3670<li>Return Value:
3671
3672<ul>
3673
3674<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3675
3676<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3677
3678<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3679
3680<li>any other non-point input value will cause a type error.</li>
3681 </ul></li>
3682
3683<li>
3684<p>Example:</p>
3685
3686<div class="source">
3687<div class="source">
3688<pre>spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3689</pre></div></div></li>
3690</ul>
3691
3692<ul>
3693
3694<li>
3695<p>The expected result is:</p>
3696
3697<div class="source">
3698<div class="source">
3699<pre>20.434678857275934
3700</pre></div></div></li>
3701</ul></div>
3702<div class="section">
3703<h3><a name="spatial_area"></a>spatial_area</h3>
3704
3705<ul>
3706
3707<li>
3708<p>Syntax:</p>
3709
3710<div class="source">
3711<div class="source">
3712<pre>spatial_area(spatial_2d_expression)
3713</pre></div></div></li>
3714
3715<li>
3716<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p></li>
3717
3718<li>Arguments:
3719
3720<ul>
3721
3722<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3723 </ul></li>
3724
3725<li>Return Value:
3726
3727<ul>
3728
3729<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
3730
3731<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3732
3733<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3734
3735<li>any other non-2d-spatial-object will cause a type error.</li>
3736 </ul></li>
3737
3738<li>
3739<p>Example:</p>
3740
3741<div class="source">
3742<div class="source">
3743<pre>spatial_area(create_circle(create_point(0.0,0.0), 5.0));
3744</pre></div></div></li>
3745</ul>
3746
3747<ul>
3748
3749<li>
3750<p>The expected result is:</p>
3751
3752<div class="source">
3753<div class="source">
3754<pre>78.53981625
3755</pre></div></div></li>
3756</ul></div>
3757<div class="section">
3758<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
3759
3760<ul>
3761
3762<li>
3763<p>Syntax:</p>
3764
3765<div class="source">
3766<div class="source">
3767<pre>spatial_intersect(spatial_object1, spatial_object2)
3768</pre></div></div></li>
3769
3770<li>
3771<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p></li>
3772
3773<li>Arguments:
3774
3775<ul>
3776
3777<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3778
3779<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3780 </ul></li>
3781
3782<li>Return Value:
3783
3784<ul>
3785
3786<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
3787
3788<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3789
3790<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3791
3792<li>any other non-spatial-object input value will cause a type error.</li>
3793 </ul></li>
3794
3795<li>
3796<p>Example:</p>
3797
3798<div class="source">
3799<div class="source">
3800<pre>spatial_intersect(point(&quot;39.28,70.48&quot;), create_rectangle(create_point(30.0,70.0), create_point(40.0,80.0)));
3801</pre></div></div></li>
3802</ul>
3803
3804<ul>
3805
3806<li>
3807<p>The expected result is:</p>
3808
3809<div class="source">
3810<div class="source">
3811<pre>true
3812</pre></div></div></li>
3813</ul></div>
3814<div class="section">
3815<h3><a name="spatial_cell"></a>spatial_cell</h3>
3816
3817<ul>
3818
3819<li>
3820<p>Syntax:</p>
3821
3822<div class="source">
3823<div class="source">
3824<pre>spatial_cell(point1, point2, x_increment, y_increment)
3825</pre></div></div></li>
3826
3827<li>
3828<p>Returns the grid cell that <tt>point1</tt> belongs to.</p></li>
3829
3830<li>Arguments:
3831
3832<ul>
3833
3834<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
3835
3836<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
3837
3838<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
3839
3840<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
3841 </ul></li>
3842
3843<li>Return Value:
3844
3845<ul>
3846
3847<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
3848
3849<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3850
3851<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3852
3853<li>a type error will be raised if:
3854
3855<ul>
3856
3857<li>the first or second argument is any other non-point value,</li>
3858
3859<li>or, the second or third argument is any other non-double value.</li>
3860 </ul></li>
3861 </ul></li>
3862
3863<li>
3864<p>Example:</p>
3865
3866<div class="source">
3867<div class="source">
3868<pre>spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
3869</pre></div></div></li>
3870</ul>
3871
3872<ul>
3873
3874<li>
3875<p>The expected result is:</p>
3876
3877<div class="source">
3878<div class="source">
3879<pre>rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
3880</pre></div></div></li>
3881</ul>
3882<!-- ! Licensed to the Apache Software Foundation (ASF) under one
3883 ! or more contributor license agreements. See the NOTICE file
3884 ! distributed with this work for additional information
3885 ! regarding copyright ownership. The ASF licenses this file
3886 ! to you under the Apache License, Version 2.0 (the
3887 ! "License"); you may not use this file except in compliance
3888 ! with the License. You may obtain a copy of the License at
3889 !
3890 ! http://www.apache.org/licenses/LICENSE-2.0
3891 !
3892 ! Unless required by applicable law or agreed to in writing,
3893 ! software distributed under the License is distributed on an
3894 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3895 ! KIND, either express or implied. See the License for the
3896 ! specific language governing permissions and limitations
3897 ! under the License.
3898 ! --></div></div>
3899<div class="section">
3900<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
3901<p>AsterixDB supports queries with different similarity functions, including <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> and <a class="externalLink" href="https://en.wikipedia.org/wiki/Jaccard_index">Jaccard</a>.</p>
3902<div class="section">
3903<h3><a name="edit_distance"></a>edit_distance</h3>
3904
3905<ul>
3906
3907<li>
3908<p>Syntax:</p>
3909
3910<div class="source">
3911<div class="source">
3912<pre>edit_distance(expression1, expression2)
3913</pre></div></div></li>
3914
3915<li>
3916<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p></li>
3917
3918<li>Arguments:
3919
3920<ul>
3921
3922<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
3923
3924<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
3925 </ul></li>
3926
3927<li>Return Value:
3928
3929<ul>
3930
3931<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
3932
3933<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3934
3935<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3936
3937<li>any other non-string input value will cause a type error.</li>
3938 </ul></li>
3939
3940<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
3941
3942<li>
3943<p>Example:</p>
3944
3945<div class="source">
3946<div class="source">
3947<pre>edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
3948</pre></div></div></li>
3949</ul>
3950
3951<ul>
3952
3953<li>
3954<p>The expected result is:</p>
3955
3956<div class="source">
3957<div class="source">
3958<pre>2
3959</pre></div></div></li>
3960</ul></div>
3961<div class="section">
3962<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
3963
3964<ul>
3965
3966<li>
3967<p>Syntax:</p>
3968
3969<div class="source">
3970<div class="source">
3971<pre>edit_distance_contains(expression1, expression2, threshold)
3972</pre></div></div></li>
3973
3974<li>
3975<p>Checks whether <tt>expression1</tt> contains <tt>expression2</tt> with an <a class="externalLink" href="http://en.wikipedia.org/wiki/Levenshtein_distance">edit distance</a> within a given threshold.</p></li>
3976
3977<li>
3978<p>Arguments:</p>
3979
3980<ul>
3981
3982<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
3983
3984<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
3985
3986<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
3987 </ul></li>
3988
3989<li>Return Value:
3990
3991<ul>
3992
3993<li>an <tt>array</tt> with two items:
3994
3995<ul>
3996
3997<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
3998
3999<li>The second item contains an <tt>integer</tt> that represents the required edit distance for <tt>expression1</tt> to contain <tt>expression2</tt> if the first item is true.</li>
4000 </ul></li>
4001
4002<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4003
4004<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4005
4006<li>a type error will be raised if:
4007
4008<ul>
4009
4010<li>the first or second argument is any other non-string value,</li>
4011
4012<li>or, the third argument is any other non-bigint value.</li>
4013 </ul></li>
4014 </ul></li>
4015
4016<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4017
4018<li>
4019<p>Example:</p>
4020
4021<div class="source">
4022<div class="source">
4023<pre>edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4024</pre></div></div></li>
4025</ul>
4026
4027<ul>
4028
4029<li>
4030<p>The expected result is:</p>
4031
4032<div class="source">
4033<div class="source">
4034<pre>[ true, 1 ]
4035</pre></div></div></li>
4036</ul></div>
4037<div class="section">
4038<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4039
4040<ul>
4041
4042<li>
4043<p>Syntax:</p>
4044
4045<div class="source">
4046<div class="source">
4047<pre>similarity_jaccard(array1, array2)
4048</pre></div></div></li>
4049
4050<li>
4051<p>Returns the <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> of <tt>array1</tt> and <tt>array2</tt>.</p></li>
4052
4053<li>Arguments:
4054
4055<ul>
4056
4057<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4058
4059<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4060 </ul></li>
4061
4062<li>Return Value:
4063
4064<ul>
4065
4066<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4067
4068<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4069
4070<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4071
4072<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4073
4074<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
4075
4076<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4077 </ul></li>
4078
4079<li>
4080<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p></li>
4081
4082<li>
4083<p>Example:</p>
4084
4085<div class="source">
4086<div class="source">
4087<pre>similarity_jaccard([1,5,8,9], [1,5,9,10]);
4088</pre></div></div></li>
4089</ul>
4090
4091<ul>
4092
4093<li>
4094<p>The expected result is:</p>
4095
4096<div class="source">
4097<div class="source">
4098<pre>0.6
4099</pre></div></div></li>
4100</ul></div>
4101<div class="section">
4102<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4103
4104<ul>
4105
4106<li>
4107<p>Syntax:</p>
4108
4109<div class="source">
4110<div class="source">
4111<pre>similarity_jaccard_check(array1, array2, threshold)
4112</pre></div></div></li>
4113
4114<li>
4115<p>Checks whether <tt>array1</tt> and <tt>array2</tt> have a <a class="externalLink" href="http://en.wikipedia.org/wiki/Jaccard_index">Jaccard similarity</a> greater than or equal to threshold. Again, the &#x201c;check&#x201d; version of Jaccard is faster than the &#x201c;non_check&#x201d; version.</p></li>
4116
4117<li>
4118<p>Arguments:</p>
4119
4120<ul>
4121
4122<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4123
4124<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4125
4126<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4127 </ul></li>
4128
4129<li>Return Value:
4130
4131<ul>
4132
4133<li>an <tt>array</tt> with two items:
4134
4135<ul>
4136
4137<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4138
4139<li>The second item contains a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt> if it is greater than or equal to the threshold, or 0 otherwise.</li>
4140 </ul></li>
4141
4142<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4143
4144<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4145
4146<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4147
4148<li><tt>null</tt> if any element in any input array is <tt>null</tt> but no element in the input array is <tt>missing</tt>,</li>
4149
4150<li>a type error will be raised if: * the first or second argument is any other non-array value, * or, the third argument is any other non-double value.</li>
4151 </ul></li>
4152
4153<li>
4154<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p></li>
4155
4156<li>
4157<p>Example:</p>
4158
4159<div class="source">
4160<div class="source">
4161<pre>similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4162</pre></div></div></li>
4163</ul>
4164
4165<ul>
4166
4167<li>
4168<p>The expected result is:</p>
4169
4170<div class="source">
4171<div class="source">
4172<pre>[ false, 0.0 ]
4173</pre></div></div></li>
4174</ul>
4175<!-- ! Licensed to the Apache Software Foundation (ASF) under one
4176 ! or more contributor license agreements. See the NOTICE file
4177 ! distributed with this work for additional information
4178 ! regarding copyright ownership. The ASF licenses this file
4179 ! to you under the Apache License, Version 2.0 (the
4180 ! "License"); you may not use this file except in compliance
4181 ! with the License. You may obtain a copy of the License at
4182 !
4183 ! http://www.apache.org/licenses/LICENSE-2.0
4184 !
4185 ! Unless required by applicable law or agreed to in writing,
4186 ! software distributed under the License is distributed on an
4187 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4188 ! KIND, either express or implied. See the License for the
4189 ! specific language governing permissions and limitations
4190 ! under the License.
4191 ! --></div></div>
4192<div class="section">
4193<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4194<div class="section">
4195<h3><a name="word_tokens"></a>word_tokens</h3>
4196
4197<ul>
4198
4199<li>
4200<p>Syntax:</p>
4201
4202<div class="source">
4203<div class="source">
4204<pre>word_tokens(string)
4205</pre></div></div></li>
4206
4207<li>
4208<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p></li>
4209
4210<li>Arguments:
4211
4212<ul>
4213
4214<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4215 </ul></li>
4216
4217<li>Return Value:
4218
4219<ul>
4220
4221<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4222
4223<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4224
4225<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4226
4227<li>any other non-string input value will cause a type error.</li>
4228 </ul></li>
4229
4230<li>
4231<p>Example:</p>
4232
4233<div class="source">
4234<div class="source">
4235<pre>word_tokens(&quot;I like the phone, awesome!&quot;);
4236</pre></div></div></li>
4237</ul>
4238
4239<ul>
4240
4241<li>
4242<p>The expected result is:</p>
4243
4244<div class="source">
4245<div class="source">
4246<pre>[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4247</pre></div></div></li>
4248</ul>
4249<!-- ! Licensed to the Apache Software Foundation (ASF) under one
4250 ! or more contributor license agreements. See the NOTICE file
4251 ! distributed with this work for additional information
4252 ! regarding copyright ownership. The ASF licenses this file
4253 ! to you under the Apache License, Version 2.0 (the
4254 ! "License"); you may not use this file except in compliance
4255 ! with the License. You may obtain a copy of the License at
4256 !
4257 ! http://www.apache.org/licenses/LICENSE-2.0
4258 !
4259 ! Unless required by applicable law or agreed to in writing,
4260 ! software distributed under the License is distributed on an
4261 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4262 ! KIND, either express or implied. See the License for the
4263 ! specific language governing permissions and limitations
4264 ! under the License.
4265 ! --></div></div>
4266<div class="section">
4267<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4268<div class="section">
4269<h3><a name="get_yearget_monthget_dayget_hourget_minuteget_secondget_millisecond"></a>get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond</h3>
4270
4271<ul>
4272
4273<li>
4274<p>Syntax:</p>
4275
4276<div class="source">
4277<div class="source">
4278<pre>get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4279</pre></div></div></li>
4280
4281<li>
4282<p>Accessors for accessing fields in a temporal value</p></li>
4283
4284<li>Arguments:
4285
4286<ul>
4287
4288<li><tt>temporal_value</tt> : a temporal value represented as one of the following types: <tt>date</tt>, <tt>datetime</tt>, <tt>time</tt>, and <tt>duration</tt>.</li>
4289 </ul></li>
4290
4291<li>Return Value:
4292
4293<ul>
4294
4295<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4296
4297<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4298
4299<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4300
4301<li>any other non-interval input value will cause a type error.</li>
4302 </ul></li>
4303
4304<li>
4305<p>Example:</p>
4306
4307<div class="source">
4308<div class="source">
4309<pre>{
4310 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4311 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4312 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4313 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4314 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4315 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4316 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4317};
4318</pre></div></div></li>
4319</ul>
4320
4321<ul>
4322
4323<li>
4324<p>The expected result is:</p>
4325
4326<div class="source">
4327<div class="source">
4328<pre>{ &quot;year&quot;: 2010, &quot;month&quot;: 11, &quot;day&quot;: 30, &quot;hour&quot;: 5, &quot;min&quot;: 28, &quot;second&quot;: 23, &quot;ms&quot;: 94 }
4329</pre></div></div></li>
4330</ul></div>
4331<div class="section">
4332<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4333
4334<ul>
4335
4336<li>
4337<p>Syntax:</p>
4338
4339<div class="source">
4340<div class="source">
4341<pre>adjust_datetime_for_timezone(datetime, string)
4342</pre></div></div></li>
4343
4344<li>
4345<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p></li>
4346
4347<li>Arguments:
4348
4349<ul>
4350
4351<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4352
4353<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4354 </ul></li>
4355
4356<li>Return Value:
4357
4358<ul>
4359
4360<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4361
4362<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4363
4364<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4365
4366<li>a type error will be raised if:
4367
4368<ul>
4369
4370<li>the first argument is any other non-datetime value,</li>
4371
4372<li>or, the second argument is any other non-string value.</li>
4373 </ul></li>
4374 </ul></li>
4375
4376<li>
4377<p>Example:</p>
4378
4379<div class="source">
4380<div class="source">
4381<pre>adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4382</pre></div></div></li>
4383</ul>
4384
4385<ul>
4386
4387<li>
4388<p>The expected result is:</p>
4389
4390<div class="source">
4391<div class="source">
4392<pre>&quot;2008-04-26T18:10:00.000+08:00&quot;
4393</pre></div></div></li>
4394</ul></div>
4395<div class="section">
4396<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4397
4398<ul>
4399
4400<li>
4401<p>Syntax:</p>
4402
4403<div class="source">
4404<div class="source">
4405<pre>adjust_time_for_timezone(time, string)
4406</pre></div></div></li>
4407
4408<li>
4409<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p></li>
4410
4411<li>Arguments:
4412
4413<ul>
4414
4415<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4416
4417<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4418 </ul></li>
4419
4420<li>Return Value:
4421
4422<ul>
4423
4424<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4425
4426<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4427
4428<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4429
4430<li>a type error will be raised if:
4431
4432<ul>
4433
4434<li>the first argument is any other non-time value,</li>
4435
4436<li>or, the second argument is any other non-string value.</li>
4437 </ul></li>
4438 </ul></li>
4439
4440<li>
4441<p>Example:</p>
4442
4443<div class="source">
4444<div class="source">
4445<pre>adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4446</pre></div></div></li>
4447</ul>
4448
4449<ul>
4450
4451<li>
4452<p>The expected result is:</p>
4453
4454<div class="source">
4455<div class="source">
4456<pre>&quot;18:10:00.000+08:00&quot;
4457</pre></div></div></li>
4458</ul></div>
4459<div class="section">
4460<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4461
4462<ul>
4463
4464<li>
4465<p>Syntax:</p>
4466
4467<div class="source">
4468<div class="source">
4469<pre>calendar_duration_from_datetime(datetime, duration_value)
4470</pre></div></div></li>
4471
4472<li>
4473<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p></li>
4474
4475<li>Arguments:
4476
4477<ul>
4478
4479<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4480
4481<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4482 </ul></li>
4483
4484<li>Return Value:
4485
4486<ul>
4487
4488<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4489
4490<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4491
4492<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4493
4494<li>a type error will be raised if:
4495
4496<ul>
4497
4498<li>the first argument is any other non-datetime value,</li>
4499
4500<li>or, the second argument is any other non-duration input value.</li>
4501 </ul></li>
4502 </ul></li>
4503
4504<li>
4505<p>Example:</p>
4506
4507<div class="source">
4508<div class="source">
4509<pre>calendar_duration_from_datetime(
4510 datetime(&quot;2016-03-26T10:10:00&quot;),
4511 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4512);
4513</pre></div></div></li>
4514
4515<li>
4516<p>The expected result is:</p>
4517
4518<div class="source">
4519<div class="source">
4520<pre>duration(&quot;P5Y2M24DT10H10M&quot;)
4521</pre></div></div></li>
4522</ul></div>
4523<div class="section">
4524<h3><a name="get_year_month_durationget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4525
4526<ul>
4527
4528<li>
4529<p>Syntax:</p>
4530
4531<div class="source">
4532<div class="source">
4533<pre>get_year_month_duration/get_day_time_duration(duration_value)
4534</pre></div></div></li>
4535
4536<li>
4537<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p></li>
4538
4539<li>Arguments:
4540
4541<ul>
4542
4543<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4544 </ul></li>
4545
4546<li>Return Value:
4547
4548<ul>
4549
4550<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4551
4552<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4553
4554<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4555
4556<li>any other non-duration input value will cause a type error.</li>
4557 </ul></li>
4558
4559<li>
4560<p>Example:</p>
4561
4562<div class="source">
4563<div class="source">
4564<pre>get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4565</pre></div></div></li>
4566</ul>
4567
4568<ul>
4569
4570<li>
4571<p>The expected result is:</p>
4572
4573<div class="source">
4574<div class="source">
4575<pre>year_month_duration(&quot;P1Y&quot;)
4576</pre></div></div></li>
4577</ul></div>
4578<div class="section">
4579<h3><a name="months_from_year_month_durationmilliseconds_from_day_time_duration"></a>months_from_year_month_duration/milliseconds_from_day_time_duration</h3>
4580
4581<ul>
4582
4583<li>
4584<p>Syntax:</p>
4585
4586<div class="source">
4587<div class="source">
4588<pre>months_from_year_month_duration/milliseconds_from_day_time_duration(duration_value)
4589</pre></div></div></li>
4590
4591<li>
4592<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p></li>
4593
4594<li>Arguments:
4595
4596<ul>
4597
4598<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4599 </ul></li>
4600
4601<li>Return Value:
4602
4603<ul>
4604
4605<li>an <tt>bigint</tt> representing the number or months/milliseconds,</li>
4606
4607<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4608
4609<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4610
4611<li>any other non-duration input value will cause a type error.</li>
4612 </ul></li>
4613
4614<li>
4615<p>Example:</p>
4616
4617<div class="source">
4618<div class="source">
4619<pre>months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;)));
4620</pre></div></div></li>
4621</ul>
4622
4623<ul>
4624
4625<li>
4626<p>The expected result is:</p>
4627
4628<div class="source">
4629<div class="source">
4630<pre>67
4631</pre></div></div></li>
4632</ul></div>
4633<div class="section">
4634<h3><a name="duration_from_monthsduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4635
4636<ul>
4637
4638<li>
4639<p>Syntax:</p>
4640
4641<div class="source">
4642<div class="source">
4643<pre>duration_from_months/duration_from_ms(number_value)
4644</pre></div></div></li>
4645
4646<li>
4647<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p></li>
4648
4649<li>Arguments:
4650
4651<ul>
4652
4653<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4654 </ul></li>
4655
4656<li>Return Value:
4657
4658<ul>
4659
4660<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4661
4662<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4663
4664<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4665
4666<li>any other non-duration input value will cause a type error.</li>
4667 </ul></li>
4668
4669<li>
4670<p>Example:</p>
4671
4672<div class="source">
4673<div class="source">
4674<pre>duration_from_months(8);
4675</pre></div></div></li>
4676
4677<li>
4678<p>The expected result is:</p>
4679
4680<div class="source">
4681<div class="source">
4682<pre>duration(&quot;P8M&quot;)
4683</pre></div></div></li>
4684</ul></div>
4685<div class="section">
4686<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4687
4688<ul>
4689
4690<li>
4691<p>Syntax:</p>
4692
4693<div class="source">
4694<div class="source">
4695<pre>duration_from_interval(interval_value)
4696</pre></div></div></li>
4697
4698<li>
4699<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p></li>
4700
4701<li>Arguments:
4702
4703<ul>
4704
4705<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
4706 </ul></li>
4707
4708<li>Return Value:
4709
4710<ul>
4711
4712<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
4713
4714<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4715
4716<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4717
4718<li>any other non-duration input value will cause a type error.</li>
4719 </ul></li>
4720
4721<li>
4722<p>Example:</p>
4723
4724<div class="source">
4725<div class="source">
4726<pre>{
4727 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
4728 &quot;dr2&quot; : duration_from_interval(interval(datetime(&quot;2012-06-26T01:01:01.111&quot;), datetime(&quot;2012-07-27T02:02:02.222&quot;))),
4729 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
4730 &quot;dr4&quot; : duration_from_interval(null)
4731};
4732</pre></div></div></li>
4733
4734<li>
4735<p>The expected result is:</p>
4736
4737<div class="source">
4738<div class="source">
4739<pre>{
4740 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
4741 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
4742 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
4743 &quot;dr4&quot;: null
4744}
4745</pre></div></div></li>
4746</ul></div>
4747<div class="section">
4748<h3><a name="current_date"></a>current_date</h3>
4749
4750<ul>
4751
4752<li>
4753<p>Syntax:</p>
4754
4755<div class="source">
4756<div class="source">
4757<pre>current_date()
4758</pre></div></div></li>
4759
4760<li>
4761<p>Gets the current date.</p></li>
4762
4763<li>Arguments: None</li>
4764
4765<li>Return Value:
4766
4767<ul>
4768
4769<li>a <tt>date</tt> value of the date when the function is called.</li>
4770 </ul></li>
4771</ul></div>
4772<div class="section">
4773<h3><a name="current_time"></a>current_time</h3>
4774
4775<ul>
4776
4777<li>
4778<p>Syntax:</p>
4779
4780<div class="source">
4781<div class="source">
4782<pre>current_time()
4783</pre></div></div></li>
4784
4785<li>
4786<p>Get the current time</p></li>
4787
4788<li>Arguments: None</li>
4789
4790<li>Return Value:
4791
4792<ul>
4793
4794<li>a <tt>time</tt> value of the time when the function is called.</li>
4795 </ul></li>
4796</ul></div>
4797<div class="section">
4798<h3><a name="current_datetime"></a>current_datetime</h3>
4799
4800<ul>
4801
4802<li>
4803<p>Syntax:</p>
4804
4805<div class="source">
4806<div class="source">
4807<pre>current_datetime()
4808</pre></div></div></li>
4809
4810<li>
4811<p>Get the current datetime</p></li>
4812
4813<li>Arguments: None</li>
4814
4815<li>Return Value:
4816
4817<ul>
4818
4819<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
4820 </ul></li>
4821</ul></div>
4822<div class="section">
4823<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
4824
4825<ul>
4826
4827<li>
4828<p>Syntax:</p>
4829
4830<div class="source">
4831<div class="source">
4832<pre>get_date_from_datetime(datetime)
4833</pre></div></div></li>
4834
4835<li>
4836<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p></li>
4837
4838<li>Arguments:
4839
4840<ul>
4841
4842<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
4843 </ul></li>
4844
4845<li>Return Value:
4846
4847<ul>
4848
4849<li>a <tt>date</tt> value from the datetime,</li>
4850
4851<li>any other non-datetime input value will cause a type error.</li>
4852 </ul></li>
4853</ul></div>
4854<div class="section">
4855<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
4856
4857<ul>
4858
4859<li>
4860<p>Syntax:</p>
4861
4862<div class="source">
4863<div class="source">
4864<pre>get_time_from_datetime(datetime)
4865</pre></div></div></li>
4866
4867<li>
4868<p>Get the time value from the given datetime value <tt>datetime</tt></p></li>
4869
4870<li>Arguments:
4871
4872<ul>
4873
4874<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
4875 </ul></li>
4876
4877<li>Return Value:
4878
4879<ul>
4880
4881<li>a <tt>time</tt> value from the datetime.</li>
4882
4883<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4884
4885<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4886
4887<li>any other non-datetime input value will cause a type error.</li>
4888 </ul></li>
4889
4890<li>
4891<p>Example:</p>
4892
4893<div class="source">
4894<div class="source">
4895<pre>get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
4896</pre></div></div></li>
4897
4898<li>
4899<p>The expected result is:</p>
4900
4901<div class="source">
4902<div class="source">
4903<pre>time(&quot;10:10:00.000Z&quot;)
4904</pre></div></div></li>
4905</ul></div>
4906<div class="section">
4907<h3><a name="day_of_week"></a>day_of_week</h3>
4908
4909<ul>
4910
4911<li>
4912<p>Syntax:</p>
4913
4914<div class="source">
4915<div class="source">
4916<pre>day_of_week(date)
4917</pre></div></div></li>
4918
4919<li>
4920<p>Finds the day of the week for a given date (1_7)</p></li>
4921
4922<li>Arguments:
4923
4924<ul>
4925
4926<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
4927 </ul></li>
4928
4929<li>Return Value:
4930
4931<ul>
4932
4933<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
4934
4935<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4936
4937<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4938
4939<li>any other non-date input value will cause a type error.</li>
4940 </ul></li>
4941
4942<li>
4943<p>Example:</p>
4944
4945<div class="source">
4946<div class="source">
4947<pre>day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
4948</pre></div></div></li>
4949</ul>
4950
4951<ul>
4952
4953<li>
4954<p>The expected result is:</p>
4955
4956<div class="source">
4957<div class="source">
4958<pre>7
4959</pre></div></div></li>
4960</ul></div>
4961<div class="section">
4962<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
4963
4964<ul>
4965
4966<li>
4967<p>Syntax:</p>
4968
4969<div class="source">
4970<div class="source">
4971<pre>date_from_unix_time_in_days(numeric_value)
4972</pre></div></div></li>
4973
4974<li>
4975<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p></li>
4976
4977<li>Arguments:
4978
4979<ul>
4980
4981<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of days.</li>
4982 </ul></li>
4983
4984<li>Return Value:
4985
4986<ul>
4987
4988<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
4989
4990<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4991
4992<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4993
4994<li>any other non-numeric input value will cause a type error.</li>
4995 </ul></li>
4996</ul></div>
4997<div class="section">
4998<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
4999
5000<ul>
5001
5002<li>
5003<p>Syntax:</p>
5004
5005<div class="source">
5006<div class="source">
5007<pre>datetime_from_unix_time_in_ms(numeric_value)
5008</pre></div></div></li>
5009
5010<li>
5011<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p></li>
5012
5013<li>Arguments:
5014
5015<ul>
5016
5017<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
5018 </ul></li>
5019
5020<li>Return Value:
5021
5022<ul>
5023
5024<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5025
5026<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5027
5028<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5029
5030<li>any other non-numeric input value will cause a type error.</li>
5031 </ul></li>
5032</ul></div>
5033<div class="section">
5034<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5035
5036<ul>
5037
5038<li>
5039<p>Syntax:</p>
5040
5041<div class="source">
5042<div class="source">
5043<pre>datetime_from_unix_time_in_secs(numeric_value)
5044</pre></div></div></li>
5045
5046<li>
5047<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p></li>
5048
5049<li>Arguments:
5050
5051<ul>
5052
5053<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of seconds.</li>
5054 </ul></li>
5055
5056<li>Return Value:
5057
5058<ul>
5059
5060<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5061
5062<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5063
5064<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5065
5066<li>any other non-numeric input value will cause a type error.</li>
5067 </ul></li>
5068</ul></div>
5069<div class="section">
5070<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5071
5072<ul>
5073
5074<li>Syntax:</li>
5075</ul>
5076<p>datetime_from_date_time(date,time)</p>
5077
5078<ul>
5079
5080<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5081
5082<ul>
5083
5084<li>Arguments:</li>
5085
5086<li><tt>date</tt>: a <tt>date</tt> value</li>
5087
5088<li><tt>time</tt> a <tt>time</tt> value</li>
5089 </ul></li>
5090
5091<li>Return Value:
5092
5093<ul>
5094
5095<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5096
5097<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5098
5099<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5100
5101<li>a type error will be raised if
5102
5103<ul>
5104
5105<li>the first argument is any other non-date value,</li>
5106
5107<li>or, the second argument is any other non-time value.</li>
5108 </ul></li>
5109 </ul></li>
5110</ul></div>
5111<div class="section">
5112<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5113
5114<ul>
5115
5116<li>
5117<p>Syntax:</p>
5118
5119<div class="source">
5120<div class="source">
5121<pre>time_from_unix_time_in_ms(numeric_value)
5122</pre></div></div></li>
5123
5124<li>
5125<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p></li>
5126
5127<li>Arguments:
5128
5129<ul>
5130
5131<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the number of milliseconds.</li>
5132 </ul></li>
5133
5134<li>Return Value:
5135
5136<ul>
5137
5138<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5139
5140<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5141
5142<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5143
5144<li>any other non-numeric input value will cause a type error.</li>
5145 </ul></li>
5146
5147<li>
5148<p>Example:</p>
5149
5150<div class="source">
5151<div class="source">
5152<pre>{
5153 &quot;date&quot;: date_from_unix_time_in_days(15800),
5154 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5155 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5156};
5157</pre></div></div></li>
5158</ul>
5159
5160<ul>
5161
5162<li>
5163<p>The expected result is:</p>
5164
5165<div class="source">
5166<div class="source">
5167<pre>{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
5168</pre></div></div></li>
5169</ul></div>
5170<div class="section">
5171<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5172
5173<ul>
5174
5175<li>
5176<p>Syntax:</p>
5177
5178<div class="source">
5179<div class="source">
5180<pre>unix_time_from_date_in_days(date_value)
5181</pre></div></div></li>
5182
5183<li>
5184<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p></li>
5185
5186<li>Arguments:
5187
5188<ul>
5189
5190<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5191 </ul></li>
5192
5193<li>Return Value:
5194
5195<ul>
5196
5197<li>a <tt>bigint</tt> value representing the number of days,</li>
5198
5199<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5200
5201<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5202
5203<li>any other non-date input value will cause a type error.</li>
5204 </ul></li>
5205</ul></div>
5206<div class="section">
5207<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5208
5209<ul>
5210
5211<li>
5212<p>Syntax:</p>
5213
5214<div class="source">
5215<div class="source">
5216<pre>unix_time_from_datetime_in_ms(datetime_value)
5217</pre></div></div></li>
5218
5219<li>
5220<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p></li>
5221
5222<li>Arguments:
5223
5224<ul>
5225
5226<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5227 </ul></li>
5228
5229<li>Return Value:
5230
5231<ul>
5232
5233<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5234
5235<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5236
5237<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5238
5239<li>any other non-datetime input value will cause a type error.</li>
5240 </ul></li>
5241</ul></div>
5242<div class="section">
5243<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5244
5245<ul>
5246
5247<li>
5248<p>Syntax:</p>
5249
5250<div class="source">
5251<div class="source">
5252<pre>unix_time_from_datetime_in_secs(datetime_value)
5253</pre></div></div></li>
5254
5255<li>
5256<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p></li>
5257
5258<li>Arguments:
5259
5260<ul>
5261
5262<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5263 </ul></li>
5264
5265<li>Return Value:
5266
5267<ul>
5268
5269<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5270
5271<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5272
5273<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5274
5275<li>any other non-datetime input value will cause a type error.</li>
5276 </ul></li>
5277</ul></div>
5278<div class="section">
5279<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5280
5281<ul>
5282
5283<li>
5284<p>Syntax:</p>
5285
5286<div class="source">
5287<div class="source">
5288<pre>unix_time_from_time_in_ms(time_value)
5289</pre></div></div></li>
5290
5291<li>
5292<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p></li>
5293
5294<li>Arguments:
5295
5296<ul>
5297
5298<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5299 </ul></li>
5300
5301<li>Return Value:
5302
5303<ul>
5304
5305<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5306
5307<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5308
5309<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5310
5311<li>any other non-datetime input value will cause a type error.</li>
5312 </ul></li>
5313
5314<li>
5315<p>Example:</p>
5316
5317<div class="source">
5318<div class="source">
5319<pre>{
5320 &quot;date&quot;: date_from_unix_time_in_days(15800),
5321 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5322 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5323}
5324</pre></div></div></li>
5325</ul>
5326
5327<ul>
5328
5329<li>
5330<p>The expected result is:</p>
5331
5332<div class="source">
5333<div class="source">
5334<pre>{ &quot;date&quot;: date(&quot;2013-04-05&quot;), &quot;datetime&quot;: datetime(&quot;2013-04-05T05:28:20.000Z&quot;), &quot;time&quot;: time(&quot;00:00:03.748Z&quot;) }
5335</pre></div></div></li>
5336</ul></div>
5337<div class="section">
5338<h3><a name="parse_dateparse_timeparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5339
5340<ul>
5341
5342<li>Syntax:</li>
5343</ul>
5344<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5345
5346<ul>
5347
5348<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5349
5350<li>Arguments:
5351
5352<ul>
5353
5354<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5355
5356<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>.Characters used to create date expression:</li>
5357
5358<li><tt>h</tt> hours</li>
5359
5360<li><tt>m</tt> minutes</li>
5361
5362<li><tt>s</tt> seconds</li>
5363
5364<li><tt>n</tt> milliseconds</li>
5365
5366<li><tt>a</tt> am/pm</li>
5367
5368<li><tt>z</tt> timezone</li>
5369
5370<li><tt>Y</tt> year</li>
5371
5372<li><tt>M</tt> month</li>
5373
5374<li><tt>D</tt> day</li>
5375
5376<li><tt>W</tt> weekday</li>
5377
5378<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5379 </ul></li>
5380
5381<li>Return Value:
5382
5383<ul>
5384
5385<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5386
5387<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5388
5389<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5390
5391<li>a type error will be raised if:</li>
5392
5393<li>the first argument is any other non-date value,</li>
5394
5395<li>the second argument is any other non-string value.</li>
5396 </ul></li>
5397
5398<li>
5399<p>Example:</p>
5400
5401<div class="source">
5402<div class="source">
5403<pre>parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5404</pre></div></div></li>
5405
5406<li>
5407<p>The expected result is:</p>
5408
5409<div class="source">
5410<div class="source">
5411<pre>time(&quot;00:30:30.000Z&quot;)
5412</pre></div></div></li>
5413</ul></div>
5414<div class="section">
5415<h3><a name="print_dateprint_timeprint_datetime"></a>print_date/print_time/print_datetime</h3>
5416
5417<ul>
5418
5419<li>
5420<p>Syntax:</p>
5421
5422<div class="source">
5423<div class="source">
5424<pre>print_date/print_time/print_datetime(date,formatting_expression)
5425</pre></div></div></li>
5426
5427<li>
5428<p>Creates a <tt>string</tt> representing a <tt>date/time/date_time</tt> value of the <tt>date</tt> using the formatting <tt>formatting_expression</tt></p></li>
5429
5430<li>Arguments:
5431
5432<ul>
5433
5434<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5435
5436<li><tt>formatting_expression</tt> a <tt>string</tt> value providing the formatting for <tt>date_expression</tt>. Characters used to create date expression:</li>
5437
5438<li><tt>h</tt> hours</li>
5439
5440<li><tt>m</tt> minutes</li>
5441
5442<li><tt>s</tt> seconds</li>
5443
5444<li><tt>n</tt> milliseconds</li>
5445
5446<li><tt>a</tt> am/pm</li>
5447
5448<li><tt>z</tt> timezone</li>
5449
5450<li><tt>Y</tt> year</li>
5451
5452<li><tt>M</tt> month</li>
5453
5454<li><tt>D</tt> day</li>
5455
5456<li><tt>W</tt> weekday</li>
5457
5458<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5459 </ul></li>
5460
5461<li>Return Value:
5462
5463<ul>
5464
5465<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5466
5467<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5468
5469<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5470
5471<li>a type error will be raised if:
5472
5473<ul>
5474
5475<li>the first argument is any other non-date value,</li>
5476
5477<li>the second argument is any other non-string value.</li>
5478 </ul></li>
5479 </ul></li>
5480
5481<li>
5482<p>Example:</p>
5483
5484<div class="source">
5485<div class="source">
5486<pre>print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5487</pre></div></div></li>
5488
5489<li>
5490<p>The expected result is:</p>
5491
5492<div class="source">
5493<div class="source">
5494<pre>&quot;30:30&quot;
5495</pre></div></div></li>
5496</ul></div>
5497<div class="section">
5498<h3><a name="get_interval_start_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5499
5500<ul>
5501
5502<li>
5503<p>Syntax:</p>
5504
5505<div class="source">
5506<div class="source">
5507<pre>get_interval_start/get_interval_end(interval)
5508</pre></div></div></li>
5509
5510<li>
5511<p>Gets the start/end of the given interval.</p></li>
5512
5513<li>Arguments:
5514
5515<ul>
5516
5517<li><tt>interval</tt>: the interval to be accessed.</li>
5518 </ul></li>
5519
5520<li>Return Value:
5521
5522<ul>
5523
5524<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the time instances of the interval) representing the starting or ending time,</li>
5525
5526<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5527
5528<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5529
5530<li>any other non-interval value will cause a type error.</li>
5531 </ul></li>
5532
5533<li>
5534<p>Example:</p>
5535
5536<div class="source">
5537<div class="source">
5538<pre>{
5539 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5540 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5541};
5542</pre></div></div></li>
5543</ul>
5544
5545<ul>
5546
5547<li>
5548<p>The expected result is:</p>
5549
5550<div class="source">
5551<div class="source">
5552<pre>{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5553</pre></div></div></li>
5554</ul></div>
5555<div class="section">
5556<h3><a name="get_interval_start_dateget_interval_start_datetimeget_interval_start_time_get_interval_end_dateget_interval_end_datetimeget_interval_end_time"></a>get_interval_start_date/get_interval_start_datetimeget_interval_start_time, get_interval_end_date/get_interval_end_datetime/get_interval_end_time</h3>
5557
5558<ul>
5559
5560<li>
5561<p>Syntax:</p>
5562
5563<div class="source">
5564<div class="source">
5565<pre>get_interval_start_date/get_interval_start_datetime/get_interval_start_time/get_interval_end_date/get_interval_end_datetime/get_interval_end_time(interval)
5566</pre></div></div></li>
5567
5568<li>
5569<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p></li>
5570
5571<li>Arguments:
5572
5573<ul>
5574
5575<li><tt>interval</tt>: the interval to be accessed.</li>
5576 </ul></li>
5577
5578<li>Return Value:
5579
5580<ul>
5581
5582<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5583
5584<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5585
5586<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5587
5588<li>any other non-interval value will cause a type error.</li>
5589 </ul></li>
5590
5591<li>
5592<p>Example:</p>
5593
5594<div class="source">
5595<div class="source">
5596<pre>{
5597 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5598 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5599 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5600 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5601 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5602 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5603};
5604</pre></div></div></li>
5605</ul>
5606
5607<ul>
5608
5609<li>
5610<p>The expected result is:</p>
5611
5612<div class="source">
5613<div class="source">
5614<pre>{
5615 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5616 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5617 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5618 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5619 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5620 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5621}
5622</pre></div></div></li>
5623</ul></div>
5624<div class="section">
5625<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5626
5627<ul>
5628
5629<li>
5630<p>Syntax:</p>
5631
5632<div class="source">
5633<div class="source">
5634<pre>get_overlapping_interval(interval1, interval2)
5635</pre></div></div></li>
5636
5637<li>
5638<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p></li>
5639
5640<li>Arguments:
5641
5642<ul>
5643
5644<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5645
5646<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5647 </ul></li>
5648
5649<li>Return Value:
5650
5651<ul>
5652
5653<li>an <tt>interval</tt> that is overlapping <tt>interval1</tt> and <tt>interval2</tt>. If <tt>interval1</tt> and <tt>interval2</tt> do not overlap <tt>null</tt> is returned. Note each interval must be of the same type.</li>
5654
5655<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5656
5657<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5658
5659<li>any other non-interval input value will cause a type error.</li>
5660 </ul></li>
5661
5662<li>
5663<p>Example:</p>
5664
5665<div class="source">
5666<div class="source">
5667<pre>{ &quot;overlap1&quot;: get_overlapping_interval(interval(time(&quot;11:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;12:23:39&quot;), time(&quot;23:18:00&quot;))),
5668 &quot;overlap2&quot;: get_overlapping_interval(interval(time(&quot;12:23:39&quot;), time(&quot;18:27:19&quot;)), interval(time(&quot;07:19:39&quot;), time(&quot;09:18:00&quot;))),
5669 &quot;overlap3&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;1999-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
5670 &quot;overlap4&quot;: get_overlapping_interval(interval(date(&quot;1980-11-30&quot;), date(&quot;2099-09-09&quot;)), interval(date(&quot;2013-01-01&quot;), date(&quot;2014-01-01&quot;))),
5671 &quot;overlap5&quot;: get_overlapping_interval(interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2009-10-10T23:18:00&quot;))),
5672 &quot;overlap6&quot;: get_overlapping_interval(interval(datetime(&quot;1989-03-04T12:23:39&quot;), datetime(&quot;2000-10-30T18:27:19&quot;)), interval(datetime(&quot;1844-03-03T11:19:39&quot;), datetime(&quot;1888-10-10T23:18:00&quot;)))
5673};
5674</pre></div></div></li>
5675
5676<li>
5677<p>The expected result is:</p>
5678
5679<div class="source">
5680<div class="source">
5681<pre>{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5682 &quot;overlap2&quot;: null,
5683 &quot;overlap3&quot;: null,
5684 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5685 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5686 &quot;overlap6&quot;: null
5687}
5688</pre></div></div></li>
5689</ul></div>
5690<div class="section">
5691<h3><a name="interval_bin"></a>interval_bin</h3>
5692
5693<ul>
5694
5695<li>
5696<p>Syntax:</p>
5697
5698<div class="source">
5699<div class="source">
5700<pre>interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5701</pre></div></div></li>
5702
5703<li>
5704<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p></li>
5705
5706<li>Arguments:
5707
5708<ul>
5709
5710<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5711
5712<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
5713
5714<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
5715
5716<ul>
5717
5718<li>datetime +|_ year_month_duration</li>
5719
5720<li>datetime +|_ day_time_duration</li>
5721
5722<li>date +|_ year_month_duration</li>
5723
5724<li>date +|_ day_time_duration</li>
5725
5726<li>time +|_ day_time_duration</li>
5727 </ul></li>
5728 </ul></li>
5729
5730<li>Return Value:
5731
5732<ul>
5733
5734<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type,</li>
5735
5736<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5737
5738<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5739
5740<li>a type error will be raised if:
5741
5742<ul>
5743
5744<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5745
5746<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5747 </ul></li>
5748 </ul></li>
5749
5750<li>
5751<p>Example:</p>
5752
5753<div class="source">
5754<div class="source">
5755<pre>{
5756 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5757 &quot;bin2&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;1990-01-01T00:00:00.000Z&quot;), year_month_duration(&quot;P6M&quot;)),
5758 &quot;bin3&quot;: interval_bin(time(&quot;12:23:34.930+07:00&quot;), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT1M&quot;)),
5759 &quot;bin4&quot;: interval_bin(datetime(&quot;1987-11-19T23:49:23.938&quot;), datetime(&quot;2013-01-01T00:00:00.000&quot;), day_time_duration(&quot;PT24H&quot;))
5760};
5761</pre></div></div></li>
5762
5763<li>
5764<p>The expected result is:</p>
5765
5766<div class="source">
5767<div class="source">
5768<pre>{
5769 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5770 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5771 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5772 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5773}
5774</pre></div></div></li>
5775</ul></div>
5776<div class="section">
5777<h3><a name="interval_start_from_datetimedatetime"></a>interval_start_from_date/time/datetime</h3>
5778
5779<ul>
5780
5781<li>
5782<p>Syntax:</p>
5783
5784<div class="source">
5785<div class="source">
5786<pre>interval_start_from_date/time/datetime(date/time/datetime, duration)
5787</pre></div></div></li>
5788
5789<li>
5790<p>Construct an <tt>interval</tt> value by the given starting <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> and the <tt>duration</tt> that the interval lasts.</p></li>
5791
5792<li>Arguments:
5793
5794<ul>
5795
5796<li><tt>date/time/datetime</tt>: a <tt>string</tt> representing a <tt>date</tt>, <tt>time</tt> or <tt>datetime</tt>, or a <tt>date</tt>/<tt>time</tt>/<tt>datetime</tt> value, representing the starting time point.</li>
5797
5798<li><tt>duration</tt>: a <tt>string</tt> or <tt>duration</tt> value representing the duration of the interval. Note that duration cannot be negative value.</li>
5799 </ul></li>
5800
5801<li>Return Value:
5802
5803<ul>
5804
5805<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
5806
5807<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5808
5809<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5810
5811<li>a type error will be raised if:
5812
5813<ul>
5814
5815<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5816
5817<li>or, the second argument is any other non-duration value.</li>
5818 </ul></li>
5819 </ul></li>
5820
5821<li>
5822<p>Example:</p>
5823
5824<div class="source">
5825<div class="source">
5826<pre>{
5827 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
5828 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
5829 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
5830};
5831</pre></div></div></li>
5832
5833<li>
5834<p>The expectecd result is:</p>
5835
5836<div class="source">
5837<div class="source">
5838<pre>{
5839 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
5840 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
5841 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
5842}
5843</pre></div></div></li>
5844</ul></div>
5845<div class="section">
5846<h3><a name="overlap_bins"></a>overlap_bins</h3>
5847
5848<ul>
5849
5850<li>
5851<p>Return Value:</p>
5852
5853<ul>
5854
5855<li>a <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value. Note that the internal type of this interval value should be the same as the <tt>time_to_bin</tt> type.</li>
5856 </ul></li>
5857
5858<li>
5859<p>Syntax:</p>
5860
5861<div class="source">
5862<div class="source">
5863<pre>overlap_bins(interval, time_bin_anchor, duration_bin_size)
5864</pre></div></div></li>
5865
5866<li>
5867<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p></li>
5868
5869<li>Arguments:
5870
5871<ul>
5872
5873<li><tt>interval</tt>: an <tt>interval</tt> value</li>
5874
5875<li><tt>time_bin_anchor</tt>: a date/time/datetime value representing an anchor of a bin starts. The type of this argument should be the same as the first <tt>time_to_bin</tt> argument.</li>
5876
5877<li><tt>duration_bin_size</tt>: the duration value representing the size of the bin, in the type of year_month_duration or day_time_duration. The type of this duration should be compatible with the type of <tt>time_to_bin</tt>, so that the arithmetic operation between <tt>time_to_bin</tt> and <tt>duration_bin_size</tt> is well_defined. Currently AsterixDB supports the following arithmetic operations:
5878
5879<ul>
5880
5881<li>datetime +|_ year_month_duration</li>
5882
5883<li>datetime +|_ day_time_duration</li>
5884
5885<li>date +|_ year_month_duration</li>
5886
5887<li>date +|_ day_time_duration</li>
5888
5889<li>time +|_ day_time_duration</li>
5890 </ul></li>
5891 </ul></li>
5892
5893<li>Return Value:
5894
5895<ul>
5896
5897<li>a ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>. Note that the internal type as <tt>time_to_bin</tt> and <tt>duration_bin_size</tt>.</li>
5898
5899<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5900
5901<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5902
5903<li>a type error will be raised if:
5904
5905<ul>
5906
5907<li>the first arugment is any other non-interval value,</li>
5908
5909<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
5910
5911<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5912 </ul></li>
5913 </ul></li>
5914
5915<li>
5916<p>Example:</p>
5917
5918<div class="source">
5919<div class="source">
5920<pre>{
5921 &quot;timebins&quot;: overlap_bins(interval(time(&quot;17:23:37&quot;), time(&quot;18:30:21&quot;)), time(&quot;00:00:00&quot;), day_time_duration(&quot;PT30M&quot;)),
5922 &quot;datebins&quot;: overlap_bins(interval(date(&quot;1984-03-17&quot;), date(&quot;2013-08-22&quot;)), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P10Y&quot;)),
5923 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
5924 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
5925};
5926</pre></div></div></li>
5927
5928<li>
5929<p>The expected result is:</p>
5930
5931<div class="source">
5932<div class="source">
5933<pre>{
5934 &quot;timebins&quot;: [
5935 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
5936 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
5937 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
5938 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
5939 ],
5940 &quot;datebins&quot;: [
5941 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
5942 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
5943 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
5944 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
5945 ],
5946 &quot;datetimebins&quot;: [
5947 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
5948 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
5949 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
5950 ]
5951};
5952</pre></div></div></li>
5953</ul>
5954<!-- ! Licensed to the Apache Software Foundation (ASF) under one
5955 ! or more contributor license agreements. See the NOTICE file
5956 ! distributed with this work for additional information
5957 ! regarding copyright ownership. The ASF licenses this file
5958 ! to you under the Apache License, Version 2.0 (the
5959 ! "License"); you may not use this file except in compliance
5960 ! with the License. You may obtain a copy of the License at
5961 !
5962 ! http://www.apache.org/licenses/LICENSE-2.0
5963 !
5964 ! Unless required by applicable law or agreed to in writing,
5965 ! software distributed under the License is distributed on an
5966 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
5967 ! KIND, either express or implied. See the License for the
5968 ! specific language governing permissions and limitations
5969 ! under the License.
5970 ! --></div>
5971<div class="section">
5972<h3><a name="interval_before_interval_after"></a>interval_before, interval_after</h3>
5973
5974<ul>
5975
5976<li>
5977<p>Syntax:</p>
5978
5979<div class="source">
5980<div class="source">
5981<pre>interval_before(interval1, interval2)
5982interval_after(interval1, interval2)
5983</pre></div></div></li>
5984
5985<li>
5986<p>These two functions check whether an interval happens before/after another interval.</p></li>
5987
5988<li>Arguments:
5989
5990<ul>
5991
5992<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
5993 </ul></li>
5994
5995<li>Return Value:
5996
5997<ul>
5998
5999<li>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>.</li>
6000
6001<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6002
6003<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6004
6005<li>any other non-interval input value will cause a type error.</li>
6006 </ul></li>
6007
6008<li>
6009<p>Examples:</p>
6010
6011<div class="source">
6012<div class="source">
6013<pre>{
6014 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6015 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6016 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6017 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6018};
6019</pre></div></div></li>
6020
6021<li>
6022<p>The expected result is:</p>
6023
6024<div class="source">
6025<div class="source">
6026<pre>{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6027</pre></div></div></li>
6028</ul></div>
6029<div class="section">
6030<h3><a name="interval_covers_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6031
6032<ul>
6033
6034<li>
6035<p>Syntax:</p>
6036
6037<div class="source">
6038<div class="source">
6039<pre>interval_covers(interval1, interval2)
6040interval_covered_by(interval1, interval2)
6041</pre></div></div></li>
6042
6043<li>
6044<p>These two functions check whether one interval covers the other interval.</p></li>
6045
6046<li>Arguments:
6047
6048<ul>
6049
6050<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6051 </ul></li>
6052
6053<li>
6054<p>Return Value:</p>
6055
6056<ul>
6057
6058<li>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</li>
6059 </ul>
6060
6061<div class="source">
6062<div class="source">
6063<pre>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end
6064
6065`interval_covered_by(interval1, interval2)` is true if and only if
6066
6067interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end
6068</pre></div></div>
6069
6070<ul>
6071
6072<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6073
6074<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6075
6076<li>any other non-interval input value will cause a type error.</li>
6077 </ul></li>
6078
6079<li>
6080<p>Examples:</p>
6081
6082<div class="source">
6083<div class="source">
6084<pre>{
6085 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6086 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6087 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6088 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6089};
6090</pre></div></div></li>
6091
6092<li>
6093<p>The expected result is:</p>
6094
6095<div class="source">
6096<div class="source">
6097<pre>{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6098</pre></div></div></li>
6099</ul></div>
6100<div class="section">
6101<h3><a name="interval_overlaps_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6102
6103<ul>
6104
6105<li>
6106<p>Syntax:</p>
6107
6108<div class="source">
6109<div class="source">
6110<pre>interval_overlaps(interval1, interval2)
6111interval_overlapped_by(interval1, interval2)
6112</pre></div></div></li>
6113
6114<li>
6115<p>These functions check whether two intervals overlap with each other.</p></li>
6116
6117<li>Arguments:
6118
6119<ul>
6120
6121<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6122 </ul></li>
6123
6124<li>
6125<p>Return Value:</p>
6126
6127<ul>
6128
6129<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if</li>
6130 </ul>
6131
6132<div class="source">
6133<div class="source">
6134<pre>interval1.start &lt; interval2.start
6135AND interval2.end &gt; interval1.end
6136AND interval1.end &gt; interval2.start
6137</pre></div></div>
6138<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6139
6140<div class="source">
6141<div class="source">
6142<pre>interval2.start &lt; interval1.start
6143AND interval1.end &gt; interval2.end
6144AND interval2.end &gt; interval1.start
6145</pre></div></div>
6146
6147<ul>
6148
6149<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6150
6151<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6152
6153<li>any other non-interval input value will cause a type error.</li>
6154 </ul>
6155<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>
6156
6157<li>
6158<p>Examples:</p>
6159
6160<div class="source">
6161<div class="source">
6162<pre>{
6163 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6164 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6165 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6166 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6167};
6168</pre></div></div></li>
6169
6170<li>
6171<p>The expected result is:</p>
6172
6173<div class="source">
6174<div class="source">
6175<pre>{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6176</pre></div></div></li>
6177</ul></div>
6178<div class="section">
6179<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6180<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>
6181
6182<ul>
6183
6184<li>
6185<p>Syntax:</p>
6186
6187<div class="source">
6188<div class="source">
6189<pre>interval_overlapping(interval1, interval2)
6190</pre></div></div></li>
6191
6192<li>
6193<p>This functions check whether two intervals share any points with each other.</p></li>
6194
6195<li>Arguments:
6196
6197<ul>
6198
6199<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6200 </ul></li>
6201
6202<li>
6203<p>Return Value:</p>
6204
6205<ul>
6206
6207<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</li>
6208 </ul>
6209
6210<div class="source">
6211<div class="source">
6212<pre>interval1.start &lt; interval2.end
6213AND interval1.end &gt; interval2.start
6214</pre></div></div>
6215
6216<ul>
6217
6218<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6219
6220<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6221
6222<li>any other non-interval input value will cause a type error.</li>
6223 </ul></li>
6224
6225<li>
6226<p>Examples:</p>
6227
6228<div class="source">
6229<div class="source">
6230<pre>{
6231 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6232 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6233 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6234 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6235};
6236</pre></div></div></li>
6237
6238<li>
6239<p>The expected result is:</p>
6240
6241<div class="source">
6242<div class="source">
6243<pre>{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6244</pre></div></div></li>
6245</ul></div>
6246<div class="section">
6247<h3><a name="interval_meets_interval_met_by"></a>interval_meets, interval_met_by</h3>
6248
6249<ul>
6250
6251<li>
6252<p>Syntax:</p>
6253
6254<div class="source">
6255<div class="source">
6256<pre>interval_meets(interval1, interval2)
6257interval_met_by(interval1, interval2)
6258</pre></div></div></li>
6259
6260<li>
6261<p>These two functions check whether an interval meets with another interval.</p></li>
6262
6263<li>Arguments:
6264
6265<ul>
6266
6267<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6268 </ul></li>
6269
6270<li>Return Value:
6271
6272<ul>
6273
6274<li>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.</li>
6275
6276<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6277
6278<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6279
6280<li>any other non-interval input value will cause a type error.</li>
6281 </ul></li>
6282
6283<li>
6284<p>Examples:</p>
6285
6286<div class="source">
6287<div class="source">
6288<pre>{
6289 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6290 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6291 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6292 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6293};
6294</pre></div></div></li>
6295
6296<li>
6297<p>The expected result is:</p>
6298
6299<div class="source">
6300<div class="source">
6301<pre>{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6302</pre></div></div></li>
6303</ul></div>
6304<div class="section">
6305<h3><a name="interval_starts_interval_started_by"></a>interval_starts, interval_started_by</h3>
6306
6307<ul>
6308
6309<li>
6310<p>Syntax:</p>
6311
6312<div class="source">
6313<div class="source">
6314<pre>interval_starts(interval1, interval2)
6315interval_started_by(interval1, interval2)
6316</pre></div></div></li>
6317
6318<li>
6319<p>These two functions check whether one interval starts with the other interval.</p></li>
6320
6321<li>Arguments:
6322
6323<ul>
6324
6325<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6326 </ul></li>
6327
6328<li>
6329<p>Return Value:</p>
6330
6331<ul>
6332
6333<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if</li>
6334 </ul>
6335
6336<div class="source">
6337<div class="source">
6338<pre>interval1.start = interval2.start
6339AND interval1.end &lt;= interval2.end
6340</pre></div></div>
6341<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6342
6343<div class="source">
6344<div class="source">
6345<pre>interval1.start = interval2.start
6346AND interval2.end &lt;= interval1.end
6347</pre></div></div>
6348
6349<ul>
6350
6351<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6352
6353<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6354
6355<li>any other non-interval input value will cause a type error.</li>
6356 </ul></li>
6357
6358<li>
6359<p>Examples:</p>
6360
6361<div class="source">
6362<div class="source">
6363<pre>{
6364 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6365 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6366 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6367 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6368};
6369</pre></div></div></li>
6370
6371<li>
6372<p>The expected result is:</p>
6373
6374<div class="source">
6375<div class="source">
6376<pre>{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6377</pre></div></div></li>
6378</ul></div>
6379<div class="section">
6380<h3><a name="interval_ends_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6381
6382<ul>
6383
6384<li>
6385<p>Syntax:</p>
6386
6387<div class="source">
6388<div class="source">
6389<pre>interval_ends(interval1, interval2)
6390interval_ended_by(interval1, interval2)
6391</pre></div></div></li>
6392
6393<li>
6394<p>These two functions check whether one interval ends with the other interval.</p></li>
6395
6396<li>Arguments:
6397
6398<ul>
6399
6400<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6401 </ul></li>
6402
6403<li>
6404<p>Return Value:</p>
6405
6406<ul>
6407
6408<li>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</li>
6409 </ul>
6410
6411<div class="source">
6412<div class="source">
6413<pre>interval1.end = interval2.end
6414AND interval1.start &gt;= interval2.start
6415
6416`interval_ended_by(interval1, interval2)` returns true if and only if
6417
6418interval2.end = interval1.end
6419AND interval2.start &gt;= interval1.start
6420</pre></div></div>
6421
6422<ul>
6423
6424<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6425
6426<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6427
6428<li>any other non-interval input value will cause a type error.</li>
6429 </ul></li>
6430
6431<li>
6432<p>Examples:</p>
6433
6434<div class="source">
6435<div class="source">
6436<pre>{
6437 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6438 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6439 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6440 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6441};
6442</pre></div></div></li>
6443
6444<li>
6445<p>The expected result is:</p>
6446
6447<div class="source">
6448<div class="source">
6449<pre>{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6450</pre></div></div></li>
6451</ul>
6452<!-- ! Licensed to the Apache Software Foundation (ASF) under one
6453 ! or more contributor license agreements. See the NOTICE file
6454 ! distributed with this work for additional information
6455 ! regarding copyright ownership. The ASF licenses this file
6456 ! to you under the Apache License, Version 2.0 (the
6457 ! "License"); you may not use this file except in compliance
6458 ! with the License. You may obtain a copy of the License at
6459 !
6460 ! http://www.apache.org/licenses/LICENSE-2.0
6461 !
6462 ! Unless required by applicable law or agreed to in writing,
6463 ! software distributed under the License is distributed on an
6464 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6465 ! KIND, either express or implied. See the License for the
6466 ! specific language governing permissions and limitations
6467 ! under the License.
6468 ! --></div></div>
6469<div class="section">
6470<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6471<div class="section">
6472<h3><a name="get_object_fields"></a>get_object_fields</h3>
6473
6474<ul>
6475
6476<li>
6477<p>Syntax:</p>
6478
6479<div class="source">
6480<div class="source">
6481<pre>get_object_fields(input_object)
6482</pre></div></div></li>
6483
6484<li>
6485<p>Access the object field names, type and open status for a given object.</p></li>
6486
6487<li>Arguments:
6488
6489<ul>
6490
6491<li><tt>input_object</tt> : a object value.</li>
6492 </ul></li>
6493
6494<li>Return Value:
6495
6496<ul>
6497
6498<li>an array of <tt>object</tt> values that include the field_name <tt>string</tt>, field_type <tt>string</tt>, is_open <tt>boolean</tt> (used for debug purposes only: <tt>true</tt> if field is open and <tt>false</tt> otherwise), and optional nested <tt>orderedList</tt> for the values of a nested object,</li>
6499
6500<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6501
6502<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6503
6504<li>any other non-object input value will cause a type error.</li>
6505 </ul></li>
6506
6507<li>
6508<p>Example:</p>
6509
6510<div class="source">
6511<div class="source">
6512<pre>get_object_fields(
6513 {
6514 &quot;id&quot;: 1,
6515 &quot;project&quot;: &quot;AsterixDB&quot;,
6516 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6517 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6518 }
6519 );
6520</pre></div></div></li>
6521
6522<li>
6523<p>The expected result is:</p>
6524
6525<div class="source">
6526<div class="source">
6527<pre>[
6528 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6529 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6530 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6531 &quot;nested&quot;: [
6532 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6533 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6534 ]
6535 },
6536 { &quot;field-name&quot;:
6537 &quot;related&quot;,
6538 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6539 &quot;is-open&quot;: false,
6540 &quot;list&quot;: [
6541 { &quot;field-type&quot;: &quot;STRING&quot; },
6542 { &quot;field-type&quot;: &quot;STRING&quot; },
6543 { &quot;field-type&quot;: &quot;STRING&quot; }
6544 ]
6545 }
6546]
6547</pre></div></div></li>
6548</ul>
6549<p>]</p></div>
6550<div class="section">
6551<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6552
6553<ul>
6554
6555<li>
6556<p>Syntax:</p>
6557
6558<div class="source">
6559<div class="source">
6560<pre>get_object_field_value(input_object, string)
6561</pre></div></div></li>
6562
6563<li>
6564<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p></li>
6565
6566<li>Arguments:
6567
6568<ul>
6569
6570<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6571
6572<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6573 </ul></li>
6574
6575<li>Return Value:
6576
6577<ul>
6578
6579<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6580
6581<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6582
6583<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6584
6585<li>a type error will be raised if:
6586
6587<ul>
6588
6589<li>the first argument is any other non-object value,</li>
6590
6591<li>or, the second argument is any other non-string value.</li>
6592 </ul></li>
6593 </ul></li>
6594
6595<li>
6596<p>Example:</p>
6597
6598<div class="source">
6599<div class="source">
6600<pre>get_object_field_value({
6601 &quot;id&quot;: 1,
6602 &quot;project&quot;: &quot;AsterixDB&quot;,
6603 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6604 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6605 },
6606 &quot;project&quot;
6607 );
6608</pre></div></div></li>
6609
6610<li>
6611<p>The expected result is:</p>
6612
6613<div class="source">
6614<div class="source">
6615<pre>&quot;AsterixDB&quot;
6616</pre></div></div></li>
6617</ul></div>
6618<div class="section">
6619<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6620
6621<ul>
6622
6623<li>
6624<p>Syntax:</p>
6625
6626<div class="source">
6627<div class="source">
6628<pre>object_remove_fields(input_object, field_names)
6629</pre></div></div></li>
6630
6631<li>
6632<p>Remove indicated fields from a object given a list of field names.</p></li>
6633
6634<li>Arguments:
6635
6636<ul>
6637
6638<li><tt>input_object</tt>: a object value.</li>
6639
6640<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6641 </ul></li>
6642
6643<li>
6644<p>Return Value:</p>
6645
6646<ul>
6647
6648<li>a new object value without the fields listed in the second argument,</li>
6649
6650<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6651
6652<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6653
6654<li>a type error will be raised if:
6655
6656<ul>
6657
6658<li>the first argument is any other non-object value,</li>
6659
6660<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6661 </ul></li>
6662 </ul></li>
6663</ul>
6664
6665<ul>
6666
6667<li>
6668<p>Example:</p>
6669
6670<div class="source">
6671<div class="source">
6672<pre>object_remove_fields(
6673 {
6674 &quot;id&quot;:1,
6675 &quot;project&quot;:&quot;AsterixDB&quot;,
6676 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6677 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6678 },
6679 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6680 );
6681</pre></div></div></li>
6682
6683<li>
6684<p>The expected result is:</p>
6685
6686<div class="source">
6687<div class="source">
6688<pre>{
6689 &quot;id&quot;:1,
6690 &quot;project&quot;:&quot;AsterixDB&quot;,
6691 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6692}
6693</pre></div></div></li>
6694</ul></div>
6695<div class="section">
6696<h3><a name="object_add_fields"></a>object_add_fields</h3>
6697
6698<ul>
6699
6700<li>
6701<p>Syntax:</p>
6702
6703<div class="source">
6704<div class="source">
6705<pre>object_add_fields(input_object, fields)
6706</pre></div></div></li>
6707
6708<li>
6709<p>Add fields to a object given a list of field names.</p></li>
6710
6711<li>Arguments:
6712
6713<ul>
6714
6715<li><tt>input_object</tt> : a object value.</li>
6716
6717<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6718 </ul></li>
6719
6720<li>Return Value:
6721
6722<ul>
6723
6724<li>a new object value with the new fields included,</li>
6725
6726<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6727
6728<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6729
6730<li>a type error will be raised if:
6731
6732<ul>
6733
6734<li>the first argument is any other non-object value,</li>
6735
6736<li>the second argument is any other non-array value, or contains non-object items.</li>
6737 </ul></li>
6738 </ul></li>
6739</ul>
6740
6741<ul>
6742
6743<li>
6744<p>Example:</p>
6745
6746<div class="source">
6747<div class="source">
6748<pre>object_add_fields(
6749 {
6750 &quot;id&quot;:1,
6751 &quot;project&quot;:&quot;AsterixDB&quot;,
6752 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6753 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6754 },
6755 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6756 );
6757</pre></div></div></li>
6758
6759<li>
6760<p>The expected result is:</p>
6761
6762<div class="source">
6763<div class="source">
6764<pre>{
6765 &quot;id&quot;:1,
6766 &quot;project&quot;:&quot;AsterixDB&quot;,
6767 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6768 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6769 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6770 }
6771</pre></div></div></li>
6772</ul></div>
6773<div class="section">
6774<h3><a name="object_merge"></a>object_merge</h3>
6775
6776<ul>
6777
6778<li>
6779<p>Syntax:</p>
6780
6781<div class="source">
6782<div class="source">
6783<pre>object_merge(object1, object2)
6784</pre></div></div></li>
6785
6786<li>
6787<p>Merge two different objects into a new object.</p></li>
6788
6789<li>Arguments:
6790
6791<ul>
6792
6793<li><tt>object1</tt> : a object value.</li>
6794
6795<li><tt>object2</tt> : a object value.</li>
6796 </ul></li>
6797
6798<li>Return Value:
6799
6800<ul>
6801
6802<li>a new object value with fields from both input objects. If a field&#x2019;s names in both objects are the same, an exception is issued,</li>
6803
6804<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6805
6806<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6807
6808<li>any other non-object input value will cause a type error.</li>
6809 </ul></li>
6810</ul>
6811
6812<ul>
6813
6814<li>
6815<p>Example:</p>
6816
6817<div class="source">
6818<div class="source">
6819<pre>object_merge(
6820 {
6821 &quot;id&quot;:1,
6822 &quot;project&quot;:&quot;AsterixDB&quot;,
6823 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6824 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6825 },
6826 {
6827 &quot;user_id&quot;: 22,
6828 &quot;employer&quot;: &quot;UC Irvine&quot;,
6829 &quot;employment_type&quot;: &quot;visitor&quot;
6830 }
6831 );
6832</pre></div></div></li>
6833
6834<li>
6835<p>The expected result is:</p>
6836
6837<div class="source">
6838<div class="source">
6839<pre>{
6840 &quot;employment_type&quot;: &quot;visitor&quot;,
6841 &quot;address&quot;: {
6842 &quot;city&quot;: &quot;Irvine&quot;,
6843 &quot;state&quot;: &quot;CA&quot;
6844 },
6845 &quot;related&quot;: [
6846 &quot;Hivestrix&quot;,
6847 &quot;Preglix&quot;,
6848 &quot;Apache VXQuery&quot;
6849 ],
6850 &quot;user_id&quot;: 22,
6851 &quot;project&quot;: &quot;AsterixDB&quot;,
6852 &quot;employer&quot;: &quot;UC Irvine&quot;,
6853 &quot;id&quot;: 1
6854}
6855</pre></div></div></li>
6856</ul>
6857<!-- ! Licensed to the Apache Software Foundation (ASF) under one
6858 ! or more contributor license agreements. See the NOTICE file
6859 ! distributed with this work for additional information
6860 ! regarding copyright ownership. The ASF licenses this file
6861 ! to you under the Apache License, Version 2.0 (the
6862 ! "License"); you may not use this file except in compliance
6863 ! with the License. You may obtain a copy of the License at
6864 !
6865 ! http://www.apache.org/licenses/LICENSE-2.0
6866 !
6867 ! Unless required by applicable law or agreed to in writing,
6868 ! software distributed under the License is distributed on an
6869 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6870 ! KIND, either express or implied. See the License for the
6871 ! specific language governing permissions and limitations
6872 ! under the License.
6873 ! --></div></div>
6874<div class="section">
6875<h2><a name="Aggregate_Functions_Array_Functions"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
6876<p>This section contains detailed descriptions of each AQL aggregate function (i.e., array function).</p>
6877<div class="section">
6878<h3><a name="sql-count"></a>sql-count</h3>
6879
6880<ul>
6881
6882<li>
6883<p>Syntax:</p>
6884
6885<div class="source">
6886<div class="source">
6887<pre>sql-count(collection)
6888</pre></div></div></li>
6889
6890<li>
6891<p>Gets the number of non-null and non-missing items in the given collection.</p></li>
6892
6893<li>Arguments:
6894
6895<ul>
6896
6897<li><tt>collection</tt> could be:
6898
6899<ul>
6900
6901<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
6902
6903<li>or, a <tt>null</tt> value,</li>
6904
6905<li>or, a <tt>missing</tt> value.</li>
6906 </ul></li>
6907 </ul></li>
6908
6909<li>Return Value:
6910
6911<ul>
6912
6913<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
6914
6915<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
6916
6917<li>any other non-array and non-multiset input value will cause an error.</li>
6918 </ul></li>
6919
6920<li>
6921<p>Example:</p>
6922
6923<div class="source">
6924<div class="source">
6925<pre>sql-count( ['hello', 'world', 1, 2, 3, null, missing] );
6926</pre></div></div></li>
6927</ul>
6928
6929<ul>
6930
6931<li>
6932<p>The expected result is:</p>
6933
6934<div class="source">
6935<div class="source">
6936<pre>5
6937</pre></div></div></li>
6938</ul></div>
6939<div class="section">
6940<h3><a name="sql-avg"></a>sql-avg</h3>
6941
6942<ul>
6943
6944<li>
6945<p>Syntax:</p>
6946
6947<div class="source">
6948<div class="source">
6949<pre>sql-avg(num_collection)
6950</pre></div></div></li>
6951
6952<li>
6953<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p></li>
6954
6955<li>Arguments:
6956
6957<ul>
6958
6959<li><tt>num_collection</tt> could be:
6960
6961<ul>
6962
6963<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
6964
6965<li>or, a <tt>null</tt> value,</li>
6966
6967<li>or, a <tt>missing</tt> value.</li>
6968 </ul></li>
6969 </ul></li>
6970
6971<li>Return Value:
6972
6973<ul>
6974
6975<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
6976
6977<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
6978
6979<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
6980
6981<li>any other non-array and non-multiset input value will cause a type error,</li>
6982
6983<li>any other non-numeric value in the input collection will cause a type error.</li>
6984 </ul></li>
6985
6986<li>
6987<p>Example:</p>
6988
6989<div class="source">
6990<div class="source">
6991<pre>sql-avg( [1.2, 2.3, 3.4, 0, null] );
6992</pre></div></div></li>
6993
6994<li>
6995<p>The expected result is:</p>
6996
6997<div class="source">
6998<div class="source">
6999<pre>1.725
7000</pre></div></div></li>
7001</ul></div>
7002<div class="section">
7003<h3><a name="sql-sum"></a>sql-sum</h3>
7004
7005<ul>
7006
7007<li>
7008<p>Syntax:</p>
7009
7010<div class="source">
7011<div class="source">
7012<pre>sql-sum(num_collection)
7013</pre></div></div></li>
7014
7015<li>
7016<p>Gets the sum of non-null and non-missing items in the given collection.</p></li>
7017
7018<li>Arguments:
7019
7020<ul>
7021
7022<li><tt>num_collection</tt> could be:
7023
7024<ul>
7025
7026<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7027
7028<li>or, a <tt>null</tt> value,</li>
7029
7030<li>or, a <tt>missing</tt> value.</li>
7031 </ul></li>
7032 </ul></li>
7033
7034<li>Return Value:
7035
7036<ul>
7037
7038<li>the sum of the non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
7039
7040<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7041
7042<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7043
7044<li>any other non-array and non-multiset input value will cause a type error,</li>
7045
7046<li>any other non-numeric value in the input collection will cause a type error.</li>
7047 </ul></li>
7048
7049<li>
7050<p>Example:</p>
7051
7052<div class="source">
7053<div class="source">
7054<pre>sql-sum( [1.2, 2.3, 3.4, 0, null, missing] );
7055</pre></div></div></li>
7056
7057<li>
7058<p>The expected result is:</p>
7059
7060<div class="source">
7061<div class="source">
7062<pre>6.9
7063</pre></div></div></li>
7064</ul></div>
7065<div class="section">
7066<h3><a name="sql-sql_min"></a>sql-sql_min</h3>
7067
7068<ul>
7069
7070<li>
7071<p>Syntax:</p>
7072
7073<div class="source">
7074<div class="source">
7075<pre>sql-min(num_collection)
7076</pre></div></div></li>
7077
7078<li>
7079<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p></li>
7080
7081<li>Arguments:
7082
7083<ul>
7084
7085<li><tt>num_collection</tt> could be:
7086
7087<ul>
7088
7089<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7090
7091<li>or, a <tt>null</tt> value,</li>
7092
7093<li>or, a <tt>missing</tt> value.</li>
7094 </ul></li>
7095 </ul></li>
7096
7097<li>Return Value:
7098
7099<ul>
7100
7101<li>the min value of non-null and non-missing values in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7102
7103<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7104
7105<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7106
7107<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7108
7109<li>any other non-array and non-multiset input value will cause a type error.</li>
7110 </ul></li>
7111
7112<li>
7113<p>Example:</p>
7114
7115<div class="source">
7116<div class="source">
7117<pre>sql-min( [1.2, 2.3, 3.4, 0, null, missing] );
7118</pre></div></div></li>
7119
7120<li>
7121<p>The expected result is:</p>
7122
7123<div class="source">
7124<div class="source">
7125<pre>0.0
7126</pre></div></div></li>
7127</ul></div>
7128<div class="section">
7129<h3><a name="sql-max"></a>sql-max</h3>
7130
7131<ul>
7132
7133<li>
7134<p>Syntax:</p>
7135
7136<div class="source">
7137<div class="source">
7138<pre>sql-max(num_collection)
7139</pre></div></div></li>
7140
7141<li>
7142<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p></li>
7143
7144<li>Arguments:
7145
7146<ul>
7147
7148<li><tt>num_collection</tt> could be:
7149
7150<ul>
7151
7152<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7153
7154<li>or, a <tt>null</tt> value,</li>
7155
7156<li>or, a <tt>missing</tt> value.</li>
7157 </ul></li>
7158 </ul></li>
7159
7160<li>Return Value:
7161
7162<ul>
7163
7164<li>the max value of non-null and non-missing numbers in the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7165
7166<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7167
7168<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7169
7170<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7171
7172<li>any other non-array and non-multiset input value will cause a type error.</li>
7173 </ul></li>
7174
7175<li>
7176<p>Example:</p>
7177
7178<div class="source">
7179<div class="source">
7180<pre>sql-max( [1.2, 2.3, 3.4, 0, null, missing] );
7181</pre></div></div></li>
7182
7183<li>
7184<p>The expected result is:</p>
7185
7186<div class="source">
7187<div class="source">
7188<pre>3.4
7189</pre></div></div></li>
7190</ul></div>
7191<div class="section">
7192<h3><a name="count"></a>count</h3>
7193
7194<ul>
7195
7196<li>
7197<p>Syntax:</p>
7198
7199<div class="source">
7200<div class="source">
7201<pre>count(collection)
7202</pre></div></div></li>
7203
7204<li>
7205<p>Gets the number of items in the given collection.</p></li>
7206
7207<li>Arguments:
7208
7209<ul>
7210
7211<li><tt>collection</tt> could be:
7212
7213<ul>
7214
7215<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
7216
7217<li>or a <tt>null</tt> value,</li>
7218
7219<li>or a <tt>missing</tt> value.</li>
7220 </ul></li>
7221 </ul></li>
7222
7223<li>Return Value:
7224
7225<ul>
7226
7227<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
7228
7229<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
7230 </ul></li>
7231
7232<li>
7233<p>Example:</p>
7234
7235<div class="source">
7236<div class="source">
7237<pre>count( [1, 2, null, missing] );
7238</pre></div></div></li>
7239
7240<li>
7241<p>The expected result is:</p>
7242
7243<div class="source">
7244<div class="source">
7245<pre>4
7246</pre></div></div></li>
7247</ul></div>
7248<div class="section">
7249<h3><a name="avg"></a>avg</h3>
7250
7251<ul>
7252
7253<li>
7254<p>Syntax:</p>
7255
7256<div class="source">
7257<div class="source">
7258<pre>avg(num_collection)
7259</pre></div></div></li>
7260
7261<li>
7262<p>Gets the average value of the numeric items in the given collection.</p></li>
7263
7264<li>Arguments:
7265
7266<ul>
7267
7268<li><tt>num_collection</tt> could be:
7269
7270<ul>
7271
7272<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7273
7274<li>or, a <tt>null</tt> value,</li>
7275
7276<li>or, a <tt>missing</tt> value.</li>
7277 </ul></li>
7278 </ul></li>
7279
7280<li>Return Value:
7281
7282<ul>
7283
7284<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
7285
7286<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7287
7288<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
7289
7290<li>any other non-numeric value in the input collection will cause a type error.</li>
7291 </ul></li>
7292
7293<li>
7294<p>Example:</p>
7295
7296<div class="source">
7297<div class="source">
7298<pre>avg( [100, 200, 300] );
7299</pre></div></div></li>
7300
7301<li>
7302<p>The expected result is:</p>
7303
7304<div class="source">
7305<div class="source">
7306<pre>[ 200.0 ]
7307</pre></div></div></li>
7308</ul></div>
7309<div class="section">
7310<h3><a name="sum"></a>sum</h3>
7311
7312<ul>
7313
7314<li>
7315<p>Syntax:</p>
7316
7317<div class="source">
7318<div class="source">
7319<pre>sum(num_collection)
7320</pre></div></div></li>
7321
7322<li>
7323<p>Gets the sum of the items in the given collection.</p></li>
7324
7325<li>Arguments:
7326
7327<ul>
7328
7329<li><tt>num_collection</tt> could be:
7330
7331<ul>
7332
7333<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7334
7335<li>or, a <tt>null</tt> value,</li>
7336
7337<li>or, a <tt>missing</tt> value.</li>
7338 </ul></li>
7339 </ul></li>
7340
7341<li>Return Value:
7342
7343<ul>
7344
7345<li>the sum of the numbers in the given collection. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
7346
7347<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7348
7349<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
7350
7351<li>any other non-numeric value in the input collection will cause a type error.</li>
7352 </ul></li>
7353
7354<li>
7355<p>Example:</p>
7356
7357<div class="source">
7358<div class="source">
7359<pre>sum( [100, 200, 300] );
7360</pre></div></div></li>
7361
7362<li>
7363<p>The expected result is:</p>
7364
7365<div class="source">
7366<div class="source">
7367<pre>600
7368</pre></div></div></li>
7369</ul></div>
7370<div class="section">
7371<h3><a name="sql-min"></a>sql-min</h3>
7372
7373<ul>
7374
7375<li>
7376<p>Syntax:</p>
7377
7378<div class="source">
7379<div class="source">
7380<pre>min(num_collection)
7381</pre></div></div></li>
7382
7383<li>
7384<p>Gets the min value of comparable items in the given collection.</p></li>
7385
7386<li>Arguments:
7387
7388<ul>
7389
7390<li><tt>num_collection</tt> could be:
7391
7392<ul>
7393
7394<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7395
7396<li>or, a <tt>null</tt> value,</li>
7397
7398<li>or, a <tt>missing</tt> value.</li>
7399 </ul></li>
7400 </ul></li>
7401
7402<li>Return Value:
7403
7404<ul>
7405
7406<li>the min value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7407
7408<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7409
7410<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
7411
7412<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7413
7414<li>any other non-array and non-multiset input value will cause a type error.</li>
7415 </ul></li>
7416
7417<li>
7418<p>Example:</p>
7419
7420<div class="source">
7421<div class="source">
7422<pre>min( [10.2, 100, 5] );
7423</pre></div></div></li>
7424
7425<li>
7426<p>The expected result is:</p>
7427
7428<div class="source">
7429<div class="source">
7430<pre>5.0
7431</pre></div></div></li>
7432</ul></div>
7433<div class="section">
7434<h3><a name="sql-max"></a>sql-max</h3>
7435
7436<ul>
7437
7438<li>
7439<p>Syntax:</p>
7440
7441<div class="source">
7442<div class="source">
7443<pre>max(num_collection)
7444</pre></div></div></li>
7445
7446<li>
7447<p>Gets the max value of numeric items in the given collection.</p></li>
7448
7449<li>Arguments:
7450
7451<ul>
7452
7453<li><tt>num_collection</tt> could be:
7454
7455<ul>
7456
7457<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7458
7459<li>or, a <tt>null</tt> value,</li>
7460
7461<li>or, a <tt>missing</tt> value.</li>
7462 </ul></li>
7463 </ul></li>
7464
7465<li>Return Value:
7466
7467<ul>
7468
7469<li>The max value of the given collection. The returning type is decided by the item type with the highest order in the type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among numeric items.</li>
7470
7471<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7472
7473<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
7474
7475<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7476
7477<li>any other non-array and non-multiset input value will cause a type error.</li>
7478 </ul></li>
7479
7480<li>
7481<p>Example:</p>
7482
7483<div class="source">
7484<div class="source">
7485<pre>max( [10.2, 100, 5] );
7486</pre></div></div></li>
7487
7488<li>
7489<p>The expected result is:</p>
7490
7491<div class="source">
7492<div class="source">
7493<pre>100.0
7494</pre></div></div></li>
7495</ul>
7496<!-- ! Licensed to the Apache Software Foundation (ASF) under one
7497 ! or more contributor license agreements. See the NOTICE file
7498 ! distributed with this work for additional information
7499 ! regarding copyright ownership. The ASF licenses this file
7500 ! to you under the Apache License, Version 2.0 (the
7501 ! "License"); you may not use this file except in compliance
7502 ! with the License. You may obtain a copy of the License at
7503 !
7504 ! http://www.apache.org/licenses/LICENSE-2.0
7505 !
7506 ! Unless required by applicable law or agreed to in writing,
7507 ! software distributed under the License is distributed on an
7508 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7509 ! KIND, either express or implied. See the License for the
7510 ! specific language governing permissions and limitations
7511 ! under the License.
7512 ! --></div></div>
7513<div class="section">
7514<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
7515<div class="section">
7516<h3><a name="greatest"></a>greatest</h3>
7517
7518<ul>
7519
7520<li>
7521<p>Syntax:</p>
7522
7523<div class="source">
7524<div class="source">
7525<pre>greatest(numeric_value1, numeric_value2, ...)
7526</pre></div></div></li>
7527
7528<li>
7529<p>Computes the greatest value among arguments.</p></li>
7530
7531<li>Arguments:
7532
7533<ul>
7534
7535<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
7536
7537<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
7538
7539<li>&#x2026;.</li>
7540 </ul></li>
7541
7542<li>Return Value:
7543
7544<ul>
7545
7546<li>the greatest values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
7547
7548<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
7549
7550<li>any other non-numeric input value will cause a type error.</li>
7551 </ul></li>
7552
7553<li>
7554<p>Example:</p>
7555
7556<div class="source">
7557<div class="source">
7558<pre>{ &quot;v1&quot;: greatest(1, 2, 3), &quot;v2&quot;: greatest(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
7559</pre></div></div></li>
7560</ul>
7561
7562<ul>
7563
7564<li>
7565<p>The expected result is:</p>
7566
7567<div class="source">
7568<div class="source">
7569<pre>{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
7570</pre></div></div></li>
7571</ul></div>
7572<div class="section">
7573<h3><a name="least"></a>least</h3>
7574
7575<ul>
7576
7577<li>
7578<p>Syntax:</p>
7579
7580<div class="source">
7581<div class="source">
7582<pre>least(numeric_value1, numeric_value2, ...)
7583</pre></div></div></li>
7584
7585<li>
7586<p>Computes the least value among arguments.</p></li>
7587
7588<li>Arguments:
7589
7590<ul>
7591
7592<li><tt>numeric_value1</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
7593
7594<li><tt>numeric_value2</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value,</li>
7595
7596<li>&#x2026;.</li>
7597 </ul></li>
7598
7599<li>Return Value:
7600
7601<ul>
7602
7603<li>the least values among arguments. The returning type is decided by the item type with the highest order in the numeric type promotion order (<tt>tinyint</tt>-&gt; <tt>smallint</tt>-&gt;<tt>integer</tt>-&gt;<tt>bigint</tt>-&gt;<tt>float</tt>-&gt;<tt>double</tt>) among items.</li>
7604
7605<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
7606
7607<li>any other non-numeric input value will cause a type error.</li>
7608 </ul></li>
7609
7610<li>
7611<p>Example:</p>
7612
7613<div class="source">
7614<div class="source">
7615<pre>{ &quot;v1&quot;: least(1, 2, 3), &quot;v2&quot;: least(float(&quot;0.5&quot;), double(&quot;-0.5&quot;), 5000) };
7616</pre></div></div></li>
7617</ul>
7618
7619<ul>
7620
7621<li>
7622<p>The expected result is:</p>
7623
7624<div class="source">
7625<div class="source">
7626<pre>{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
7627</pre></div></div></li>
7628</ul>
7629<!-- ! Licensed to the Apache Software Foundation (ASF) under one
7630 ! or more contributor license agreements. See the NOTICE file
7631 ! distributed with this work for additional information
7632 ! regarding copyright ownership. The ASF licenses this file
7633 ! to you under the Apache License, Version 2.0 (the
7634 ! "License"); you may not use this file except in compliance
7635 ! with the License. You may obtain a copy of the License at
7636 !
7637 ! http://www.apache.org/licenses/LICENSE-2.0
7638 !
7639 ! Unless required by applicable law or agreed to in writing,
7640 ! software distributed under the License is distributed on an
7641 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7642 ! KIND, either express or implied. See the License for the
7643 ! specific language governing permissions and limitations
7644 ! under the License.
7645 ! --></div></div>
7646<div class="section">
7647<h2><a name="Type_Functions_Back_to_TOC"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
7648<div class="section">
7649<h3><a name="is_array_isarray"></a>is_array (isarray)</h3>
7650
7651<ul>
7652
7653<li>
7654<p>Syntax:</p>
7655
7656<div class="source">
7657<div class="source">
7658<pre>is_array(expr)
7659</pre></div></div></li>
7660
7661<li>
7662<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p></li>
7663
7664<li>Arguments:
7665
7666<ul>
7667
7668<li><tt>expr</tt> : an expression (any type is allowed).</li>
7669 </ul></li>
7670
7671<li>Return Value:
7672
7673<ul>
7674
7675<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
7676
7677<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7678
7679<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
7680 </ul></li>
7681
7682<li>
7683<p>Example:</p>
7684
7685<div class="source">
7686<div class="source">
7687<pre>{
7688 &quot;a&quot;: is_array(true),
7689 &quot;b&quot;: is_array(false),
7690 &quot;c&quot;: isarray(null),
7691 &quot;d&quot;: isarray(missing),
7692 &quot;e&quot;: isarray(&quot;d&quot;),
7693 &quot;f&quot;: isarray(4.0),
7694 &quot;g&quot;: isarray(5),
7695 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
7696 &quot;i&quot;: isarray({&quot;a&quot;:1})
7697};
7698</pre></div></div></li>
7699</ul>
7700
7701<ul>
7702
7703<li>
7704<p>The expected result is:</p>
7705
7706<div class="source">
7707<div class="source">
7708<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false }
7709</pre></div></div></li>
7710</ul>
7711<p>The function has an alias <tt>isarray</tt>.</p></div>
7712<div class="section">
7713<h3><a name="is_boolean_isboolean_isbool"></a>is_boolean (isboolean, isbool)</h3>
7714
7715<ul>
7716
7717<li>
7718<p>Syntax:</p>
7719
7720<div class="source">
7721<div class="source">
7722<pre>is_boolean(expr)
7723</pre></div></div></li>
7724
7725<li>
7726<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p></li>
7727
7728<li>Arguments:
7729
7730<ul>
7731
7732<li><tt>expr</tt> : an expression (any type is allowed).</li>
7733 </ul></li>
7734
7735<li>Return Value:
7736
7737<ul>
7738
7739<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
7740
7741<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7742
7743<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
7744 </ul></li>
7745
7746<li>
7747<p>Example:</p>
7748
7749<div class="source">
7750<div class="source">
7751<pre>{
7752 &quot;a&quot;: isboolean(true),
7753 &quot;b&quot;: isboolean(false),
7754 &quot;c&quot;: is_boolean(null),
7755 &quot;d&quot;: is_boolean(missing),
7756 &quot;e&quot;: isbool(&quot;d&quot;),
7757 &quot;f&quot;: isbool(4.0),
7758 &quot;g&quot;: isbool(5),
7759 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
7760 &quot;i&quot;: isbool({&quot;a&quot;:1})
7761};
7762</pre></div></div></li>
7763</ul>
7764
7765<ul>
7766
7767<li>
7768<p>The expected result is:</p>
7769
7770<div class="source">
7771<div class="source">
7772<pre>{ &quot;a&quot;: true, &quot;b&quot;: true, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
7773</pre></div></div></li>
7774</ul>
7775<p>The function has two aliases, <tt>isboolean</tt> or <tt>isbool</tt>.</p></div>
7776<div class="section">
7777<h3><a name="is_number_isnumber_isnum"></a>is_number (isnumber, isnum)</h3>
7778
7779<ul>
7780
7781<li>
7782<p>Syntax:</p>
7783
7784<div class="source">
7785<div class="source">
7786<pre>is_number(expr)
7787</pre></div></div></li>
7788
7789<li>
7790<p>Checks whether the given expression is evaluated to be a numeric value.</p></li>
7791
7792<li>Arguments:
7793
7794<ul>
7795
7796<li><tt>expr</tt> : an expression (any type is allowed).</li>
7797 </ul></li>
7798
7799<li>Return Value:
7800
7801<ul>
7802
7803<li>a <tt>boolean</tt> on whether the argument is a <tt>smallint</tt>/<tt>tinyint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value or not,</li>
7804
7805<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7806
7807<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
7808 </ul></li>
7809
7810<li>
7811<p>Example:</p>
7812
7813<div class="source">
7814<div class="source">
7815<pre>{
7816 &quot;a&quot;: is_number(true),
7817 &quot;b&quot;: is_number(false),
7818 &quot;c&quot;: isnumber(null),
7819 &quot;d&quot;: isnumber(missing),
7820 &quot;e&quot;: isnumber(&quot;d&quot;),
7821 &quot;f&quot;: isnum(4.0),
7822 &quot;g&quot;: isnum(5),
7823 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
7824 &quot;i&quot;: isnum({&quot;a&quot;:1})
7825};
7826</pre></div></div></li>
7827</ul>
7828
7829<ul>
7830
7831<li>
7832<p>The expected result is:</p>
7833
7834<div class="source">
7835<div class="source">
7836<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: false, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: false, &quot;i&quot;: false }
7837</pre></div></div></li>
7838</ul>
7839<p>The function has two aliases, <tt>isnumber</tt> or <tt>isnum</tt>.</p></div>
7840<div class="section">
7841<h3><a name="is_object_isobject_isobj"></a>is_object (isobject, isobj)</h3>
7842
7843<ul>
7844
7845<li>
7846<p>Syntax:</p>
7847
7848<div class="source">
7849<div class="source">
7850<pre>is_object(expr)
7851</pre></div></div></li>
7852
7853<li>
7854<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p></li>
7855
7856<li>Arguments:
7857
7858<ul>
7859
7860<li><tt>expr</tt> : an expression (any type is allowed).</li>
7861 </ul></li>
7862
7863<li>Return Value:
7864
7865<ul>
7866
7867<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
7868
7869<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7870
7871<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
7872 </ul></li>
7873
7874<li>
7875<p>Example:</p>
7876
7877<div class="source">
7878<div class="source">
7879<pre>{
7880 &quot;a&quot;: is_object(true),
7881 &quot;b&quot;: is_object(false),
7882 &quot;c&quot;: isobject(null),
7883 &quot;d&quot;: isobject(missing),
7884 &quot;e&quot;: isobj(&quot;d&quot;),
7885 &quot;f&quot;: isobj(4.0),
7886 &quot;g&quot;: isobj(5),
7887 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
7888 &quot;i&quot;: isobj({&quot;a&quot;:1})
7889};
7890</pre></div></div></li>
7891</ul>
7892
7893<ul>
7894
7895<li>
7896<p>The expected result is:</p>
7897<p>{ &#x201c;a&#x201d;: false, &#x201c;b&#x201d;: false, &#x201c;c&#x201d;: null, &#x201c;e&#x201d;: false, &#x201c;f&#x201d;: false, &#x201c;g&#x201d;: false, &#x201c;h&#x201d;: false, &#x201c;i&#x201d;: true }</p></li>
7898</ul>
7899<p>The function has two aliases, <tt>isobject</tt> or <tt>isobj</tt>.</p></div>
7900<div class="section">
7901<h3><a name="is_string_isstring_isstr"></a>is_string (isstring, isstr)</h3>
7902
7903<ul>
7904
7905<li>
7906<p>Syntax:</p>
7907
7908<div class="source">
7909<div class="source">
7910<pre>is_string(expr)
7911</pre></div></div></li>
7912
7913<li>
7914<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p></li>
7915
7916<li>Arguments:
7917
7918<ul>
7919
7920<li><tt>expr</tt> : an expression (any type is allowed).</li>
7921 </ul></li>
7922
7923<li>Return Value:
7924
7925<ul>
7926
7927<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
7928
7929<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7930
7931<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
7932 </ul></li>
7933
7934<li>
7935<p>Example:</p>
7936
7937<div class="source">
7938<div class="source">
7939<pre>{
7940 &quot;a&quot;: is_string(true),
7941 &quot;b&quot;: isstring(false),
7942 &quot;c&quot;: isstring(null),
7943 &quot;d&quot;: isstr(missing),
7944 &quot;e&quot;: isstr(&quot;d&quot;),
7945 &quot;f&quot;: isstr(4.0),
7946 &quot;g&quot;: isstr(5),
7947 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
7948 &quot;i&quot;: isstr({&quot;a&quot;:1})
7949};
7950</pre></div></div></li>
7951</ul>
7952
7953<ul>
7954
7955<li>
7956<p>The expected result is:</p>
7957
7958<div class="source">
7959<div class="source">
7960<pre>{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: false, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false }
7961</pre></div></div></li>
7962</ul>
7963<p>The function has two aliases, <tt>isstring</tt> or <tt>isstr</tt>.</p></div>
7964<div class="section">
7965<h3><a name="is_null"></a>is_null</h3>
7966
7967<ul>
7968
7969<li>
7970<p>Syntax:</p>
7971
7972<div class="source">
7973<div class="source">
7974<pre>is_null(expr)
7975</pre></div></div></li>
7976
7977<li>
7978<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p></li>
7979
7980<li>Arguments:
7981
7982<ul>
7983
7984<li><tt>expr</tt> : an expression (any type is allowed).</li>
7985 </ul></li>
7986
7987<li>Return Value:
7988
7989<ul>
7990
7991<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
7992
7993<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
7994 </ul></li>
7995
7996<li>
7997<p>Example:</p>
7998
7999<div class="source">
8000<div class="source">
8001<pre>{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
8002</pre></div></div></li>
8003</ul>
8004
8005<ul>
8006
8007<li>
8008<p>The expected result is:</p>
8009
8010<div class="source">
8011<div class="source">
8012<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false }
8013</pre></div></div></li>
8014</ul>
8015<p>The function has an alias <tt>isnull</tt>.</p></div>
8016<div class="section">
8017<h3><a name="is_missing"></a>is_missing</h3>
8018
8019<ul>
8020
8021<li>
8022<p>Syntax:</p>
8023
8024<div class="source">
8025<div class="source">
8026<pre>is_missing(expr)
8027</pre></div></div></li>
8028
8029<li>
8030<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p></li>
8031
8032<li>Arguments:
8033
8034<ul>
8035
8036<li><tt>expr</tt> : an expression (any type is allowed).</li>
8037 </ul></li>
8038
8039<li>Return Value:
8040
8041<ul>
8042
8043<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
8044 </ul></li>
8045
8046<li>
8047<p>Example:</p>
8048
8049<div class="source">
8050<div class="source">
8051<pre>{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
8052</pre></div></div></li>
8053</ul>
8054
8055<ul>
8056
8057<li>
8058<p>The expected result is:</p>
8059
8060<div class="source">
8061<div class="source">
8062<pre>{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
8063</pre></div></div></li>
8064</ul>
8065<p>The function has an alias <tt>ismissing</tt>.</p></div>
8066<div class="section">
8067<h3><a name="is_unknown"></a>is_unknown</h3>
8068
8069<ul>
8070
8071<li>
8072<p>Syntax:</p>
8073
8074<div class="source">
8075<div class="source">
8076<pre>is_unknown(expr)
8077</pre></div></div></li>
8078
8079<li>
8080<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p></li>
8081
8082<li>Arguments:
8083
8084<ul>
8085
8086<li><tt>expr</tt> : an expression (any type is allowed).</li>
8087 </ul></li>
8088
8089<li>Return Value:
8090
8091<ul>
8092
8093<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt>/`<tt>missing</tt> value (<tt>true</tt>) or not (<tt>false</tt>).</li>
8094 </ul></li>
8095
8096<li>
8097<p>Example:</p>
8098
8099<div class="source">
8100<div class="source">
8101<pre>{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
8102</pre></div></div></li>
8103</ul>
8104
8105<ul>
8106
8107<li>
8108<p>The expected result is:</p>
8109
8110<div class="source">
8111<div class="source">
8112<pre>{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
8113</pre></div></div></li>
8114</ul>
8115<p>The function has an alias <tt>isunknown</tt>.</p>
8116<!-- ! Licensed to the Apache Software Foundation (ASF) under one
8117 ! or more contributor license agreements. See the NOTICE file
8118 ! distributed with this work for additional information
8119 ! regarding copyright ownership. The ASF licenses this file
8120 ! to you under the Apache License, Version 2.0 (the
8121 ! "License"); you may not use this file except in compliance
8122 ! with the License. You may obtain a copy of the License at
8123 !
8124 ! http://www.apache.org/licenses/LICENSE-2.0
8125 !
8126 ! Unless required by applicable law or agreed to in writing,
8127 ! software distributed under the License is distributed on an
8128 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8129 ! KIND, either express or implied. See the License for the
8130 ! specific language governing permissions and limitations
8131 ! under the License.
8132 ! --></div></div>
8133<div class="section">
8134<h2><a name="Miscellaneous_Functions_Back_to_TOC"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a> <font size="4"><a href="#toc">[Back to TOC]</a></font></h2>
8135<div class="section">
8136<h3><a name="uuid"></a>uuid</h3>
8137
8138<ul>
8139
8140<li>
8141<p>Syntax:</p>
8142
8143<div class="source">
8144<div class="source">
8145<pre>uuid()
8146</pre></div></div></li>
8147
8148<li>
8149<p>Generates a <tt>uuid</tt>.</p></li>
8150
8151<li>Arguments:
8152
8153<ul>
8154
8155<li>none</li>
8156 </ul></li>
8157
8158<li>Return Value:
8159
8160<ul>
8161
8162<li>a generated, random <tt>uuid</tt>.</li>
8163 </ul></li>
8164</ul></div>
8165<div class="section">
8166<h3><a name="len"></a>len</h3>
8167
8168<ul>
8169
8170<li>
8171<p>Syntax:</p>
8172<p>len(array)</p></li>
8173
8174<li>
8175<p>Returns the length of the array array.</p></li>
8176
8177<li>Arguments:
8178
8179<ul>
8180
8181<li><tt>array</tt> : an <tt>array</tt>, <tt>multiset</tt>, <tt>null</tt>, or <tt>missing</tt>, represents the collection that needs to be checked.</li>
8182 </ul></li>
8183
8184<li>Return Value:
8185
8186<ul>
8187
8188<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
8189
8190<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
8191
8192<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
8193 </ul></li>
8194
8195<li>
8196<p>Example:</p>
8197
8198<div class="source">
8199<div class="source">
8200<pre>len([&quot;Hello&quot;, &quot;World&quot;])
8201</pre></div></div></li>
8202</ul>
8203
8204<ul>
8205
8206<li>
8207<p>The expected result is:</p>
8208
8209<div class="source">
8210<div class="source">
8211<pre>2
8212</pre></div></div></li>
8213</ul></div>
8214<div class="section">
8215<h3><a name="not"></a>not</h3>
8216
8217<ul>
8218
8219<li>
8220<p>Syntax:</p>
8221
8222<div class="source">
8223<div class="source">
8224<pre>not(expr)
8225</pre></div></div></li>
8226
8227<li>
8228<p>Inverts a <tt>boolean</tt> value</p></li>
8229
8230<li>Arguments:
8231
8232<ul>
8233
8234<li><tt>expr</tt> : an expression</li>
8235 </ul></li>
8236
8237<li>Return Value:
8238
8239<ul>
8240
8241<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
8242
8243<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
8244
8245<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
8246
8247<li>other non-boolean argument value will cause a type error.</li>
8248 </ul></li>
8249
8250<li>
8251<p>Example:</p>
8252
8253<div class="source">
8254<div class="source">
8255<pre>{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
8256</pre></div></div></li>
8257
8258<li>
8259<p>The expected result is:</p>
8260
8261<div class="source">
8262<div class="source">
8263<pre>{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
8264</pre></div></div></li>
8265</ul></div>
8266<div class="section">
8267<h3><a name="range"></a>range</h3>
8268
8269<ul>
8270
8271<li>
8272<p>Syntax:</p>
8273
8274<div class="source">
8275<div class="source">
8276<pre>range(start_numeric_value, end_numeric_value)
8277</pre></div></div></li>
8278
8279<li>
8280<p>Generates a series of <tt>bigint</tt> values based start the <tt>start_numeric_value</tt> until the <tt>end_numeric_value</tt>.</p></li>
8281
8282<li>Arguments:</li>
8283
8284<li><tt>start_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the start value.</li>
8285
8286<li><tt>end_numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value representing the max final value.</li>
8287
8288<li>Return Value:
8289
8290<ul>
8291
8292<li>an array that starts with the integer value of <tt>start_numeric_value</tt> and ends with the integer value of <tt>end_numeric_value</tt>, where the value of each entry in the array is the integer successor of the value in the preceding entry.</li>
8293 </ul></li>
8294
8295<li>
8296<p>Example:</p>
8297
8298<div class="source">
8299<div class="source">
8300<pre>range(0, 3);
8301</pre></div></div></li>
8302
8303<li>
8304<p>The expected result is:</p>
8305
8306<div class="source">
8307<div class="source">
8308<pre>[ 0, 1, 2, 3 ]
8309</pre></div></div></li>
8310</ul></div>
8311<div class="section">
8312<h3><a name="switch_case"></a>switch_case</h3>
8313
8314<ul>
8315
8316<li>
8317<p>Syntax:</p>
8318
8319<div class="source">
8320<div class="source">
8321<pre>switch_case(
8322 condition,
8323 case1, case1_result,
8324 case2, case2_result,
8325 ...,
8326 default, default_result
8327)
8328</pre></div></div></li>
8329
8330<li>
8331<p>Switches amongst a sequence of cases and returns the result of the first matching case. If no match is found, the result of the default case is returned.</p></li>
8332
8333<li>Arguments:
8334
8335<ul>
8336
8337<li><tt>condition</tt>: a variable (any type is allowed).</li>
8338
8339<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
8340
8341<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
8342 </ul></li>
8343
8344<li>Return Value:
8345
8346<ul>
8347
8348<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
8349 </ul></li>
8350
8351<li>
8352<p>Example 1:</p>
8353
8354<div class="source">
8355<div class="source">
8356<pre>switch_case(
8357 &quot;a&quot;,
8358 &quot;a&quot;, 0,
8359 &quot;x&quot;, 1,
8360 &quot;y&quot;, 2,
8361 &quot;z&quot;, 3
8362);
8363</pre></div></div></li>
8364</ul>
8365
8366<ul>
8367
8368<li>
8369<p>The expected result is:</p>
8370
8371<div class="source">
8372<div class="source">
8373<pre>0
8374</pre></div></div></li>
8375
8376<li>
8377<p>Example 2:</p>
8378
8379<div class="source">
8380<div class="source">
8381<pre>switch_case(
8382 &quot;a&quot;,
8383 &quot;x&quot;, 1,
8384 &quot;y&quot;, 2,
8385 &quot;z&quot;, 3
8386);
8387</pre></div></div></li>
8388
8389<li>
8390<p>The expected result is:</p>
8391
8392<div class="source">
8393<div class="source">
8394<pre>3
8395</pre></div></div></li>
8396</ul></div>
8397<div class="section">
8398<h3><a name="deep_equal"></a>deep_equal</h3>
8399
8400<ul>
8401
8402<li>
8403<p>Syntax:</p>
8404
8405<div class="source">
8406<div class="source">
8407<pre>deep_equal(expr1, expr2)
8408</pre></div></div></li>
8409</ul>
8410
8411<ul>
8412
8413<li>Assess the equality between two expressions of any type (e.g., object, arrays, or multiset). Two objects are deeply equal iff both their types and values are equal.</li>
8414
8415<li>Arguments:
8416
8417<ul>
8418
8419<li><tt>expr1</tt> : an expression,</li>
8420
8421<li><tt>expr2</tt> : an expression.</li>
8422 </ul></li>
8423
8424<li>Return Value:
8425
8426<ul>
8427
8428<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
8429
8430<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
8431
8432<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
8433 </ul></li>
8434</ul>
8435
8436<ul>
8437
8438<li>
8439<p>Example:</p>
8440
8441<div class="source">
8442<div class="source">
8443<pre>deep_equal(
8444 {
8445 &quot;id&quot;:1,
8446 &quot;project&quot;:&quot;AsterixDB&quot;,
8447 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
8448 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
8449 },
8450 {
8451 &quot;id&quot;:1,
8452 &quot;project&quot;:&quot;AsterixDB&quot;,
8453 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
8454 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
8455 }
8456);
8457</pre></div></div></li>
8458
8459<li>
8460<p>The expected result is:</p>
8461
8462<div class="source">
8463<div class="source">
8464<pre>false
8465</pre></div></div></li>
8466</ul></div></div>
8467 </div>
8468 </div>
8469 </div>
8470
8471 <hr/>
8472
8473 <footer>
8474 <div class="container-fluid">
8475 <div class="row span12">Copyright &copy; 2017
8476 <a href="https://www.apache.org/">The Apache Software Foundation</a>.
8477 All Rights Reserved.
8478
8479 </div>
8480
8481 <?xml version="1.0" encoding="UTF-8"?>
8482<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
8483 feather logo, and the Apache AsterixDB project logo are either
8484 registered trademarks or trademarks of The Apache Software
8485 Foundation in the United States and other countries.
8486 All other marks mentioned may be trademarks or registered
8487 trademarks of their respective owners.</div>
8488
8489
8490 </div>
8491 </footer>
8492 </body>
8493</html>