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