blob: a17f9627863fbeed18c14c9e6b3850113119209e [file] [log] [blame]
Ian Maxon3355d4c2021-12-13 12:38:15 -08001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/aql/builtins.md at 2021-12-13
4 | Rendered using Apache Maven Fluido Skin 1.7
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20211213" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; Builtin Functions</title>
13 <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
14 <link rel="stylesheet" href="../css/site.css" />
15 <link rel="stylesheet" href="../css/print.css" media="print" />
16 <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2021-12-13</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.7.1</li>
31 <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="../SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="../interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
61 <li><a href="../sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
62 <li class="nav-header">Deprecated</li>
63 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
64 <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
65 <li class="active"><a href="#"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
66</ul>
67 <hr />
68 <div id="poweredBy">
69 <div class="clear"></div>
70 <div class="clear"></div>
71 <div class="clear"></div>
72 <div class="clear"></div>
73<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
74 </div>
75 </div>
76 </div>
77 <div id="bodyColumn" class="span10" >
78<!--
79 ! Licensed to the Apache Software Foundation (ASF) under one
80 ! or more contributor license agreements. See the NOTICE file
81 ! distributed with this work for additional information
82 ! regarding copyright ownership. The ASF licenses this file
83 ! to you under the Apache License, Version 2.0 (the
84 ! "License"); you may not use this file except in compliance
85 ! with the License. You may obtain a copy of the License at
86 !
87 ! http://www.apache.org/licenses/LICENSE-2.0
88 !
89 ! Unless required by applicable law or agreed to in writing,
90 ! software distributed under the License is distributed on an
91 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
92 ! KIND, either express or implied. See the License for the
93 ! specific language governing permissions and limitations
94 ! under the License.
95 !-->
96<h1>Builtin Functions</h1><!--
97 ! Licensed to the Apache Software Foundation (ASF) under one
98 ! or more contributor license agreements. See the NOTICE file
99 ! distributed with this work for additional information
100 ! regarding copyright ownership. The ASF licenses this file
101 ! to you under the Apache License, Version 2.0 (the
102 ! "License"); you may not use this file except in compliance
103 ! with the License. You may obtain a copy of the License at
104 !
105 ! http://www.apache.org/licenses/LICENSE-2.0
106 !
107 ! Unless required by applicable law or agreed to in writing,
108 ! software distributed under the License is distributed on an
109 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
110 ! KIND, either express or implied. See the License for the
111 ! specific language governing permissions and limitations
112 ! under the License.
113 !-->
114
115<div class="section">
116<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
117<ul>
118
119<li><a href="#NumericFunctions">Numeric Functions</a></li>
120<li><a href="#StringFunctions">String Functions</a></li>
121<li><a href="#BinaryFunctions">Binary Functions</a></li>
122<li><a href="#SpatialFunctions">Spatial Functions</a></li>
123<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
124<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
125<li><a href="#TemporalFunctions">Temporal Functions</a></li>
126<li><a href="#ObjectFunctions">Object Functions</a></li>
127<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
128<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
129<li><a href="#TypeFunctions">Type Functions</a></li>
130<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
131<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
132</ul><!--
133 ! Licensed to the Apache Software Foundation (ASF) under one
134 ! or more contributor license agreements. See the NOTICE file
135 ! distributed with this work for additional information
136 ! regarding copyright ownership. The ASF licenses this file
137 ! to you under the Apache License, Version 2.0 (the
138 ! "License"); you may not use this file except in compliance
139 ! with the License. You may obtain a copy of the License at
140 !
141 ! http://www.apache.org/licenses/LICENSE-2.0
142 !
143 ! Unless required by applicable law or agreed to in writing,
144 ! software distributed under the License is distributed on an
145 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
146 ! KIND, either express or implied. See the License for the
147 ! specific language governing permissions and limitations
148 ! under the License.
149 !-->
150
151<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><!--
152 ! Licensed to the Apache Software Foundation (ASF) under one
153 ! or more contributor license agreements. See the NOTICE file
154 ! distributed with this work for additional information
155 ! regarding copyright ownership. The ASF licenses this file
156 ! to you under the Apache License, Version 2.0 (the
157 ! "License"); you may not use this file except in compliance
158 ! with the License. You may obtain a copy of the License at
159 !
160 ! http://www.apache.org/licenses/LICENSE-2.0
161 !
162 ! Unless required by applicable law or agreed to in writing,
163 ! software distributed under the License is distributed on an
164 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
165 ! KIND, either express or implied. See the License for the
166 ! specific language governing permissions and limitations
167 ! under the License.
168 !-->
169</div>
170<div class="section">
171<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
172<div class="section">
173<h3><a name="abs"></a>abs</h3>
174<ul>
175
176<li>
177
178<p>Syntax:</p>
179
180<div>
181<div>
182<pre class="source">abs(numeric_value)
183</pre></div></div>
184</li>
185<li>
186
187<p>Computes the absolute value of the argument.</p>
188</li>
189<li>Arguments:
190<ul>
191
192<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>
193</ul>
194</li>
195<li>Return Value:
196<ul>
197
198<li>The absolute value of the argument with the same type as the input argument,</li>
199<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
200<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
201<li>any other non-numeric input value will cause a type error.</li>
202</ul>
203</li>
204<li>
205
206<p>Example:</p>
207
208<div>
209<div>
210<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;)) };
211</pre></div></div>
212</li>
213<li>
214
215<p>The expected result is:</p>
216
217<div>
218<div>
219<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 }
220</pre></div></div>
221</li>
222</ul></div>
223<div class="section">
224<h3><a name="acos"></a>acos</h3>
225<ul>
226
227<li>
228
229<p>Syntax:</p>
230
231<div>
232<div>
233<pre class="source">acos(numeric_value)
234</pre></div></div>
235</li>
236<li>
237
238<p>Computes the arc cosine value of the argument.</p>
239</li>
240<li>Arguments:
241<ul>
242
243<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>
244</ul>
245</li>
246<li>Return Value:
247<ul>
248
249<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>
250<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
251<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
252<li>any other non-numeric input value will cause a type error,</li>
253<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
254</ul>
255</li>
256<li>
257
258<p>Example:</p>
259
260<div>
261<div>
262<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;)) };
263</pre></div></div>
264</li>
265<li>
266
267<p>The expected result is:</p>
268
269<div>
270<div>
271<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 }
272</pre></div></div>
273</li>
274</ul></div>
275<div class="section">
276<h3><a name="asin"></a>asin</h3>
277<ul>
278
279<li>
280
281<p>Syntax:</p>
282
283<div>
284<div>
285<pre class="source">asin(numeric_value)
286</pre></div></div>
287</li>
288<li>
289
290<p>Computes the arc sine value of the argument.</p>
291</li>
292<li>Arguments:
293<ul>
294
295<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>
296</ul>
297</li>
298<li>Return Value:
299<ul>
300
301<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>
302<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
303<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
304<li>any other non-numeric input value will cause a type error,</li>
305<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
306</ul>
307</li>
308<li>
309
310<p>Example:</p>
311
312<div>
313<div>
314<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;)) };
315</pre></div></div>
316</li>
317<li>
318
319<p>The expected result is:</p>
320
321<div>
322<div>
323<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 }
324</pre></div></div>
325</li>
326</ul></div>
327<div class="section">
328<h3><a name="atan"></a>atan</h3>
329<ul>
330
331<li>
332
333<p>Syntax:</p>
334
335<div>
336<div>
337<pre class="source">atan(numeric_value)
338</pre></div></div>
339</li>
340<li>
341
342<p>Computes the arc tangent value of the argument.</p>
343</li>
344<li>Arguments:
345<ul>
346
347<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>
348</ul>
349</li>
350<li>Return Value:
351<ul>
352
353<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
354<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
355<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
356<li>any other non-numeric input value will cause a type error.</li>
357</ul>
358</li>
359<li>
360
361<p>Example:</p>
362
363<div>
364<div>
365<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;)) };
366</pre></div></div>
367</li>
368<li>
369
370<p>The expected result is:</p>
371
372<div>
373<div>
374<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 }
375</pre></div></div>
376</li>
377</ul></div>
378<div class="section">
379<h3><a name="atan2"></a>atan2</h3>
380<ul>
381
382<li>
383
384<p>Syntax:</p>
385
386<div>
387<div>
388<pre class="source">atan2(numeric_value1, numeric_value2)
389</pre></div></div>
390</li>
391<li>
392
393<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
394</li>
395<li>Arguments:
396<ul>
397
398<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>
399<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>
400</ul>
401</li>
402<li>Return Value:
403<ul>
404
405<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
406<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
407<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
408<li>any other non-numeric input value will cause a type error.</li>
409</ul>
410</li>
411<li>
412
413<p>Example:</p>
414
415<div>
416<div>
417<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;)) };
418</pre></div></div>
419</li>
420<li>
421
422<p>The expected result is:</p>
423
424<div>
425<div>
426<pre class="source">{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
427</pre></div></div>
428</li>
429</ul></div>
430<div class="section">
431<h3><a name="ceil"></a>ceil</h3>
432<ul>
433
434<li>
435
436<p>Syntax:</p>
437
438<div>
439<div>
440<pre class="source">ceil(numeric_value)
441</pre></div></div>
442</li>
443<li>
444
445<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>
446</li>
447<li>Arguments:
448<ul>
449
450<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>
451</ul>
452</li>
453<li>Return Value:
454<ul>
455
456<li>The ceiling value for the given number in the same type as the input argument,</li>
457<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
458<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
459<li>any other non-numeric input value will cause a type error.</li>
460</ul>
461</li>
462<li>
463
464<p>Example:</p>
465
466<div>
467<div>
468<pre class="source">{
469 &quot;v1&quot;: ceil(2013),
470 &quot;v2&quot;: ceil(-4036),
471 &quot;v3&quot;: ceil(0.3),
472 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
473 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
474};
475</pre></div></div>
476</li>
477<li>
478
479<p>The expected result is:</p>
480
481<div>
482<div>
483<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 }
484</pre></div></div>
485</li>
486</ul></div>
487<div class="section">
488<h3><a name="cos"></a>cos</h3>
489<ul>
490
491<li>
492
493<p>Syntax:</p>
494
495<div>
496<div>
497<pre class="source">cos(numeric_value)
498</pre></div></div>
499</li>
500<li>
501
502<p>Computes the cosine value of the argument.</p>
503</li>
504<li>Arguments:
505<ul>
506
507<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>
508</ul>
509</li>
510<li>Return Value:
511<ul>
512
513<li>the <tt>double</tt> cosine value for the argument,</li>
514<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
515<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
516<li>any other non-numeric input value will cause a type error.</li>
517</ul>
518</li>
519<li>
520
521<p>Example:</p>
522
523<div>
524<div>
525<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;)) };
526</pre></div></div>
527</li>
528<li>
529
530<p>The expected result is:</p>
531
532<div>
533<div>
534<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 }
535</pre></div></div>
536</li>
537</ul></div>
538<div class="section">
539<h3><a name="cosh"></a>cosh</h3>
540<ul>
541
542<li>
543
544<p>Syntax:</p>
545
546<div>
547<div>
548<pre class="source">cosh(numeric_value)
549</pre></div></div>
550</li>
551<li>
552
553<p>Computes the hyperbolic cosine value of the argument.</p>
554</li>
555<li>Arguments:
556<ul>
557
558<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>
559</ul>
560</li>
561<li>Return Value:
562<ul>
563
564<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
565<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
566<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
567<li>any other non-numeric input value will cause a type error.</li>
568</ul>
569</li>
570<li>
571
572<p>Example:</p>
573
574<div>
575<div>
576<pre class="source">{ &quot;v1&quot;: cosh(1), &quot;v2&quot;: cosh(2), &quot;v3&quot;: cosh(0), &quot;v4&quot;: cosh(float(&quot;0.5&quot;)), &quot;v5&quot;: cosh(double(&quot;8&quot;)) };
577</pre></div></div>
578</li>
579<li>
580
581<p>The expected result is:</p>
582
583<div>
584<div>
585<pre class="source">{ &quot;v1&quot;: 1.5430806348152437, &quot;v2&quot;: 3.7621956910836314, &quot;v3&quot;: 1.0, &quot;v4&quot;: 1.1276259652063807, &quot;v5&quot;: 1490.479161252178 }
586</pre></div></div>
587</li>
588</ul></div>
589<div class="section">
590<h3><a name="degrees"></a>degrees</h3>
591<ul>
592
593<li>
594
595<p>Syntax:</p>
596
597<div>
598<div>
599<pre class="source">degrees(numeric_value)
600</pre></div></div>
601</li>
602<li>
603
604<p>Converts radians to degrees</p>
605</li>
606<li>Arguments:
607<ul>
608
609<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>
610</ul>
611</li>
612<li>Return Value:
613<ul>
614
615<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
616<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
617<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
618<li>any other non-numeric input value will cause a type error.</li>
619</ul>
620</li>
621<li>
622
623<p>Example:</p>
624
625<div>
626<div>
627<pre class="source">{ &quot;v1&quot;: degrees(pi()) };
628</pre></div></div>
629</li>
630<li>
631
632<p>The expected result is:</p>
633
634<div>
635<div>
636<pre class="source">{ &quot;v1&quot;: 180.0 }
637</pre></div></div>
638</li>
639</ul></div>
640<div class="section">
641<h3><a name="e"></a>e</h3>
642<ul>
643
644<li>
645
646<p>Syntax:</p>
647
648<div>
649<div>
650<pre class="source">e()
651</pre></div></div>
652</li>
653<li>
654
655<p>Return Value:</p>
656<ul>
657
658<li>e (base of the natural logarithm)</li>
659</ul>
660</li>
661<li>
662
663<p>Example:</p>
664
665<div>
666<div>
667<pre class="source">{ &quot;v1&quot;: e() };
668</pre></div></div>
669</li>
670<li>
671
672<p>The expected result is:</p>
673
674<div>
675<div>
676<pre class="source">{ &quot;v1&quot;: 2.718281828459045 }
677</pre></div></div>
678</li>
679</ul></div>
680<div class="section">
681<h3><a name="exp"></a>exp</h3>
682<ul>
683
684<li>
685
686<p>Syntax:</p>
687
688<div>
689<div>
690<pre class="source">exp(numeric_value)
691</pre></div></div>
692</li>
693<li>
694
695<p>Computes e<sup>numeric_value</sup>.</p>
696</li>
697<li>Arguments:
698<ul>
699
700<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>
701</ul>
702</li>
703<li>Return Value:
704<ul>
705
706<li>e<sup>numeric_value</sup>,</li>
707<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
708<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
709<li>any other non-numeric input value will cause a type error.</li>
710</ul>
711</li>
712<li>
713
714<p>Example:</p>
715
716<div>
717<div>
718<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;)) };
719</pre></div></div>
720</li>
721<li>
722
723<p>The expected result is:</p>
724
725<div>
726<div>
727<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; }
728</pre></div></div>
729</li>
730</ul></div>
731<div class="section">
732<h3><a name="floor"></a>floor</h3>
733<ul>
734
735<li>
736
737<p>Syntax:</p>
738
739<div>
740<div>
741<pre class="source">floor(numeric_value)
742</pre></div></div>
743</li>
744<li>
745
746<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>
747</li>
748<li>Arguments:
749<ul>
750
751<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>
752</ul>
753</li>
754<li>Return Value:
755<ul>
756
757<li>The floor value for the given number in the same type as the input argument,</li>
758<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
759<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
760<li>any other non-numeric input value will cause a type error.</li>
761</ul>
762</li>
763<li>
764
765<p>Example:</p>
766
767<div>
768<div>
769<pre class="source">{
770 &quot;v1&quot;: floor(2013),
771 &quot;v2&quot;: floor(-4036),
772 &quot;v3&quot;: floor(0.8),
773 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
774 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
775};
776</pre></div></div>
777</li>
778<li>
779
780<p>The expected result is:</p>
781
782<div>
783<div>
784<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 }
785</pre></div></div>
786</li>
787</ul></div>
788<div class="section">
789<h3><a name="ln"></a>ln</h3>
790<ul>
791
792<li>
793
794<p>Syntax:</p>
795
796<div>
797<div>
798<pre class="source">ln(numeric_value)
799</pre></div></div>
800</li>
801<li>
802
803<p>Computes log<sub>e</sub>numeric_value.</p>
804</li>
805<li>Arguments:
806<ul>
807
808<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>
809</ul>
810</li>
811<li>Return Value:
812<ul>
813
814<li>log<sub>e</sub>numeric_value,</li>
815<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
816<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
817<li>any other non-numeric input value will cause a type error.</li>
818</ul>
819</li>
820<li>
821
822<p>Example:</p>
823
824<div>
825<div>
826<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;)) };
827</pre></div></div>
828</li>
829<li>
830
831<p>The expected result is:</p>
832
833<div>
834<div>
835<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 }
836</pre></div></div>
837</li>
838</ul></div>
839<div class="section">
840<h3><a name="log"></a>log</h3>
841<ul>
842
843<li>
844
845<p>Syntax:</p>
846
847<div>
848<div>
849<pre class="source">log(numeric_value)
850</pre></div></div>
851</li>
852<li>
853
854<p>Computes log<sub>10</sub>numeric_value.</p>
855</li>
856<li>Arguments:
857<ul>
858
859<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>
860</ul>
861</li>
862<li>Return Value:
863<ul>
864
865<li>log<sub>10</sub>numeric_value,</li>
866<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
867<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
868<li>any other non-numeric input value will cause a type error.</li>
869</ul>
870</li>
871<li>
872
873<p>Example:</p>
874
875<div>
876<div>
877<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;)) };
878</pre></div></div>
879</li>
880<li>
881
882<p>The expected result is:</p>
883
884<div>
885<div>
886<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 }
887</pre></div></div>
888</li>
889</ul></div>
890<div class="section">
891<h3><a name="pi"></a>pi</h3>
892<ul>
893
894<li>
895
896<p>Syntax:</p>
897
898<div>
899<div>
900<pre class="source">pi()
901</pre></div></div>
902</li>
903<li>
904
905<p>Return Value:</p>
906<ul>
907
908<li>Pi</li>
909</ul>
910</li>
911<li>
912
913<p>Example:</p>
914
915<div>
916<div>
917<pre class="source">{ &quot;v1&quot;: pi() };
918</pre></div></div>
919</li>
920<li>
921
922<p>The expected result is:</p>
923
924<div>
925<div>
926<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
927</pre></div></div>
928</li>
929</ul></div>
930<div class="section">
931<h3><a name="power"></a>power</h3>
932<ul>
933
934<li>
935
936<p>Syntax:</p>
937
938<div>
939<div>
940<pre class="source">power(numeric_value1, numeric_value2)
941</pre></div></div>
942</li>
943<li>
944
945<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
946</li>
947<li>Arguments:
948<ul>
949
950<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>
951<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>
952</ul>
953</li>
954<li>Return Value:
955<ul>
956
957<li>numeric_value1<sup>numeric_value2</sup>,</li>
958<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
959<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
960<li>any other non-numeric input value will cause a type error.</li>
961</ul>
962</li>
963<li>
964
965<p>Example:</p>
966
967<div>
968<div>
969<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;)) };
970</pre></div></div>
971</li>
972<li>
973
974<p>The expected result is:</p>
975
976<div>
977<div>
978<pre class="source">{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
979</pre></div></div>
980</li>
981</ul></div>
982<div class="section">
983<h3><a name="radians"></a>radians</h3>
984<ul>
985
986<li>
987
988<p>Syntax:</p>
989
990<div>
991<div>
992<pre class="source">radians(numeric_value)
993</pre></div></div>
994</li>
995<li>
996
997<p>Converts degrees to radians</p>
998</li>
999<li>Arguments:
1000<ul>
1001
1002<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>
1003</ul>
1004</li>
1005<li>Return Value:
1006<ul>
1007
1008<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
1009<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1010<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1011<li>any other non-numeric input value will cause a type error.</li>
1012</ul>
1013</li>
1014<li>
1015
1016<p>Example:</p>
1017
1018<div>
1019<div>
1020<pre class="source">{ &quot;v1&quot;: radians(180) };
1021</pre></div></div>
1022</li>
1023<li>
1024
1025<p>The expected result is:</p>
1026
1027<div>
1028<div>
1029<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
1030</pre></div></div>
1031</li>
1032</ul></div>
1033<div class="section">
1034<h3><a name="round"></a>round</h3>
1035<ul>
1036
1037<li>
1038
1039<p>Syntax:</p>
1040
1041<div>
1042<div>
1043<pre class="source">round(numeric_value[, round_digit])
1044</pre></div></div>
1045</li>
1046<li>
1047
1048<p>Rounds the value to the given number of integer digits to the right of the decimal point, or to the left of the decimal point if the number of digits is negative.</p>
1049</li>
1050<li>
1051
1052<p>Arguments:</p>
1053<ul>
1054
1055<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 that represents the numeric value to be rounded.</li>
1056<li><tt>round_digit</tt>: (Optional) a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value that specifies the digit to round to. This argument may be positive or negative; positive indicating that rounding needs to be to the right of the decimal point, and negative indicating that rounding needs to be to the left of the decimal point. Values such as 1.0 and 2.0 are acceptable, but values such as 1.3 and 1.5 result in a <tt>null</tt>. If omitted, the default is 0.</li>
1057</ul>
1058</li>
1059<li>Return Value:
1060<ul>
1061
1062<li>The rounded value for the given number. The returned value has the following type:
1063<ul>
1064
1065<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
1066<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
1067<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
1068</ul>
1069</li>
1070<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
1071<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
1072<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
1073</ul>
1074</li>
1075<li>
1076
1077<p>Example:</p>
1078
1079<div>
1080<div>
1081<pre class="source">{
1082 &quot;v1&quot;: round(2013),
1083 &quot;v2&quot;: round(-4036),
1084 &quot;v3&quot;: round(0.8),
1085 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1086 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1087 &quot;v6&quot;: round(123456, -1),
1088 &quot;v7&quot;: round(456.456, 2),
1089 &quot;v8&quot;: round(456.456, -1),
1090 &quot;v9&quot;: round(-456.456, -2)
1091};
1092</pre></div></div>
1093</li>
1094<li>
1095
1096<p>The expected result is:</p>
1097
1098<div>
1099<div>
1100<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;: 123460, &quot;v7&quot;: 456.46, &quot;v8&quot;: 460, &quot;v9&quot;: -500 }
1101</pre></div></div>
1102</li>
1103</ul></div>
1104<div class="section">
1105<h3><a name="sign"></a>sign</h3>
1106<ul>
1107
1108<li>
1109
1110<p>Syntax:</p>
1111
1112<div>
1113<div>
1114<pre class="source">sign(numeric_value)
1115</pre></div></div>
1116</li>
1117<li>
1118
1119<p>Computes the sign of the argument.</p>
1120</li>
1121<li>Arguments:
1122<ul>
1123
1124<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>
1125</ul>
1126</li>
1127<li>Return Value:
1128<ul>
1129
1130<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1131<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1132<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1133<li>any other non-numeric input value will cause a type error.</li>
1134</ul>
1135</li>
1136<li>
1137
1138<p>Example:</p>
1139
1140<div>
1141<div>
1142<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;)) };
1143</pre></div></div>
1144</li>
1145<li>
1146
1147<p>The expected result is:</p>
1148
1149<div>
1150<div>
1151<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1152</pre></div></div>
1153</li>
1154</ul></div>
1155<div class="section">
1156<h3><a name="sin"></a>sin</h3>
1157<ul>
1158
1159<li>
1160
1161<p>Syntax:</p>
1162
1163<div>
1164<div>
1165<pre class="source">sin(numeric_value)
1166</pre></div></div>
1167</li>
1168<li>
1169
1170<p>Computes the sine value of the argument.</p>
1171</li>
1172<li>Arguments:
1173<ul>
1174
1175<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>
1176</ul>
1177</li>
1178<li>Return Value:
1179<ul>
1180
1181<li>the <tt>double</tt> sine value for the argument,</li>
1182<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1183<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1184<li>any other non-numeric input value will cause a type error.</li>
1185</ul>
1186</li>
1187<li>
1188
1189<p>Example:</p>
1190
1191<div>
1192<div>
1193<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;)) };
1194</pre></div></div>
1195</li>
1196<li>
1197
1198<p>The expected result is:</p>
1199
1200<div>
1201<div>
1202<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 }
1203</pre></div></div>
1204</li>
1205</ul></div>
1206<div class="section">
1207<h3><a name="sinh"></a>sinh</h3>
1208<ul>
1209
1210<li>
1211
1212<p>Syntax:</p>
1213
1214<div>
1215<div>
1216<pre class="source">sinh(numeric_value)
1217</pre></div></div>
1218</li>
1219<li>
1220
1221<p>Computes the hyperbolic sine value of the argument.</p>
1222</li>
1223<li>Arguments:
1224<ul>
1225
1226<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>
1227</ul>
1228</li>
1229<li>Return Value:
1230<ul>
1231
1232<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
1233<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1234<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1235<li>any other non-numeric input value will cause a type error.</li>
1236</ul>
1237</li>
1238<li>
1239
1240<p>Example:</p>
1241
1242<div>
1243<div>
1244<pre class="source">{ &quot;v1&quot;: sinh(1), &quot;v2&quot;: sinh(2), &quot;v3&quot;: sinh(0), &quot;v4&quot;: sinh(float(&quot;0.5&quot;)), &quot;v5&quot;: sinh(double(&quot;8&quot;)) };
1245</pre></div></div>
1246</li>
1247<li>
1248
1249<p>The expected result is:</p>
1250
1251<div>
1252<div>
1253<pre class="source">{ &quot;v1&quot;: 1.1752011936438014, &quot;v2&quot;: 3.626860407847019, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.5210953054937474, &quot;v5&quot;: 1490.4788257895502 }
1254</pre></div></div>
1255</li>
1256</ul></div>
1257<div class="section">
1258<h3><a name="sqrt"></a>sqrt</h3>
1259<ul>
1260
1261<li>
1262
1263<p>Syntax:</p>
1264
1265<div>
1266<div>
1267<pre class="source">sqrt(numeric_value)
1268</pre></div></div>
1269</li>
1270<li>
1271
1272<p>Computes the square root of the argument.</p>
1273</li>
1274<li>Arguments:
1275<ul>
1276
1277<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>
1278</ul>
1279</li>
1280<li>Return Value:
1281<ul>
1282
1283<li>the <tt>double</tt> square root value for the argument,</li>
1284<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1285<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1286<li>any other non-numeric input value will cause a type error.</li>
1287</ul>
1288</li>
1289<li>
1290
1291<p>Example:</p>
1292
1293<div>
1294<div>
1295<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;)) };
1296</pre></div></div>
1297</li>
1298<li>
1299
1300<p>The expected result is:</p>
1301
1302<div>
1303<div>
1304<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 }
1305</pre></div></div>
1306</li>
1307</ul></div>
1308<div class="section">
1309<h3><a name="tan"></a>tan</h3>
1310<ul>
1311
1312<li>
1313
1314<p>Syntax:</p>
1315
1316<div>
1317<div>
1318<pre class="source">tan(numeric_value)
1319</pre></div></div>
1320</li>
1321<li>
1322
1323<p>Computes the tangent value of the argument.</p>
1324</li>
1325<li>Arguments:
1326<ul>
1327
1328<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>
1329</ul>
1330</li>
1331<li>Return Value:
1332<ul>
1333
1334<li>the <tt>double</tt> tangent value for the argument,</li>
1335<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1336<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1337<li>any other non-numeric input value will cause a type error.</li>
1338</ul>
1339</li>
1340<li>
1341
1342<p>Example:</p>
1343
1344<div>
1345<div>
1346<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;)) };
1347</pre></div></div>
1348</li>
1349<li>
1350
1351<p>The expected result is:</p>
1352
1353<div>
1354<div>
1355<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 }
1356</pre></div></div>
1357</li>
1358</ul></div>
1359<div class="section">
1360<h3><a name="tanh"></a>tanh</h3>
1361<ul>
1362
1363<li>
1364
1365<p>Syntax:</p>
1366
1367<div>
1368<div>
1369<pre class="source">tanh(numeric_value)
1370</pre></div></div>
1371</li>
1372<li>
1373
1374<p>Computes the hyperbolic tangent value of the argument.</p>
1375</li>
1376<li>Arguments:
1377<ul>
1378
1379<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>
1380</ul>
1381</li>
1382<li>Return Value:
1383<ul>
1384
1385<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
1386<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1387<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1388<li>any other non-numeric input value will cause a type error.</li>
1389</ul>
1390</li>
1391<li>
1392
1393<p>Example:</p>
1394
1395<div>
1396<div>
1397<pre class="source">{ &quot;v1&quot;: tanh(1), &quot;v2&quot;: tanh(2), &quot;v3&quot;: tanh(0), &quot;v4&quot;: tanh(float(&quot;0.5&quot;)), &quot;v5&quot;: tanh(double(&quot;8&quot;)) };
1398</pre></div></div>
1399</li>
1400<li>
1401
1402<p>The expected result is:</p>
1403
1404<div>
1405<div>
1406<pre class="source">{ &quot;v1&quot;: 0.7615941559557649, &quot;v2&quot;: 0.964027580075817, &quot;v3&quot;: 0.0, &quot;v4&quot;: 0.4621171572600098, &quot;v5&quot;: 0.999999774929676 }
1407</pre></div></div>
1408</li>
1409</ul></div>
1410<div class="section">
1411<h3><a name="trunc"></a>trunc</h3>
1412<ul>
1413
1414<li>
1415
1416<p>Syntax:</p>
1417
1418<div>
1419<div>
1420<pre class="source">trunc(numeric_value, number_digits)
1421</pre></div></div>
1422</li>
1423<li>
1424
1425<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>
1426</li>
1427<li>Arguments:
1428<ul>
1429
1430<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>
1431<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1432</ul>
1433</li>
1434<li>Return Value:
1435<ul>
1436
1437<li>the <tt>double</tt> tangent value for the argument,</li>
1438<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1439<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1440<li>a type error will be raised if:
1441<ul>
1442
1443<li>the first argument is any other non-numeric value,</li>
1444<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1445</ul>
1446</li>
1447</ul>
1448</li>
1449<li>
1450
1451<p>Example:</p>
1452
1453<div>
1454<div>
1455<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) };
1456</pre></div></div>
1457</li>
1458<li>
1459
1460<p>The expected result is:</p>
1461
1462<div>
1463<div>
1464<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 }
1465</pre></div></div>
1466</li>
1467</ul><!--
1468 ! Licensed to the Apache Software Foundation (ASF) under one
1469 ! or more contributor license agreements. See the NOTICE file
1470 ! distributed with this work for additional information
1471 ! regarding copyright ownership. The ASF licenses this file
1472 ! to you under the Apache License, Version 2.0 (the
1473 ! "License"); you may not use this file except in compliance
1474 ! with the License. You may obtain a copy of the License at
1475 !
1476 ! http://www.apache.org/licenses/LICENSE-2.0
1477 !
1478 ! Unless required by applicable law or agreed to in writing,
1479 ! software distributed under the License is distributed on an
1480 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1481 ! KIND, either express or implied. See the License for the
1482 ! specific language governing permissions and limitations
1483 ! under the License.
1484 !-->
1485</div>
1486<div class="section">
1487<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1488<ul>
1489
1490<li>
1491
1492<p>Syntax:</p>
1493
1494<div>
1495<div>
1496<pre class="source">round_half_to_even(numeric_value, [precision])
1497</pre></div></div>
1498</li>
1499<li>
1500
1501<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>
1502</li>
1503<li>Arguments:
1504<ul>
1505
1506<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>
1507<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>
1508</ul>
1509</li>
1510<li>Return Value:
1511<ul>
1512
1513<li>The rounded value for the given number in the same type as the input argument,</li>
1514<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1515<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1516<li>a type error will be raised if:
1517<ul>
1518
1519<li>the first argument is any other non-numeric value,</li>
1520<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1521</ul>
1522</li>
1523</ul>
1524</li>
1525<li>
1526
1527<p>Example:</p>
1528
1529<div>
1530<div>
1531<pre class="source">{
1532 &quot;v1&quot;: round_half_to_even(2013),
1533 &quot;v2&quot;: round_half_to_even(-4036),
1534 &quot;v3&quot;: round_half_to_even(0.8),
1535 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1536 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1537 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1538 &quot;v7&quot;: round_half_to_even(2013, 4),
1539 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1540};
1541</pre></div></div>
1542</li>
1543<li>
1544
1545<p>The expected result is:</p>
1546
1547<div>
1548<div>
1549<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 }
1550</pre></div></div>
1551</li>
1552</ul><!--
1553 ! Licensed to the Apache Software Foundation (ASF) under one
1554 ! or more contributor license agreements. See the NOTICE file
1555 ! distributed with this work for additional information
1556 ! regarding copyright ownership. The ASF licenses this file
1557 ! to you under the Apache License, Version 2.0 (the
1558 ! "License"); you may not use this file except in compliance
1559 ! with the License. You may obtain a copy of the License at
1560 !
1561 ! http://www.apache.org/licenses/LICENSE-2.0
1562 !
1563 ! Unless required by applicable law or agreed to in writing,
1564 ! software distributed under the License is distributed on an
1565 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1566 ! KIND, either express or implied. See the License for the
1567 ! specific language governing permissions and limitations
1568 ! under the License.
1569 !-->
1570</div></div>
1571<div class="section">
1572<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1573<div class="section">
1574<h3><a name="concat"></a>concat</h3>
1575<ul>
1576
1577<li>
1578
1579<p>Syntax:</p>
1580
1581<div>
1582<div>
1583<pre class="source">concat(string1, string2, ...)
1584</pre></div></div>
1585</li>
1586<li>
1587
1588<p>Returns a concatenated string from arguments.</p>
1589</li>
1590<li>Arguments:
1591<ul>
1592
1593<li><tt>string1</tt>: a string value,</li>
1594<li><tt>string2</tt>: a string value,</li>
1595<li>&#x2026;.</li>
1596</ul>
1597</li>
1598<li>Return Value:
1599<ul>
1600
1601<li>a concatenated string from arguments,</li>
1602<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1603<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1604<li>any other non-string input value will cause a type error.</li>
1605</ul>
1606</li>
1607<li>
1608
1609<p>Example:</p>
1610
1611<div>
1612<div>
1613<pre class="source">concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1614</pre></div></div>
1615</li>
1616<li>
1617
1618<p>The expected result is:</p>
1619
1620<div>
1621<div>
1622<pre class="source">&quot;test driven development&quot;
1623</pre></div></div>
1624</li>
1625</ul></div>
1626<div class="section">
1627<h3><a name="contains"></a>contains</h3>
1628<ul>
1629
1630<li>
1631
1632<p>Syntax:</p>
1633
1634<div>
1635<div>
1636<pre class="source">contains(string, substring_to_contain)
1637</pre></div></div>
1638</li>
1639<li>
1640
1641<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
1642</li>
1643<li>Arguments:
1644<ul>
1645
1646<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1647<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1648</ul>
1649</li>
1650<li>Return Value:
1651<ul>
1652
1653<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1654<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1655<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1656<li>any other non-string input value will cause a type error,</li>
1657<li><tt>false</tt> otherwise.</li>
1658</ul>
1659</li>
1660<li>
1661
1662<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
1663</li>
1664<li>Example:
1665
1666<div>
1667<div>
1668<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;) };
1669</pre></div></div>
1670</li>
1671<li>
1672
1673<p>The expected result is:</p>
1674
1675<div>
1676<div>
1677<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1678</pre></div></div>
1679</li>
1680</ul></div>
1681<div class="section">
1682<h3><a name="ends_with"></a>ends_with</h3>
1683<ul>
1684
1685<li>
1686
1687<p>Syntax:</p>
1688
1689<div>
1690<div>
1691<pre class="source">ends_with(string, substring_to_end_with)
1692</pre></div></div>
1693</li>
1694<li>
1695
1696<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
1697</li>
1698<li>Arguments:
1699<ul>
1700
1701<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1702<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1703</ul>
1704</li>
1705<li>Return Value:
1706<ul>
1707
1708<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1709<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1710<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1711<li>any other non-string input value will cause a type error,</li>
1712<li><tt>false</tt> otherwise.</li>
1713</ul>
1714</li>
1715<li>
1716
1717<p>Example:</p>
1718
1719<div>
1720<div>
1721<pre class="source">{
1722 &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1723 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1724};
1725</pre></div></div>
1726</li>
1727<li>
1728
1729<p>The expected result is:</p>
1730
1731<div>
1732<div>
1733<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1734</pre></div></div>
1735</li>
1736</ul></div>
1737<div class="section">
1738<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
1739<ul>
1740
1741<li>
1742
1743<p>Syntax:</p>
1744
1745<div>
1746<div>
1747<pre class="source">initcap(string)
1748</pre></div></div>
1749</li>
1750<li>
1751
1752<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>
1753</li>
1754<li>Arguments:
1755<ul>
1756
1757<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1758</ul>
1759</li>
1760<li>Return Value:
1761<ul>
1762
1763<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1764<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1765<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1766<li>any other non-string input value will cause a type error.</li>
1767</ul>
1768</li>
1769<li>
1770
1771<p>Example:</p>
1772
1773<div>
1774<div>
1775<pre class="source">{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1776</pre></div></div>
1777</li>
1778<li>
1779
1780<p>The expected result is:</p>
1781
1782<div>
1783<div>
1784<pre class="source">{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1785</pre></div></div>
1786</li>
1787</ul></div>
1788<div class="section">
1789<h3><a name="length"></a>length</h3>
1790<ul>
1791
1792<li>
1793
1794<p>Syntax:</p>
1795
1796<div>
1797<div>
1798<pre class="source">length(string)
1799</pre></div></div>
1800</li>
1801<li>
1802
1803<p>Returns the length of the string <tt>string</tt>. Note that the length is in the unit of code point. See the following examples for more details.</p>
1804</li>
1805<li>Arguments:
1806<ul>
1807
1808<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1809</ul>
1810</li>
1811<li>Return Value:
1812<ul>
1813
1814<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1815<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1816<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1817<li>any other non-string input value will cause a type error.</li>
1818</ul>
1819</li>
1820<li>
1821
1822<p>Example:</p>
1823
1824<div>
1825<div>
1826<pre class="source">length(&quot;test string&quot;);
1827</pre></div></div>
1828</li>
1829<li>
1830
1831<p>The expected result is:</p>
1832
1833<div>
1834<div>
1835<pre class="source">11
1836</pre></div></div>
1837</li>
1838<li>
1839
1840<p>Example:</p>
1841
1842<div>
1843<div>
1844<pre class="source">length(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;);
1845</pre></div></div>
1846</li>
1847<li>
1848
1849<p>The expected result is (the emoji character &#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points):</p>
1850
1851<div>
1852<div>
1853<pre class="source">7
1854</pre></div></div>
1855</li>
1856</ul></div>
1857<div class="section">
1858<h3><a name="lower"></a>lower</h3>
1859<ul>
1860
1861<li>
1862
1863<p>Syntax:</p>
1864
1865<div>
1866<div>
1867<pre class="source">lower(string)
1868</pre></div></div>
1869</li>
1870<li>
1871
1872<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
1873</li>
1874<li>Arguments:
1875<ul>
1876
1877<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1878</ul>
1879</li>
1880<li>Return Value:
1881<ul>
1882
1883<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1884<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1885<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1886<li>any other non-string input value will cause a type error.</li>
1887</ul>
1888</li>
1889<li>
1890
1891<p>Example:</p>
1892
1893<div>
1894<div>
1895<pre class="source">lower(&quot;ASTERIXDB&quot;);
1896</pre></div></div>
1897</li>
1898<li>
1899
1900<p>The expected result is:</p>
1901
1902<div>
1903<div>
1904<pre class="source">&quot;asterixdb&quot;
1905</pre></div></div>
1906</li>
1907</ul></div>
1908<div class="section">
1909<h3><a name="ltrim"></a>ltrim</h3>
1910<ul>
1911
1912<li>
1913
1914<p>Syntax:</p>
1915
1916<div>
1917<div>
1918<pre class="source">ltrim(string[, chars]);
1919</pre></div></div>
1920</li>
1921<li>
1922
1923<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. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
1924</li>
1925<li>Arguments:
1926<ul>
1927
1928<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1929<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1930</ul>
1931</li>
1932<li>Return Value:
1933<ul>
1934
1935<li>a trimmed, new <tt>string</tt>,</li>
1936<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1937<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1938<li>any other non-string input value will cause a type error.</li>
1939</ul>
1940</li>
1941<li>Related functions: see <tt>trim()</tt>, <tt>rtrim()</tt></li>
1942<li>
1943
1944<p>Example:</p>
1945
1946<div>
1947<div>
1948<pre class="source">ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
1949</pre></div></div>
1950</li>
1951<li>
1952
1953<p>The expected result is:</p>
1954
1955<div>
1956<div>
1957<pre class="source">&quot; like x-phone&quot;
1958</pre></div></div>
1959</li>
1960<li>
1961
1962<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
1963
1964<div>
1965<div>
1966<pre class="source">ltrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
1967</pre></div></div>
1968</li>
1969<li>
1970
1971<p>The expected result is (only woman, girl and boy are left in the family):</p>
1972
1973<div>
1974<div>
1975<pre class="source">&quot;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;
1976</pre></div></div>
1977</li>
1978</ul></div>
1979<div class="section">
1980<h3><a name="position"></a>position</h3>
1981<ul>
1982
1983<li>
1984
1985<p>Syntax:</p>
1986
1987<div>
1988<div>
1989<pre class="source">position(string, string_pattern)
1990</pre></div></div>
1991</li>
1992<li>
1993
1994<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>. The result is counted in the unit of code points. See the following example for more details.</p>
1995</li>
1996<li>
1997
1998<p>The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
1999<ul>
2000
2001<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
2002<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
2003</ul>
2004</li>
2005<li>
2006
2007<p>Arguments:</p>
2008<ul>
2009
2010<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2011<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2012</ul>
2013</li>
2014<li>Return Value:
2015<ul>
2016
2017<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>
2018<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2019<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2020<li>any other non-string input value will return a <tt>null</tt>.</li>
2021</ul>
2022</li>
2023<li>
2024
2025<p>Example:</p>
2026
2027<div>
2028<div>
2029<pre class="source">{
2030 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
2031 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;),
2032 &quot;v3&quot;: position1(&quot;ppphonepp&quot;, &quot;phone&quot;),
2033 &quot;v4&quot;: position1(&quot;hone&quot;, &quot;phone&quot;)
2034};
2035</pre></div></div>
2036</li>
2037<li>
2038
2039<p>The expected result is:</p>
2040
2041<div>
2042<div>
2043<pre class="source">{ &quot;v1&quot;: 2, &quot;v2&quot;: -1, v3&quot;: 3, &quot;v4&quot;: -1 }
2044</pre></div></div>
2045</li>
2046<li>
2047
2048<p>Example of multi-code-point character:</p>
2049
2050<div>
2051<div>
2052<pre class="source">position(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x1f3c0;&quot;, &quot;&#x1f3c0;&quot;);
2053</pre></div></div>
2054</li>
2055<li>
2056
2057<p>The expected result is (the emoji family character has 7 code points):</p>
2058
2059<div>
2060<div>
2061<pre class="source">7
2062</pre></div></div>
2063</li>
2064</ul></div>
2065<div class="section">
2066<h3><a name="regexp_contains"></a>regexp_contains</h3>
2067<ul>
2068
2069<li>
2070
2071<p>Syntax:</p>
2072
2073<div>
2074<div>
2075<pre class="source">regexp_contains(string, string_pattern[, string_flags])
2076</pre></div></div>
2077</li>
2078<li>
2079
2080<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2081</li>
2082<li>
2083
2084<p>Aliases:</p>
2085<ul>
2086
2087<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
2088</ul>
2089</li>
2090<li>
2091
2092<p>Arguments:</p>
2093<ul>
2094
2095<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2096<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2097<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2098<ul>
2099
2100<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2101</ul>
2102</li>
2103</ul>
2104</li>
2105<li>Return Value:
2106<ul>
2107
2108<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
2109<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2110<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2111<li>any other non-string input value will return a <tt>null</tt>.</li>
2112</ul>
2113</li>
2114<li>
2115
2116<p>Example:</p>
2117
2118<div>
2119<div>
2120<pre class="source">{
2121 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2122 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
2123};
2124</pre></div></div>
2125</li>
2126<li>
2127
2128<p>The expected result is:</p>
2129
2130<div>
2131<div>
2132<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2133</pre></div></div>
2134</li>
2135</ul></div>
2136<div class="section">
2137<h3><a name="regexp_like"></a>regexp_like</h3>
2138<ul>
2139
2140<li>
2141
2142<p>Syntax:</p>
2143
2144<div>
2145<div>
2146<pre class="source">regexp_like(string, string_pattern[, string_flags])
2147</pre></div></div>
2148</li>
2149<li>
2150
2151<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2152</li>
2153<li>
2154
2155<p>Aliases:</p>
2156<ul>
2157
2158<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
2159</ul>
2160</li>
2161<li>
2162
2163<p>Arguments:</p>
2164<ul>
2165
2166<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2167<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
2168<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2169<ul>
2170
2171<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2172</ul>
2173</li>
2174</ul>
2175</li>
2176<li>Return Value:
2177<ul>
2178
2179<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains the pattern <tt>string_pattern</tt>, <tt>false</tt> otherwise.</li>
2180<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2181<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2182<li>any other non-string input value will return a <tt>null</tt>.</li>
2183</ul>
2184</li>
2185<li>
2186
2187<p>Example:</p>
2188
2189<div>
2190<div>
2191<pre class="source">{
2192 &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
2193 &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
2194};
2195</pre></div></div>
2196</li>
2197<li>
2198
2199<p>The expected result is:</p>
2200
2201<div>
2202<div>
2203<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2204</pre></div></div>
2205</li>
2206</ul></div>
2207<div class="section">
2208<h3><a name="regexp_position"></a>regexp_position</h3>
2209<ul>
2210
2211<li>
2212
2213<p>Syntax:</p>
2214
2215<div>
2216<div>
2217<pre class="source">regexp_position(string, string_pattern[, string_flags])
2218</pre></div></div>
2219</li>
2220<li>
2221
2222<p>Returns first position of the regular expression <tt>string_pattern</tt> (a Java regular expression pattern) within <tt>string</tt>. The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
2223</li>
2224<li>
2225
2226<p>Aliases:</p>
2227<ul>
2228
2229<li>0-Based: <tt>regexp_position</tt>, <tt>regexp_pos</tt>, <tt>regexp_position0</tt>, <tt>regexp_pos0</tt>, <tt>regex_position</tt>, <tt>regex_pos</tt>, <tt>regex_position0</tt>, <tt>regex_pos0</tt>.</li>
2230<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
2231</ul>
2232</li>
2233<li>
2234
2235<p>Arguments:</p>
2236<ul>
2237
2238<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2239<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2240<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2241<ul>
2242
2243<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2244</ul>
2245</li>
2246</ul>
2247</li>
2248<li>Return Value:
2249<ul>
2250
2251<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>
2252<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2253<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2254<li>any other non-string input value will return a <tt>null</tt>.</li>
2255</ul>
2256</li>
2257<li>
2258
2259<p>Example:</p>
2260
2261<div>
2262<div>
2263<pre class="source">{
2264 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2265 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;),
2266 &quot;v3&quot;: regexp_position1(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2267 &quot;v4&quot;: regexp_position1(&quot;hone&quot;, &quot;p+hone&quot;)
2268};
2269</pre></div></div>
2270</li>
2271<li>
2272
2273<p>The expected result is:</p>
2274
2275<div>
2276<div>
2277<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: -1, &quot;v3&quot;: 1, &quot;v4&quot;: -1 }
2278</pre></div></div>
2279</li>
2280</ul></div>
2281<div class="section">
2282<h3><a name="regexp_replace"></a>regexp_replace</h3>
2283<ul>
2284
2285<li>
2286
2287<p>Syntax:</p>
2288
2289<div>
2290<div>
2291<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
2292regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
2293</pre></div></div>
2294</li>
2295<li>
2296
2297<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>
2298</li>
2299<li>
2300
2301<p>Aliases:</p>
2302<ul>
2303
2304<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
2305</ul>
2306</li>
2307<li>
2308
2309<p>Arguments:</p>
2310<ul>
2311
2312<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2313<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2314<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
2315<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2316<ul>
2317
2318<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2319</ul>
2320</li>
2321<li><tt>replacement_limit</tt>: (Optional) an <tt>integer</tt> specifying the maximum number of replacements to make (if negative then all occurrences will be replaced)</li>
2322</ul>
2323</li>
2324<li>Return Value:
2325<ul>
2326
2327<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
2328<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2329<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2330<li>any other non-string input value will return a <tt>null</tt>.</li>
2331</ul>
2332</li>
2333<li>
2334
2335<p>Example:</p>
2336
2337<div>
2338<div>
2339<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;);
2340</pre></div></div>
2341</li>
2342<li>
2343
2344<p>The expected result is:</p>
2345
2346<div>
2347<div>
2348<pre class="source">&quot;like product-a the voicemail_service is awesome&quot;
2349</pre></div></div>
2350</li>
2351</ul></div>
2352<div class="section">
2353<h3><a name="repeat"></a>repeat</h3>
2354<ul>
2355
2356<li>
2357
2358<p>Syntax:</p>
2359
2360<div>
2361<div>
2362<pre class="source">repeat(string, n)
2363</pre></div></div>
2364</li>
2365<li>
2366
2367<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
2368</li>
2369<li>Arguments:
2370<ul>
2371
2372<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2373<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>
2374</ul>
2375</li>
2376<li>Return Value:
2377<ul>
2378
2379<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2380<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2381<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2382<li>a type error will be raised if:
2383<ul>
2384
2385<li>the first argument is any other non-string value,</li>
2386<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2387</ul>
2388</li>
2389</ul>
2390</li>
2391<li>
2392
2393<p>Example:</p>
2394
2395<div>
2396<div>
2397<pre class="source">repeat(&quot;test&quot;, 3);
2398</pre></div></div>
2399</li>
2400<li>
2401
2402<p>The expected result is:</p>
2403
2404<div>
2405<div>
2406<pre class="source">&quot;testtesttest&quot;
2407</pre></div></div>
2408</li>
2409</ul></div>
2410<div class="section">
2411<h3><a name="replace"></a>replace</h3>
2412<ul>
2413
2414<li>
2415
2416<p>Syntax:</p>
2417
2418<div>
2419<div>
2420<pre class="source">replace(string, search_string, replacement_string[, limit])
2421</pre></div></div>
2422</li>
2423<li>
2424
2425<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>
2426</li>
2427<li>Arguments:
2428<ul>
2429
2430<li><tt>string</tt> : an input <tt>string</tt>,</li>
2431<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
2432<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
2433<li><tt>limit</tt> : (Optional) an <tt>integer</tt> - maximum number of occurrences to be replaced. If not specified or negative then all occurrences will be replaced</li>
2434</ul>
2435</li>
2436<li>Return Value:
2437<ul>
2438
2439<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2440<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2441<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
2442<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2443</ul>
2444</li>
2445<li>
2446
2447<p>Example:</p>
2448
2449<div>
2450<div>
2451<pre class="source">{
2452 &quot;v1&quot;: replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;),
2453 &quot;v2&quot;: replace(&quot;x-phone and x-phone&quot;, &quot;x-phone&quot;, &quot;product-a&quot;, 1)
2454};
2455</pre></div></div>
2456</li>
2457<li>
2458
2459<p>The expected result is:</p>
2460
2461<div>
2462<div>
2463<pre class="source">{
2464 &quot;v1&quot;: &quot;like product-a the voicemail_service is awesome&quot;,
2465 &quot;v2&quot;: &quot;product-a and x-phone&quot;
2466}
2467</pre></div></div>
2468</li>
2469</ul></div>
2470<div class="section">
2471<h3><a name="reverse"></a>reverse</h3>
2472<ul>
2473
2474<li>
2475
2476<p>Syntax:</p>
2477
2478<div>
2479<div>
2480<pre class="source">reverse(string)
2481</pre></div></div>
2482</li>
2483<li>
2484
2485<p>Returns a string formed by reversing characters in the input <tt>string</tt>. For characters of multiple code points, code point is the minimal unit to reverse. See the following examples for more details.</p>
2486</li>
2487<li>Arguments:
2488<ul>
2489
2490<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
2491</ul>
2492</li>
2493<li>Return Value:
2494<ul>
2495
2496<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
2497<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2498<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2499<li>a type error will be raised if:
2500<ul>
2501
2502<li>the first argument is any other non-string value</li>
2503</ul>
2504</li>
2505</ul>
2506</li>
2507<li>
2508
2509<p>Example:</p>
2510
2511<div>
2512<div>
2513<pre class="source">reverse(&quot;hello&quot;);
2514</pre></div></div>
2515</li>
2516<li>
2517
2518<p>The expected result is:</p>
2519
2520<div>
2521<div>
2522<pre class="source">&quot;olleh&quot;
2523</pre></div></div>
2524</li>
2525<li>
2526
2527<p>Example of multi-code-point character (Korean):</p>
2528
2529<div>
2530<div>
2531<pre class="source">reverse(&quot;&#x1112;&#x1161;&#x11ab;&#x1100;&#x1173;&#x11af;&quot;);
2532</pre></div></div>
2533</li>
2534<li>
2535
2536<p>The expected result is (the Korean characters are splitted into code points and then the code points are reversed):</p>
2537
2538<div>
2539<div>
2540<pre class="source">&quot;&#x11af;&#x1173;&#x1100;&#x11ab;&#x1161;&#x1112;&quot;
2541</pre></div></div>
2542</li>
2543</ul></div>
2544<div class="section">
2545<h3><a name="rtrim"></a>rtrim</h3>
2546<ul>
2547
2548<li>
2549
2550<p>Syntax:</p>
2551
2552<div>
2553<div>
2554<pre class="source">rtrim(string[, chars]);
2555</pre></div></div>
2556</li>
2557<li>
2558
2559<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. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2560</li>
2561<li>Arguments:
2562<ul>
2563
2564<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2565<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2566</ul>
2567</li>
2568<li>Return Value:
2569<ul>
2570
2571<li>a trimmed, new <tt>string</tt>,</li>
2572<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2573<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2574<li>any other non-string input value will cause a type error.</li>
2575</ul>
2576</li>
2577<li>Related functions: see <tt>trim()</tt>, <tt>ltrim()</tt></li>
2578<li>
2579
2580<p>Example:</p>
2581
2582<div>
2583<div>
2584<pre class="source">{
2585 &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
2586 &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
2587};
2588</pre></div></div>
2589</li>
2590<li>
2591
2592<p>The expected result is:</p>
2593
2594<div>
2595<div>
2596<pre class="source">{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like x-&quot; }
2597</pre></div></div>
2598</li>
2599<li>
2600
2601<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2602
2603<div>
2604<div>
2605<pre class="source">rtrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
2606</pre></div></div>
2607</li>
2608<li>
2609
2610<p>The expected result is (only man, woman and girl are left in the family):</p>
2611
2612<div>
2613<div>
2614<pre class="source">&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&quot;
2615</pre></div></div>
2616</li>
2617</ul></div>
2618<div class="section">
2619<h3><a name="split"></a>split</h3>
2620<ul>
2621
2622<li>
2623
2624<p>Syntax:</p>
2625
2626<div>
2627<div>
2628<pre class="source">split(string, sep)
2629</pre></div></div>
2630</li>
2631<li>
2632
2633<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
2634</li>
2635<li>Arguments:
2636<ul>
2637
2638<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2639</ul>
2640</li>
2641<li>Return Value:
2642<ul>
2643
2644<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2645<li>in case of two consecutive <tt>sep</tt>s in the <tt>string</tt>, the result of splitting the two consecutive <tt>sep</tt>s will be the empty string <tt>&quot;&quot;</tt>,</li>
2646<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2647<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2648<li>any other non-string input value will cause a type error.</li>
2649</ul>
2650</li>
2651<li>
2652
2653<p>Example:</p>
2654
2655<div>
2656<div>
2657<pre class="source">split(&quot;test driven development&quot;, &quot; &quot;);
2658</pre></div></div>
2659</li>
2660<li>
2661
2662<p>The expected result is:</p>
2663
2664<div>
2665<div>
2666<pre class="source">[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2667</pre></div></div>
2668</li>
2669<li>
2670
2671<p>Example with two consecutive <tt>sep</tt>s in the <tt>string</tt>:</p>
2672
2673<div>
2674<div>
2675<pre class="source">split(&quot;123//456&quot;, &quot;/&quot;);
2676</pre></div></div>
2677</li>
2678<li>
2679
2680<p>The expected result is:</p>
2681
2682<div>
2683<div>
2684<pre class="source">[ &quot;123&quot;, &quot;&quot;, &quot;456&quot; ]
2685</pre></div></div>
2686</li>
2687</ul></div>
2688<div class="section">
2689<h3><a name="starts_with"></a>starts_with</h3>
2690<ul>
2691
2692<li>
2693
2694<p>Syntax:</p>
2695
2696<div>
2697<div>
2698<pre class="source">starts_with(string, substring_to_start_with)
2699</pre></div></div>
2700</li>
2701<li>
2702
2703<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
2704</li>
2705<li>Arguments:
2706<ul>
2707
2708<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2709<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2710</ul>
2711</li>
2712<li>Return Value:
2713<ul>
2714
2715<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2716<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2717<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2718<li>any other non-string input value will cause a type error,</li>
2719<li><tt>false</tt> otherwise.</li>
2720</ul>
2721</li>
2722<li>
2723
2724<p>Example:</p>
2725
2726<div>
2727<div>
2728<pre class="source">{
2729 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2730 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2731};
2732</pre></div></div>
2733</li>
2734<li>
2735
2736<p>The expected result is:</p>
2737
2738<div>
2739<div>
2740<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2741</pre></div></div>
2742</li>
2743</ul></div>
2744<div class="section">
2745<h3><a name="substr"></a>substr</h3>
2746<ul>
2747
2748<li>
2749
2750<p>Syntax:</p>
2751
2752<div>
2753<div>
2754<pre class="source">substr(string, offset[, length])
2755</pre></div></div>
2756</li>
2757<li>
2758
2759<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>. Note that both of the <tt>offset</tt> and <tt>length</tt> are in the unit of code point (e.g. the emoji family &#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points). The function uses the 0-based position. Another version of the function uses the 1-based position. Below are the aliases for each version:</p>
2760</li>
2761<li>
2762
2763<p>Aliases:</p>
2764<ul>
2765
2766<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
2767<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
2768</ul>
2769</li>
2770<li>
2771
2772<p>Arguments:</p>
2773<ul>
2774
2775<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2776<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). If negative then counted from the end of the string.</li>
2777<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>
2778</ul>
2779</li>
2780<li>Return Value:
2781<ul>
2782
2783<li>a <tt>string</tt> that represents the substring,</li>
2784<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2785<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or if the substring could not be obtained because the starting offset is not within string bounds or <tt>length</tt> is negative.</li>
2786<li>a <tt>null</tt> will be returned if:
2787<ul>
2788
2789<li>the first argument is any other non-string value.</li>
2790<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2791<li>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>
2792</ul>
2793</li>
2794</ul>
2795</li>
2796<li>
2797
2798<p>Example:</p>
2799
2800<div>
2801<div>
2802<pre class="source">{ &quot;v1&quot;: substr(&quot;test string&quot;, 6, 3), &quot;v2&quot;: substr1(&quot;test string&quot;, 6, 3) };
2803</pre></div></div>
2804</li>
2805<li>
2806
2807<p>The expected result is:</p>
2808
2809<div>
2810<div>
2811<pre class="source">{ &quot;v1&quot;: &quot;tri&quot;, &quot;v2&quot;: &quot;str&quot; }
2812</pre></div></div>
2813</li>
2814</ul>
2815<p>The function has an alias <tt>substring</tt>.</p></div>
2816<div class="section">
2817<h3><a name="trim"></a>trim</h3>
2818<ul>
2819
2820<li>
2821
2822<p>Syntax:</p>
2823
2824<div>
2825<div>
2826<pre class="source">trim(string[, chars]);
2827</pre></div></div>
2828</li>
2829<li>
2830
2831<p>Returns a new string with all leading and trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2832</li>
2833<li>Arguments:
2834<ul>
2835
2836<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2837<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2838</ul>
2839</li>
2840<li>Return Value:
2841<ul>
2842
2843<li>a trimmed, new <tt>string</tt>,</li>
2844<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2845<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2846<li>any other non-string input value will cause a type error.</li>
2847</ul>
2848</li>
2849<li>Related functions: see <tt>ltrim()</tt>, <tt>rtrim()</tt></li>
2850<li>
2851
2852<p>Example:</p>
2853
2854<div>
2855<div>
2856<pre class="source">trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
2857</pre></div></div>
2858</li>
2859<li>
2860
2861<p>The expected result is:</p>
2862
2863<div>
2864<div>
2865<pre class="source">&quot; like &quot;
2866</pre></div></div>
2867</li>
2868<li>
2869
2870<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2871<p>trim(&#x201c;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d;, &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;)</p>
2872</li>
2873<li>
2874
2875<p>The expected result is (only woman and girl are left in the family):</p>
2876
2877<div>
2878<div>
2879<pre class="source"> &quot;&#x1f469;&#x200d;&#x1f467;&quot;
2880</pre></div></div>
2881</li>
2882</ul></div>
2883<div class="section">
2884<h3><a name="upper"></a>upper</h3>
2885<ul>
2886
2887<li>
2888
2889<p>Syntax:</p>
2890
2891<div>
2892<div>
2893<pre class="source">upper(string)
2894</pre></div></div>
2895</li>
2896<li>
2897
2898<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
2899</li>
2900<li>Arguments:
2901<ul>
2902
2903<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2904</ul>
2905</li>
2906<li>Return Value:
2907<ul>
2908
2909<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2910<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2911<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2912<li>any other non-string input value will cause a type error.</li>
2913</ul>
2914</li>
2915<li>
2916
2917<p>Example:</p>
2918
2919<div>
2920<div>
2921<pre class="source">upper(&quot;hello&quot;)
2922</pre></div></div>
2923</li>
2924<li>
2925
2926<p>The expected result is:</p>
2927
2928<div>
2929<div>
2930<pre class="source">&quot;HELLO&quot;
2931</pre></div></div>
2932</li>
2933</ul><!--
2934 ! Licensed to the Apache Software Foundation (ASF) under one
2935 ! or more contributor license agreements. See the NOTICE file
2936 ! distributed with this work for additional information
2937 ! regarding copyright ownership. The ASF licenses this file
2938 ! to you under the Apache License, Version 2.0 (the
2939 ! "License"); you may not use this file except in compliance
2940 ! with the License. You may obtain a copy of the License at
2941 !
2942 ! http://www.apache.org/licenses/LICENSE-2.0
2943 !
2944 ! Unless required by applicable law or agreed to in writing,
2945 ! software distributed under the License is distributed on an
2946 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2947 ! KIND, either express or implied. See the License for the
2948 ! specific language governing permissions and limitations
2949 ! under the License.
2950 !-->
2951</div>
2952<div class="section">
2953<h3><a name="string_concat"></a>string_concat</h3>
2954<ul>
2955
2956<li>
2957
2958<p>Syntax:</p>
2959
2960<div>
2961<div>
2962<pre class="source">string_concat(array)
2963</pre></div></div>
2964</li>
2965<li>
2966
2967<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
2968</li>
2969<li>Arguments:
2970<ul>
2971
2972<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>
2973</ul>
2974</li>
2975<li>Return Value:
2976<ul>
2977
2978<li>the concatenated <tt>string</tt> value,</li>
2979<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2980<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2981<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2982<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>
2983<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2984</ul>
2985</li>
2986<li>
2987
2988<p>Example:</p>
2989
2990<div>
2991<div>
2992<pre class="source">string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2993</pre></div></div>
2994</li>
2995<li>
2996
2997<p>The expected result is:</p>
2998
2999<div>
3000<div>
3001<pre class="source">&quot;ASTERIX ROCKS!&quot;
3002</pre></div></div>
3003</li>
3004</ul></div>
3005<div class="section">
3006<h3><a name="string_join"></a>string_join</h3>
3007<ul>
3008
3009<li>
3010
3011<p>Syntax:</p>
3012
3013<div>
3014<div>
3015<pre class="source">string_join(array, string)
3016</pre></div></div>
3017</li>
3018<li>
3019
3020<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
3021</li>
3022<li>Arguments:
3023<ul>
3024
3025<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
3026<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
3027</ul>
3028</li>
3029<li>Return Value:
3030<ul>
3031
3032<li>the joined <tt>string</tt>,</li>
3033<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3034<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3035<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
3036<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
3037<li>a type error will be raised if:
3038<ul>
3039
3040<li>the first argument is any other non-array value, or contains any other non-string value,</li>
3041<li>or, the second argument is any other non-string value.</li>
3042</ul>
3043</li>
3044</ul>
3045</li>
3046<li>
3047
3048<p>Example:</p>
3049
3050<div>
3051<div>
3052<pre class="source">string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
3053</pre></div></div>
3054</li>
3055<li>
3056
3057<p>The expected result is:</p>
3058
3059<div>
3060<div>
3061<pre class="source">&quot;ASTERIX!! ROCKS~&quot;
3062</pre></div></div>
3063</li>
3064</ul></div>
3065<div class="section">
3066<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
3067<ul>
3068
3069<li>
3070
3071<p>Syntax:</p>
3072
3073<div>
3074<div>
3075<pre class="source">string_to_codepoint(string)
3076</pre></div></div>
3077</li>
3078<li>
3079
3080<p>Converts the string <tt>string</tt> to its code_based representation.</p>
3081</li>
3082<li>Arguments:
3083<ul>
3084
3085<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
3086</ul>
3087</li>
3088<li>Return Value:
3089<ul>
3090
3091<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
3092<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3093<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3094<li>any other non-string input value will cause a type error.</li>
3095</ul>
3096</li>
3097<li>
3098
3099<p>Example:</p>
3100
3101<div>
3102<div>
3103<pre class="source">string_to_codepoint(&quot;Hello ASTERIX!&quot;);
3104</pre></div></div>
3105</li>
3106<li>
3107
3108<p>The expected result is:</p>
3109
3110<div>
3111<div>
3112<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
3113</pre></div></div>
3114</li>
3115</ul></div>
3116<div class="section">
3117<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
3118<ul>
3119
3120<li>
3121
3122<p>Syntax:</p>
3123
3124<div>
3125<div>
3126<pre class="source">codepoint_to_string(array)
3127</pre></div></div>
3128</li>
3129<li>
3130
3131<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
3132</li>
3133<li>Arguments:
3134<ul>
3135
3136<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
3137</ul>
3138</li>
3139<li>Return Value:
3140<ul>
3141
3142<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
3143<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3144<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3145<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3146<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>
3147<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
3148</ul>
3149</li>
3150<li>
3151
3152<p>Example:</p>
3153
3154<div>
3155<div>
3156<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
3157</pre></div></div>
3158</li>
3159<li>
3160
3161<p>The expected result is:</p>
3162
3163<div>
3164<div>
3165<pre class="source">&quot;Hello ASTERIX!&quot;
3166</pre></div></div>
3167</li>
3168</ul></div>
3169<div class="section">
3170<h3><a name="substring_before"></a>substring_before</h3>
3171<ul>
3172
3173<li>
3174
3175<p>Syntax:</p>
3176
3177<div>
3178<div>
3179<pre class="source">substring_before(string, string_pattern)
3180</pre></div></div>
3181</li>
3182<li>
3183
3184<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
3185</li>
3186<li>Arguments:
3187<ul>
3188
3189<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3190<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3191</ul>
3192</li>
3193<li>Return Value:
3194<ul>
3195
3196<li>a <tt>string</tt> that represents the substring,</li>
3197<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3198<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3199<li>any other non-string input value will cause a type error.</li>
3200</ul>
3201</li>
3202<li>
3203
3204<p>Example:</p>
3205
3206<div>
3207<div>
3208<pre class="source">substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
3209</pre></div></div>
3210</li>
3211<li>
3212
3213<p>The expected result is:</p>
3214
3215<div>
3216<div>
3217<pre class="source">&quot; like &quot;
3218</pre></div></div>
3219</li>
3220</ul></div>
3221<div class="section">
3222<h3><a name="substring_after"></a>substring_after</h3>
3223<ul>
3224
3225<li>
3226
3227<p>Syntax:</p>
3228<p>substring_after(string, string_pattern);</p>
3229</li>
3230<li>
3231
3232<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
3233</li>
3234<li>Arguments:
3235<ul>
3236
3237<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3238<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3239</ul>
3240</li>
3241<li>Return Value:
3242<ul>
3243
3244<li>a <tt>string</tt> that represents the substring,</li>
3245<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3246<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3247<li>any other non-string input value will cause a type error.</li>
3248</ul>
3249</li>
3250<li>
3251
3252<p>Example:</p>
3253
3254<div>
3255<div>
3256<pre class="source">substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
3257</pre></div></div>
3258</li>
3259<li>
3260
3261<p>The expected result is:</p>
3262
3263<div>
3264<div>
3265<pre class="source">&quot;one&quot;
3266</pre></div></div>
3267</li>
3268</ul><!--
3269 ! Licensed to the Apache Software Foundation (ASF) under one
3270 ! or more contributor license agreements. See the NOTICE file
3271 ! distributed with this work for additional information
3272 ! regarding copyright ownership. The ASF licenses this file
3273 ! to you under the Apache License, Version 2.0 (the
3274 ! "License"); you may not use this file except in compliance
3275 ! with the License. You may obtain a copy of the License at
3276 !
3277 ! http://www.apache.org/licenses/LICENSE-2.0
3278 !
3279 ! Unless required by applicable law or agreed to in writing,
3280 ! software distributed under the License is distributed on an
3281 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3282 ! KIND, either express or implied. See the License for the
3283 ! specific language governing permissions and limitations
3284 ! under the License.
3285 !-->
3286</div></div>
3287<div class="section">
3288<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
3289<div class="section">
3290<h3><a name="parse_binary"></a>parse_binary</h3>
3291<ul>
3292
3293<li>
3294
3295<p>Syntax:</p>
3296<p>parse_binary(string, encoding)</p>
3297</li>
3298<li>
3299
3300<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
3301</li>
3302<li>Arguments:
3303<ul>
3304
3305<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
3306<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>
3307</ul>
3308</li>
3309<li>Return Value:
3310<ul>
3311
3312<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
3313<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3314<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3315<li>any other non-string input value will cause a type error.</li>
3316</ul>
3317</li>
3318<li>
3319
3320<p>Example:</p>
3321<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>
3322</li>
3323<li>
3324
3325<p>The expected result is:</p>
3326<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p>
3327</li>
3328</ul></div>
3329<div class="section">
3330<h3><a name="print_binary"></a>print_binary</h3>
3331<ul>
3332
3333<li>
3334
3335<p>Syntax:</p>
3336<p>print_binary(binary, encoding)</p>
3337</li>
3338<li>
3339
3340<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
3341</li>
3342<li>Arguments:
3343<ul>
3344
3345<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
3346<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3347</ul>
3348</li>
3349<li>Return Value:
3350<ul>
3351
3352<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
3353<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3354<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3355<li>any other non-string input value will cause a type error.</li>
3356</ul>
3357</li>
3358<li>
3359
3360<p>Example:</p>
3361
3362<div>
3363<div>
3364<pre class="source">[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3365</pre></div></div>
3366</li>
3367<li>
3368
3369<p>The expected result are:</p>
3370
3371<div>
3372<div>
3373<pre class="source">[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3374</pre></div></div>
3375</li>
3376</ul></div>
3377<div class="section">
3378<h3><a name="binary_length"></a>binary_length</h3>
3379<ul>
3380
3381<li>
3382
3383<p>Syntax:</p>
3384<p>binary_length(binary)</p>
3385</li>
3386<li>
3387
3388<p>Returns the number of bytes storing the binary data.</p>
3389</li>
3390<li>Arguments:
3391<ul>
3392
3393<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3394</ul>
3395</li>
3396<li>Return Value:
3397<ul>
3398
3399<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3400<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3401<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3402<li>any other non-binary input value will cause a type error.</li>
3403</ul>
3404</li>
3405<li>
3406
3407<p>Example:</p>
3408
3409<div>
3410<div>
3411<pre class="source">binary_length(hex(&quot;00AA&quot;))
3412</pre></div></div>
3413</li>
3414<li>
3415
3416<p>The expected result is:</p>
3417<p>2</p>
3418</li>
3419</ul></div>
3420<div class="section">
3421<h3><a name="sub_binary"></a>sub_binary</h3>
3422<ul>
3423
3424<li>
3425
3426<p>Syntax:</p>
3427<p>sub_binary(binary, offset[, length])</p>
3428</li>
3429<li>
3430
3431<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
3432</li>
3433<li>Arguments:
3434<ul>
3435
3436<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3437<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>
3438<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>
3439</ul>
3440</li>
3441<li>Return Value:
3442<ul>
3443
3444<li>a <tt>binary</tt> that represents the sub binary,</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>a type error will be raised if:
3448<ul>
3449
3450<li>the first argument is any other non-binary value,</li>
3451<li>or, the second argument is any other non-integer value,</li>
3452<li>or, the third argument is any other non-integer value, if it is present.</li>
3453</ul>
3454</li>
3455</ul>
3456</li>
3457<li>
3458
3459<p>Example:</p>
3460
3461<div>
3462<div>
3463<pre class="source">sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3464</pre></div></div>
3465</li>
3466<li>
3467
3468<p>The expected result is</p>
3469
3470<div>
3471<div>
3472<pre class="source">hex(&quot;DD&quot;)
3473</pre></div></div>
3474</li>
3475</ul></div>
3476<div class="section">
3477<h3><a name="binary_concat"></a>binary_concat</h3>
3478<ul>
3479
3480<li>
3481
3482<p>Syntax:</p>
3483<p>binary_concat(array)</p>
3484</li>
3485<li>
3486
3487<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
3488</li>
3489<li>Arguments:
3490<ul>
3491
3492<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>
3493</ul>
3494</li>
3495<li>Return Value :
3496<ul>
3497
3498<li>the concatenated <tt>binary</tt> value,</li>
3499<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3500<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3501<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3502<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>
3503<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3504</ul>
3505</li>
3506<li>
3507
3508<p>Example:</p>
3509<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p>
3510</li>
3511<li>
3512
3513<p>The expected result is</p>
3514<p>hex(&#x201c;4242&#x201d;)</p>
3515</li>
3516</ul><!--
3517 ! Licensed to the Apache Software Foundation (ASF) under one
3518 ! or more contributor license agreements. See the NOTICE file
3519 ! distributed with this work for additional information
3520 ! regarding copyright ownership. The ASF licenses this file
3521 ! to you under the Apache License, Version 2.0 (the
3522 ! "License"); you may not use this file except in compliance
3523 ! with the License. You may obtain a copy of the License at
3524 !
3525 ! http://www.apache.org/licenses/LICENSE-2.0
3526 !
3527 ! Unless required by applicable law or agreed to in writing,
3528 ! software distributed under the License is distributed on an
3529 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3530 ! KIND, either express or implied. See the License for the
3531 ! specific language governing permissions and limitations
3532 ! under the License.
3533 !-->
3534</div></div>
3535<div class="section">
3536<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3537<div class="section">
3538<h3><a name="create_point"></a>create_point</h3>
3539<ul>
3540
3541<li>
3542
3543<p>Syntax:</p>
3544
3545<div>
3546<div>
3547<pre class="source">create_point(x, y)
3548</pre></div></div>
3549</li>
3550<li>
3551
3552<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
3553</li>
3554<li>Arguments:</li>
3555<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3556<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3557<li>Return Value:</li>
3558<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3559<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3560<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3561<li>any other non-double input value will cause a type error.</li>
3562<li>
3563
3564<p>Example:</p>
3565
3566<div>
3567<div>
3568<pre class="source">{ &quot;point&quot;: create_point(30.0,70.0) };
3569</pre></div></div>
3570</li>
3571<li>
3572
3573<p>The expected result is:</p>
3574
3575<div>
3576<div>
3577<pre class="source">{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3578</pre></div></div>
3579</li>
3580</ul></div>
3581<div class="section">
3582<h3><a name="create_line"></a>create_line</h3>
3583<ul>
3584
3585<li>
3586
3587<p>Syntax:</p>
3588
3589<div>
3590<div>
3591<pre class="source">create_line(point1, point2)
3592</pre></div></div>
3593</li>
3594<li>
3595
3596<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3597</li>
3598<li>Arguments:
3599<ul>
3600
3601<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3602<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3603</ul>
3604</li>
3605<li>Return Value:
3606<ul>
3607
3608<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3609<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3610<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3611<li>any other non-point input value will cause a type error.</li>
3612</ul>
3613</li>
3614<li>
3615
3616<p>Example:</p>
3617
3618<div>
3619<div>
3620<pre class="source">{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3621</pre></div></div>
3622</li>
3623<li>
3624
3625<p>The expected result is:</p>
3626
3627<div>
3628<div>
3629<pre class="source">{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3630</pre></div></div>
3631</li>
3632</ul></div>
3633<div class="section">
3634<h3><a name="create_rectangle"></a>create_rectangle</h3>
3635<ul>
3636
3637<li>
3638
3639<p>Syntax:</p>
3640
3641<div>
3642<div>
3643<pre class="source">create_rectangle(point1, point2)
3644</pre></div></div>
3645</li>
3646<li>
3647
3648<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3649</li>
3650<li>Arguments:
3651<ul>
3652
3653<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3654<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3655</ul>
3656</li>
3657<li>Return Value:
3658<ul>
3659
3660<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3661<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3662<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3663<li>any other non-point input value will cause a type error.</li>
3664</ul>
3665</li>
3666<li>
3667
3668<p>Example:</p>
3669
3670<div>
3671<div>
3672<pre class="source">{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3673</pre></div></div>
3674</li>
3675<li>
3676
3677<p>The expected result is:</p>
3678
3679<div>
3680<div>
3681<pre class="source">{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3682</pre></div></div>
3683</li>
3684</ul></div>
3685<div class="section">
3686<h3><a name="create_circle"></a>create_circle</h3>
3687<ul>
3688
3689<li>
3690
3691<p>Syntax:</p>
3692
3693<div>
3694<div>
3695<pre class="source">create_circle(point, radius)
3696</pre></div></div>
3697</li>
3698<li>
3699
3700<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
3701</li>
3702<li>Arguments:
3703<ul>
3704
3705<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3706<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3707</ul>
3708</li>
3709<li>Return Value:
3710<ul>
3711
3712<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3713<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3714<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3715<li>a type error will be raised if:
3716<ul>
3717
3718<li>the first argument is any other non-point value,</li>
3719<li>or, the second argument is any other non-double value.</li>
3720</ul>
3721</li>
3722</ul>
3723</li>
3724<li>
3725
3726<p>Example:</p>
3727
3728<div>
3729<div>
3730<pre class="source">{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3731</pre></div></div>
3732</li>
3733<li>
3734
3735<p>The expected result is:</p>
3736
3737<div>
3738<div>
3739<pre class="source">{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3740</pre></div></div>
3741</li>
3742</ul></div>
3743<div class="section">
3744<h3><a name="create_polygon"></a>create_polygon</h3>
3745<ul>
3746
3747<li>
3748
3749<p>Syntax:</p>
3750
3751<div>
3752<div>
3753<pre class="source">create_polygon(array)
3754</pre></div></div>
3755</li>
3756<li>
3757
3758<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>
3759</li>
3760<li>Arguments:
3761<ul>
3762
3763<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3764</ul>
3765</li>
3766<li>Return Value:
3767<ul>
3768
3769<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3770<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3771<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3772<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3773<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>
3774<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3775</ul>
3776</li>
3777<li>
3778
3779<p>Example:</p>
3780
3781<div>
3782<div>
3783<pre class="source">{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3784</pre></div></div>
3785</li>
3786<li>
3787
3788<p>The expected result is:</p>
3789
3790<div>
3791<div>
3792<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;) }
3793</pre></div></div>
3794</li>
3795</ul></div>
3796<div class="section">
3797<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
3798<ul>
3799
3800<li>
3801
3802<p>Syntax:</p>
3803
3804<div>
3805<div>
3806<pre class="source">get_x(point) or get_y(point)
3807</pre></div></div>
3808</li>
3809<li>
3810
3811<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
3812</li>
3813<li>Arguments:
3814<ul>
3815
3816<li><tt>point</tt> : a <tt>point</tt>.</li>
3817</ul>
3818</li>
3819<li>Return Value:
3820<ul>
3821
3822<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3823<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3824<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3825<li>any other non-point input value will cause a type error.</li>
3826</ul>
3827</li>
3828<li>
3829
3830<p>Example:</p>
3831
3832<div>
3833<div>
3834<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)) };
3835</pre></div></div>
3836</li>
3837<li>
3838
3839<p>The expected result is:</p>
3840
3841<div>
3842<div>
3843<pre class="source">{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3844</pre></div></div>
3845</li>
3846</ul></div>
3847<div class="section">
3848<h3><a name="get_points"></a>get_points</h3>
3849<ul>
3850
3851<li>
3852
3853<p>Syntax:</p>
3854
3855<div>
3856<div>
3857<pre class="source">get_points(spatial_object)
3858</pre></div></div>
3859</li>
3860<li>
3861
3862<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
3863</li>
3864<li>Arguments:
3865<ul>
3866
3867<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3868</ul>
3869</li>
3870<li>Return Value:
3871<ul>
3872
3873<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3874<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3875<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3876<li>any other non-spatial-object input value will cause a type error.</li>
3877</ul>
3878</li>
3879<li>
3880
3881<p>Example:</p>
3882
3883<div>
3884<div>
3885<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3886</pre></div></div>
3887</li>
3888<li>
3889
3890<p>The expected result is:</p>
3891
3892<div>
3893<div>
3894<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;) ]
3895</pre></div></div>
3896</li>
3897</ul></div>
3898<div class="section">
3899<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
3900<ul>
3901
3902<li>
3903
3904<p>Syntax:</p>
3905
3906<div>
3907<div>
3908<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
3909</pre></div></div>
3910</li>
3911<li>
3912
3913<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
3914</li>
3915<li>Arguments:
3916<ul>
3917
3918<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3919</ul>
3920</li>
3921<li>Return Value:
3922<ul>
3923
3924<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3925<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3926<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3927<li>any other non-circle input value will cause a type error.</li>
3928</ul>
3929</li>
3930<li>
3931
3932<p>Example:</p>
3933
3934<div>
3935<div>
3936<pre class="source">{
3937 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3938 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3939};
3940</pre></div></div>
3941</li>
3942<li>
3943
3944<p>The expected result is:</p>
3945
3946<div>
3947<div>
3948<pre class="source">{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3949</pre></div></div>
3950</li>
3951</ul></div>
3952<div class="section">
3953<h3><a name="spatial_distance"></a>spatial_distance</h3>
3954<ul>
3955
3956<li>
3957
3958<p>Syntax:</p>
3959
3960<div>
3961<div>
3962<pre class="source">spatial_distance(point1, point2)
3963</pre></div></div>
3964</li>
3965<li>
3966
3967<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
3968</li>
3969<li>Arguments:
3970<ul>
3971
3972<li><tt>point1</tt> : a <tt>point</tt>.</li>
3973<li><tt>point2</tt> : a <tt>point</tt>.</li>
3974</ul>
3975</li>
3976<li>Return Value:
3977<ul>
3978
3979<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3980<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3981<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3982<li>any other non-point input value will cause a type error.</li>
3983</ul>
3984</li>
3985<li>
3986
3987<p>Example:</p>
3988
3989<div>
3990<div>
3991<pre class="source">spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3992</pre></div></div>
3993</li>
3994<li>
3995
3996<p>The expected result is:</p>
3997
3998<div>
3999<div>
4000<pre class="source">20.434678857275934
4001</pre></div></div>
4002</li>
4003</ul></div>
4004<div class="section">
4005<h3><a name="spatial_area"></a>spatial_area</h3>
4006<ul>
4007
4008<li>
4009
4010<p>Syntax:</p>
4011
4012<div>
4013<div>
4014<pre class="source">spatial_area(spatial_2d_expression)
4015</pre></div></div>
4016</li>
4017<li>
4018
4019<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
4020</li>
4021<li>Arguments:
4022<ul>
4023
4024<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4025</ul>
4026</li>
4027<li>Return Value:
4028<ul>
4029
4030<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
4031<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4032<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4033<li>any other non-2d-spatial-object will cause a type error.</li>
4034</ul>
4035</li>
4036<li>
4037
4038<p>Example:</p>
4039
4040<div>
4041<div>
4042<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
4043</pre></div></div>
4044</li>
4045<li>
4046
4047<p>The expected result is:</p>
4048
4049<div>
4050<div>
4051<pre class="source">78.53981625
4052</pre></div></div>
4053</li>
4054</ul></div>
4055<div class="section">
4056<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
4057<ul>
4058
4059<li>
4060
4061<p>Syntax:</p>
4062
4063<div>
4064<div>
4065<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
4066</pre></div></div>
4067</li>
4068<li>
4069
4070<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
4071</li>
4072<li>Arguments:
4073<ul>
4074
4075<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4076<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4077</ul>
4078</li>
4079<li>Return Value:
4080<ul>
4081
4082<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
4083<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4084<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4085<li>any other non-spatial-object input value will cause a type error.</li>
4086</ul>
4087</li>
4088<li>
4089
4090<p>Example:</p>
4091
4092<div>
4093<div>
4094<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)));
4095</pre></div></div>
4096</li>
4097<li>
4098
4099<p>The expected result is:</p>
4100
4101<div>
4102<div>
4103<pre class="source">true
4104</pre></div></div>
4105</li>
4106</ul></div>
4107<div class="section">
4108<h3><a name="spatial_cell"></a>spatial_cell</h3>
4109<ul>
4110
4111<li>
4112
4113<p>Syntax:</p>
4114
4115<div>
4116<div>
4117<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
4118</pre></div></div>
4119</li>
4120<li>
4121
4122<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
4123</li>
4124<li>Arguments:
4125<ul>
4126
4127<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
4128<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
4129<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
4130<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
4131</ul>
4132</li>
4133<li>Return Value:
4134<ul>
4135
4136<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
4137<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4138<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4139<li>a type error will be raised if:
4140<ul>
4141
4142<li>the first or second argument is any other non-point value,</li>
4143<li>or, the second or third argument is any other non-double value.</li>
4144</ul>
4145</li>
4146</ul>
4147</li>
4148<li>
4149
4150<p>Example:</p>
4151
4152<div>
4153<div>
4154<pre class="source">spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
4155</pre></div></div>
4156</li>
4157<li>
4158
4159<p>The expected result is:</p>
4160
4161<div>
4162<div>
4163<pre class="source">rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
4164</pre></div></div>
4165</li>
4166</ul><!--
4167 ! Licensed to the Apache Software Foundation (ASF) under one
4168 ! or more contributor license agreements. See the NOTICE file
4169 ! distributed with this work for additional information
4170 ! regarding copyright ownership. The ASF licenses this file
4171 ! to you under the Apache License, Version 2.0 (the
4172 ! "License"); you may not use this file except in compliance
4173 ! with the License. You may obtain a copy of the License at
4174 !
4175 ! http://www.apache.org/licenses/LICENSE-2.0
4176 !
4177 ! Unless required by applicable law or agreed to in writing,
4178 ! software distributed under the License is distributed on an
4179 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4180 ! KIND, either express or implied. See the License for the
4181 ! specific language governing permissions and limitations
4182 ! under the License.
4183 !-->
4184</div></div>
4185<div class="section">
4186<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
4187<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>
4188<div class="section">
4189<h3><a name="edit_distance"></a>edit_distance</h3>
4190<ul>
4191
4192<li>
4193
4194<p>Syntax:</p>
4195
4196<div>
4197<div>
4198<pre class="source">edit_distance(expression1, expression2)
4199</pre></div></div>
4200</li>
4201<li>
4202
4203<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
4204</li>
4205<li>Arguments:
4206<ul>
4207
4208<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4209<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4210</ul>
4211</li>
4212<li>Return Value:
4213<ul>
4214
4215<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
4216<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4217<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4218<li>any other non-string input value will cause a type error.</li>
4219</ul>
4220</li>
4221<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4222<li>Example:
4223
4224<div>
4225<div>
4226<pre class="source">edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
4227</pre></div></div>
4228</li>
4229<li>
4230
4231<p>The expected result is:</p>
4232
4233<div>
4234<div>
4235<pre class="source">2
4236</pre></div></div>
4237</li>
4238</ul></div>
4239<div class="section">
4240<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
4241<ul>
4242
4243<li>
4244
4245<p>Syntax:</p>
4246
4247<div>
4248<div>
4249<pre class="source">edit_distance_check(expression1, expression2, threshold)
4250</pre></div></div>
4251</li>
4252<li>
4253
4254<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
4255</li>
4256<li>
4257
4258<p>Arguments:</p>
4259<ul>
4260
4261<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4262<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4263<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4264</ul>
4265</li>
4266<li>Return Value:
4267<ul>
4268
4269<li>an <tt>array</tt> with two items:
4270<ul>
4271
4272<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>
4273<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>
4274<li>If the first item is false, then the second item is set to 2147483647.</li>
4275</ul>
4276</li>
4277<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4278<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4279<li>a type error will be raised if:
4280<ul>
4281
4282<li>the first or second argument is any other non-string value,</li>
4283<li>or, the third argument is any other non-bigint value.</li>
4284</ul>
4285</li>
4286</ul>
4287</li>
4288<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4289<li>Example:
4290
4291<div>
4292<div>
4293<pre class="source">edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
4294</pre></div></div>
4295</li>
4296<li>
4297
4298<p>The expected result is:</p>
4299
4300<div>
4301<div>
4302<pre class="source">[ true, 2 ]
4303</pre></div></div>
4304</li>
4305</ul></div>
4306<div class="section">
4307<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
4308<ul>
4309
4310<li>
4311
4312<p>Syntax:</p>
4313
4314<div>
4315<div>
4316<pre class="source">edit_distance_contains(expression1, expression2, threshold)
4317</pre></div></div>
4318</li>
4319<li>
4320
4321<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>
4322</li>
4323<li>
4324
4325<p>Arguments:</p>
4326<ul>
4327
4328<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4329<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4330<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4331</ul>
4332</li>
4333<li>Return Value:
4334<ul>
4335
4336<li>an <tt>array</tt> with two items:
4337<ul>
4338
4339<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
4340<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>
4341</ul>
4342</li>
4343<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4344<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4345<li>a type error will be raised if:
4346<ul>
4347
4348<li>the first or second argument is any other non-string value,</li>
4349<li>or, the third argument is any other non-bigint value.</li>
4350</ul>
4351</li>
4352</ul>
4353</li>
4354<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4355<li>Example:
4356
4357<div>
4358<div>
4359<pre class="source">edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4360</pre></div></div>
4361</li>
4362<li>
4363
4364<p>The expected result is:</p>
4365
4366<div>
4367<div>
4368<pre class="source">[ true, 1 ]
4369</pre></div></div>
4370</li>
4371</ul></div>
4372<div class="section">
4373<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4374<ul>
4375
4376<li>
4377
4378<p>Syntax:</p>
4379
4380<div>
4381<div>
4382<pre class="source">similarity_jaccard(array1, array2)
4383</pre></div></div>
4384</li>
4385<li>
4386
4387<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>
4388</li>
4389<li>Arguments:
4390<ul>
4391
4392<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4393<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4394</ul>
4395</li>
4396<li>Return Value:
4397<ul>
4398
4399<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4400<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4401<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4402<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4403<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>
4404<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4405</ul>
4406</li>
4407<li>
4408
4409<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4410</li>
4411<li>Example:
4412
4413<div>
4414<div>
4415<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
4416</pre></div></div>
4417</li>
4418<li>
4419
4420<p>The expected result is:</p>
4421
4422<div>
4423<div>
4424<pre class="source">0.6
4425</pre></div></div>
4426</li>
4427</ul></div>
4428<div class="section">
4429<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4430<ul>
4431
4432<li>
4433
4434<p>Syntax:</p>
4435
4436<div>
4437<div>
4438<pre class="source">similarity_jaccard_check(array1, array2, threshold)
4439</pre></div></div>
4440</li>
4441<li>
4442
4443<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>
4444</li>
4445<li>
4446
4447<p>Arguments:</p>
4448<ul>
4449
4450<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4451<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4452<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4453</ul>
4454</li>
4455<li>Return Value:
4456<ul>
4457
4458<li>an <tt>array</tt> with two items:
4459<ul>
4460
4461<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4462<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>
4463</ul>
4464</li>
4465<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4466<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4467<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4468<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>
4469<li>a type error will be raised if:
4470<ul>
4471
4472<li>the first or second argument is any other non-array value,
4473<ul>
4474
4475<li>or, the third argument is any other non-double value.</li>
4476</ul>
4477</li>
4478</ul>
4479</li>
4480</ul>
4481</li>
4482<li>
4483
4484<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4485</li>
4486<li>Example:
4487
4488<div>
4489<div>
4490<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4491</pre></div></div>
4492</li>
4493<li>
4494
4495<p>The expected result is:</p>
4496
4497<div>
4498<div>
4499<pre class="source">[ false, 0.0 ]
4500</pre></div></div>
4501</li>
4502</ul><!--
4503 ! Licensed to the Apache Software Foundation (ASF) under one
4504 ! or more contributor license agreements. See the NOTICE file
4505 ! distributed with this work for additional information
4506 ! regarding copyright ownership. The ASF licenses this file
4507 ! to you under the Apache License, Version 2.0 (the
4508 ! "License"); you may not use this file except in compliance
4509 ! with the License. You may obtain a copy of the License at
4510 !
4511 ! http://www.apache.org/licenses/LICENSE-2.0
4512 !
4513 ! Unless required by applicable law or agreed to in writing,
4514 ! software distributed under the License is distributed on an
4515 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4516 ! KIND, either express or implied. See the License for the
4517 ! specific language governing permissions and limitations
4518 ! under the License.
4519 !-->
4520</div></div>
4521<div class="section">
4522<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4523<div class="section">
4524<h3><a name="word_tokens"></a>word_tokens</h3>
4525<ul>
4526
4527<li>
4528
4529<p>Syntax:</p>
4530
4531<div>
4532<div>
4533<pre class="source">word_tokens(string)
4534</pre></div></div>
4535</li>
4536<li>
4537
4538<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
4539</li>
4540<li>Arguments:
4541<ul>
4542
4543<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4544</ul>
4545</li>
4546<li>Return Value:
4547<ul>
4548
4549<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4550<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4551<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4552<li>any other non-string input value will cause a type error.</li>
4553</ul>
4554</li>
4555<li>
4556
4557<p>Example:</p>
4558
4559<div>
4560<div>
4561<pre class="source">word_tokens(&quot;I like the phone, awesome!&quot;);
4562</pre></div></div>
4563</li>
4564<li>
4565
4566<p>The expected result is:</p>
4567
4568<div>
4569<div>
4570<pre class="source">[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4571</pre></div></div>
4572</li>
4573</ul><!--
4574 ! Licensed to the Apache Software Foundation (ASF) under one
4575 ! or more contributor license agreements. See the NOTICE file
4576 ! distributed with this work for additional information
4577 ! regarding copyright ownership. The ASF licenses this file
4578 ! to you under the Apache License, Version 2.0 (the
4579 ! "License"); you may not use this file except in compliance
4580 ! with the License. You may obtain a copy of the License at
4581 !
4582 ! http://www.apache.org/licenses/LICENSE-2.0
4583 !
4584 ! Unless required by applicable law or agreed to in writing,
4585 ! software distributed under the License is distributed on an
4586 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4587 ! KIND, either express or implied. See the License for the
4588 ! specific language governing permissions and limitations
4589 ! under the License.
4590 !-->
4591</div></div>
4592<div class="section">
4593<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4594<div class="section">
4595<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>
4596<ul>
4597
4598<li>
4599
4600<p>Syntax:</p>
4601
4602<div>
4603<div>
4604<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4605</pre></div></div>
4606</li>
4607<li>
4608
4609<p>Accessors for accessing fields in a temporal value</p>
4610</li>
4611<li>Arguments:
4612<ul>
4613
4614<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>
4615</ul>
4616</li>
4617<li>Return Value:
4618<ul>
4619
4620<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4621<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4622<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4623<li>any other non-interval input value will cause a type error.</li>
4624</ul>
4625</li>
4626<li>
4627
4628<p>Example:</p>
4629
4630<div>
4631<div>
4632<pre class="source">{
4633 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4634 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4635 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4636 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4637 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4638 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4639 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4640};
4641</pre></div></div>
4642</li>
4643<li>
4644
4645<p>The expected result is:</p>
4646
4647<div>
4648<div>
4649<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 }
4650</pre></div></div>
4651</li>
4652</ul></div>
4653<div class="section">
4654<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4655<ul>
4656
4657<li>
4658
4659<p>Syntax:</p>
4660
4661<div>
4662<div>
4663<pre class="source">adjust_datetime_for_timezone(datetime, string)
4664</pre></div></div>
4665</li>
4666<li>
4667
4668<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
4669</li>
4670<li>Arguments:
4671<ul>
4672
4673<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4674<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4675</ul>
4676</li>
4677<li>Return Value:
4678<ul>
4679
4680<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4681<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4682<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4683<li>a type error will be raised if:
4684<ul>
4685
4686<li>the first argument is any other non-datetime value,</li>
4687<li>or, the second argument is any other non-string value.</li>
4688</ul>
4689</li>
4690</ul>
4691</li>
4692<li>
4693
4694<p>Example:</p>
4695
4696<div>
4697<div>
4698<pre class="source">adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4699</pre></div></div>
4700</li>
4701<li>
4702
4703<p>The expected result is:</p>
4704
4705<div>
4706<div>
4707<pre class="source">&quot;2008-04-26T18:10:00.000+08:00&quot;
4708</pre></div></div>
4709</li>
4710</ul></div>
4711<div class="section">
4712<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4713<ul>
4714
4715<li>
4716
4717<p>Syntax:</p>
4718
4719<div>
4720<div>
4721<pre class="source">adjust_time_for_timezone(time, string)
4722</pre></div></div>
4723</li>
4724<li>
4725
4726<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
4727</li>
4728<li>Arguments:
4729<ul>
4730
4731<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4732<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4733</ul>
4734</li>
4735<li>Return Value:
4736<ul>
4737
4738<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4739<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4740<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4741<li>a type error will be raised if:
4742<ul>
4743
4744<li>the first argument is any other non-time value,</li>
4745<li>or, the second argument is any other non-string value.</li>
4746</ul>
4747</li>
4748</ul>
4749</li>
4750<li>
4751
4752<p>Example:</p>
4753
4754<div>
4755<div>
4756<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4757</pre></div></div>
4758</li>
4759<li>
4760
4761<p>The expected result is:</p>
4762
4763<div>
4764<div>
4765<pre class="source">&quot;18:10:00.000+08:00&quot;
4766</pre></div></div>
4767</li>
4768</ul></div>
4769<div class="section">
4770<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4771<ul>
4772
4773<li>
4774
4775<p>Syntax:</p>
4776
4777<div>
4778<div>
4779<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
4780</pre></div></div>
4781</li>
4782<li>
4783
4784<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
4785</li>
4786<li>Arguments:
4787<ul>
4788
4789<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4790<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4791</ul>
4792</li>
4793<li>Return Value:
4794<ul>
4795
4796<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4797<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4798<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4799<li>a type error will be raised if:
4800<ul>
4801
4802<li>the first argument is any other non-datetime value,</li>
4803<li>or, the second argument is any other non-duration input value.</li>
4804</ul>
4805</li>
4806</ul>
4807</li>
4808<li>
4809
4810<p>Example:</p>
4811
4812<div>
4813<div>
4814<pre class="source">calendar_duration_from_datetime(
4815 datetime(&quot;2016-03-26T10:10:00&quot;),
4816 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4817);
4818</pre></div></div>
4819</li>
4820<li>
4821
4822<p>The expected result is:</p>
4823
4824<div>
4825<div>
4826<pre class="source">duration(&quot;P5Y2M24DT10H10M&quot;)
4827</pre></div></div>
4828</li>
4829</ul></div>
4830<div class="section">
4831<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4832<ul>
4833
4834<li>
4835
4836<p>Syntax:</p>
4837
4838<div>
4839<div>
4840<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
4841</pre></div></div>
4842</li>
4843<li>
4844
4845<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
4846</li>
4847<li>Arguments:
4848<ul>
4849
4850<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4851</ul>
4852</li>
4853<li>Return Value:
4854<ul>
4855
4856<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4857<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4858<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4859<li>any other non-duration input value will cause a type error.</li>
4860</ul>
4861</li>
4862<li>
4863
4864<p>Example:</p>
4865
4866<div>
4867<div>
4868<pre class="source">get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4869</pre></div></div>
4870</li>
4871<li>
4872
4873<p>The expected result is:</p>
4874
4875<div>
4876<div>
4877<pre class="source">year_month_duration(&quot;P1Y&quot;)
4878</pre></div></div>
4879</li>
4880</ul></div>
4881<div class="section">
4882<h3><a name="months_from_year_month_duration.2Fms_from_day_time_duration"></a>months_from_year_month_duration/ms_from_day_time_duration</h3>
4883<ul>
4884
4885<li>
4886
4887<p>Syntax:</p>
4888
4889<div>
4890<div>
4891<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
4892</pre></div></div>
4893</li>
4894<li>
4895
4896<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
4897</li>
4898<li>Arguments:
4899<ul>
4900
4901<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4902</ul>
4903</li>
4904<li>Return Value:
4905<ul>
4906
4907<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
4908<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4909<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4910<li>any other non-duration input value will cause a type error.</li>
4911</ul>
4912</li>
4913<li>
4914
4915<p>Example:</p>
4916
4917<div>
4918<div>
4919<pre class="source">{
4920 &quot;months&quot;: months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;))),
4921 &quot;milliseconds&quot;: ms_from_day_time_duration(get_day_time_duration(duration(&quot;P5Y7MT50M&quot;)))
4922};
4923</pre></div></div>
4924</li>
4925<li>
4926
4927<p>The expected result is:</p>
4928
4929<div>
4930<div>
4931<pre class="source">{&quot;months&quot;: 67, &quot;milliseconds&quot;: 3000000}
4932</pre></div></div>
4933</li>
4934</ul></div>
4935<div class="section">
4936<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4937<ul>
4938
4939<li>
4940
4941<p>Syntax:</p>
4942
4943<div>
4944<div>
4945<pre class="source">duration_from_months/duration_from_ms(number_value)
4946</pre></div></div>
4947</li>
4948<li>
4949
4950<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
4951</li>
4952<li>Arguments:
4953<ul>
4954
4955<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4956</ul>
4957</li>
4958<li>Return Value:
4959<ul>
4960
4961<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4962<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4963<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4964<li>any other non-duration input value will cause a type error.</li>
4965</ul>
4966</li>
4967<li>
4968
4969<p>Example:</p>
4970
4971<div>
4972<div>
4973<pre class="source">duration_from_months(8);
4974</pre></div></div>
4975</li>
4976<li>
4977
4978<p>The expected result is:</p>
4979
4980<div>
4981<div>
4982<pre class="source">duration(&quot;P8M&quot;)
4983</pre></div></div>
4984</li>
4985</ul></div>
4986<div class="section">
4987<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4988<ul>
4989
4990<li>
4991
4992<p>Syntax:</p>
4993
4994<div>
4995<div>
4996<pre class="source">duration_from_interval(interval_value)
4997</pre></div></div>
4998</li>
4999<li>
5000
5001<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
5002</li>
5003<li>Arguments:
5004<ul>
5005
5006<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
5007</ul>
5008</li>
5009<li>Return Value:
5010<ul>
5011
5012<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
5013<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5014<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5015<li>any other non-duration input value will cause a type error.</li>
5016</ul>
5017</li>
5018<li>
5019
5020<p>Example:</p>
5021
5022<div>
5023<div>
5024<pre class="source">{
5025 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
5026 &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;))),
5027 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
5028 &quot;dr4&quot; : duration_from_interval(null)
5029};
5030</pre></div></div>
5031</li>
5032<li>
5033
5034<p>The expected result is:</p>
5035
5036<div>
5037<div>
5038<pre class="source">{
5039 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
5040 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
5041 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
5042 &quot;dr4&quot;: null
5043}
5044</pre></div></div>
5045</li>
5046</ul></div>
5047<div class="section">
5048<h3><a name="current_date"></a>current_date</h3>
5049<ul>
5050
5051<li>
5052
5053<p>Syntax:</p>
5054
5055<div>
5056<div>
5057<pre class="source">current_date()
5058</pre></div></div>
5059</li>
5060<li>
5061
5062<p>Gets the current date.</p>
5063</li>
5064<li>Arguments: None</li>
5065<li>Return Value:
5066<ul>
5067
5068<li>a <tt>date</tt> value of the date when the function is called.</li>
5069</ul>
5070</li>
5071</ul></div>
5072<div class="section">
5073<h3><a name="current_time"></a>current_time</h3>
5074<ul>
5075
5076<li>
5077
5078<p>Syntax:</p>
5079
5080<div>
5081<div>
5082<pre class="source">current_time()
5083</pre></div></div>
5084</li>
5085<li>
5086
5087<p>Get the current time</p>
5088</li>
5089<li>Arguments: None</li>
5090<li>Return Value:
5091<ul>
5092
5093<li>a <tt>time</tt> value of the time when the function is called.</li>
5094</ul>
5095</li>
5096</ul></div>
5097<div class="section">
5098<h3><a name="current_datetime"></a>current_datetime</h3>
5099<ul>
5100
5101<li>
5102
5103<p>Syntax:</p>
5104
5105<div>
5106<div>
5107<pre class="source">current_datetime()
5108</pre></div></div>
5109</li>
5110<li>
5111
5112<p>Get the current datetime</p>
5113</li>
5114<li>Arguments: None</li>
5115<li>Return Value:
5116<ul>
5117
5118<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
5119</ul>
5120</li>
5121</ul></div>
5122<div class="section">
5123<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
5124<ul>
5125
5126<li>
5127
5128<p>Syntax:</p>
5129
5130<div>
5131<div>
5132<pre class="source">get_date_from_datetime(datetime)
5133</pre></div></div>
5134</li>
5135<li>
5136
5137<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
5138</li>
5139<li>Arguments:
5140<ul>
5141
5142<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5143</ul>
5144</li>
5145<li>Return Value:
5146<ul>
5147
5148<li>a <tt>date</tt> value from the datetime,</li>
5149<li>any other non-datetime input value will cause a type error.</li>
5150</ul>
5151</li>
5152</ul></div>
5153<div class="section">
5154<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
5155<ul>
5156
5157<li>
5158
5159<p>Syntax:</p>
5160
5161<div>
5162<div>
5163<pre class="source">get_time_from_datetime(datetime)
5164</pre></div></div>
5165</li>
5166<li>
5167
5168<p>Get the time value from the given datetime value <tt>datetime</tt></p>
5169</li>
5170<li>Arguments:
5171<ul>
5172
5173<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5174</ul>
5175</li>
5176<li>Return Value:
5177<ul>
5178
5179<li>a <tt>time</tt> value from the datetime.</li>
5180<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5181<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5182<li>any other non-datetime input value will cause a type error.</li>
5183</ul>
5184</li>
5185<li>
5186
5187<p>Example:</p>
5188
5189<div>
5190<div>
5191<pre class="source">get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
5192</pre></div></div>
5193</li>
5194<li>
5195
5196<p>The expected result is:</p>
5197
5198<div>
5199<div>
5200<pre class="source">time(&quot;10:10:00.000Z&quot;)
5201</pre></div></div>
5202</li>
5203</ul></div>
5204<div class="section">
5205<h3><a name="day_of_week"></a>day_of_week</h3>
5206<ul>
5207
5208<li>
5209
5210<p>Syntax:</p>
5211
5212<div>
5213<div>
5214<pre class="source">day_of_week(date)
5215</pre></div></div>
5216</li>
5217<li>
5218
5219<p>Finds the day of the week for a given date (1_7)</p>
5220</li>
5221<li>Arguments:
5222<ul>
5223
5224<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
5225</ul>
5226</li>
5227<li>Return Value:
5228<ul>
5229
5230<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
5231<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5232<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5233<li>any other non-date input value will cause a type error.</li>
5234</ul>
5235</li>
5236<li>
5237
5238<p>Example:</p>
5239
5240<div>
5241<div>
5242<pre class="source">day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
5243</pre></div></div>
5244</li>
5245<li>
5246
5247<p>The expected result is:</p>
5248
5249<div>
5250<div>
5251<pre class="source">7
5252</pre></div></div>
5253</li>
5254</ul></div>
5255<div class="section">
5256<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
5257<ul>
5258
5259<li>
5260
5261<p>Syntax:</p>
5262
5263<div>
5264<div>
5265<pre class="source">date_from_unix_time_in_days(numeric_value)
5266</pre></div></div>
5267</li>
5268<li>
5269
5270<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
5271</li>
5272<li>Arguments:
5273<ul>
5274
5275<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>
5276</ul>
5277</li>
5278<li>Return Value:
5279<ul>
5280
5281<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
5282<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5283<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5284<li>any other non-numeric input value will cause a type error.</li>
5285</ul>
5286</li>
5287</ul></div>
5288<div class="section">
5289<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
5290<ul>
5291
5292<li>
5293
5294<p>Syntax:</p>
5295
5296<div>
5297<div>
5298<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
5299</pre></div></div>
5300</li>
5301<li>
5302
5303<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
5304</li>
5305<li>Arguments:
5306<ul>
5307
5308<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>
5309</ul>
5310</li>
5311<li>Return Value:
5312<ul>
5313
5314<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5315<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5316<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5317<li>any other non-numeric input value will cause a type error.</li>
5318</ul>
5319</li>
5320</ul></div>
5321<div class="section">
5322<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5323<ul>
5324
5325<li>
5326
5327<p>Syntax:</p>
5328
5329<div>
5330<div>
5331<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
5332</pre></div></div>
5333</li>
5334<li>
5335
5336<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
5337</li>
5338<li>Arguments:
5339<ul>
5340
5341<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>
5342</ul>
5343</li>
5344<li>Return Value:
5345<ul>
5346
5347<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5348<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5349<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5350<li>any other non-numeric input value will cause a type error.</li>
5351</ul>
5352</li>
5353</ul></div>
5354<div class="section">
5355<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5356<ul>
5357
5358<li>Syntax:</li>
5359</ul>
5360<p>datetime_from_date_time(date,time)</p>
5361<ul>
5362
5363<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5364<ul>
5365
5366<li>Arguments:</li>
5367<li><tt>date</tt>: a <tt>date</tt> value</li>
5368<li><tt>time</tt> a <tt>time</tt> value</li>
5369</ul>
5370</li>
5371<li>Return Value:
5372<ul>
5373
5374<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5375<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5376<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5377<li>a type error will be raised if
5378<ul>
5379
5380<li>the first argument is any other non-date value,</li>
5381<li>or, the second argument is any other non-time value.</li>
5382</ul>
5383</li>
5384</ul>
5385</li>
5386</ul></div>
5387<div class="section">
5388<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5389<ul>
5390
5391<li>
5392
5393<p>Syntax:</p>
5394
5395<div>
5396<div>
5397<pre class="source">time_from_unix_time_in_ms(numeric_value)
5398</pre></div></div>
5399</li>
5400<li>
5401
5402<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
5403</li>
5404<li>Arguments:
5405<ul>
5406
5407<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>
5408</ul>
5409</li>
5410<li>Return Value:
5411<ul>
5412
5413<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5414<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5415<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5416<li>any other non-numeric input value will cause a type error.</li>
5417</ul>
5418</li>
5419<li>
5420
5421<p>Example:</p>
5422
5423<div>
5424<div>
5425<pre class="source">{
5426 &quot;date&quot;: date_from_unix_time_in_days(15800),
5427 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5428 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5429};
5430</pre></div></div>
5431</li>
5432<li>
5433
5434<p>The expected result is:</p>
5435
5436<div>
5437<div>
5438<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;) }
5439</pre></div></div>
5440</li>
5441</ul></div>
5442<div class="section">
5443<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5444<ul>
5445
5446<li>
5447
5448<p>Syntax:</p>
5449
5450<div>
5451<div>
5452<pre class="source">unix_time_from_date_in_days(date_value)
5453</pre></div></div>
5454</li>
5455<li>
5456
5457<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
5458</li>
5459<li>Arguments:
5460<ul>
5461
5462<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5463</ul>
5464</li>
5465<li>Return Value:
5466<ul>
5467
5468<li>a <tt>bigint</tt> value representing the number of days,</li>
5469<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5470<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5471<li>any other non-date input value will cause a type error.</li>
5472</ul>
5473</li>
5474</ul></div>
5475<div class="section">
5476<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5477<ul>
5478
5479<li>
5480
5481<p>Syntax:</p>
5482
5483<div>
5484<div>
5485<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
5486</pre></div></div>
5487</li>
5488<li>
5489
5490<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5491</li>
5492<li>Arguments:
5493<ul>
5494
5495<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5496</ul>
5497</li>
5498<li>Return Value:
5499<ul>
5500
5501<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5502<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5503<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5504<li>any other non-datetime input value will cause a type error.</li>
5505</ul>
5506</li>
5507</ul></div>
5508<div class="section">
5509<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5510<ul>
5511
5512<li>
5513
5514<p>Syntax:</p>
5515
5516<div>
5517<div>
5518<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
5519</pre></div></div>
5520</li>
5521<li>
5522
5523<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5524</li>
5525<li>Arguments:
5526<ul>
5527
5528<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5529</ul>
5530</li>
5531<li>Return Value:
5532<ul>
5533
5534<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5535<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5536<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5537<li>any other non-datetime input value will cause a type error.</li>
5538</ul>
5539</li>
5540</ul></div>
5541<div class="section">
5542<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5543<ul>
5544
5545<li>
5546
5547<p>Syntax:</p>
5548
5549<div>
5550<div>
5551<pre class="source">unix_time_from_time_in_ms(time_value)
5552</pre></div></div>
5553</li>
5554<li>
5555
5556<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
5557</li>
5558<li>Arguments:
5559<ul>
5560
5561<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5562</ul>
5563</li>
5564<li>Return Value:
5565<ul>
5566
5567<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5568<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5569<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5570<li>any other non-datetime input value will cause a type error.</li>
5571</ul>
5572</li>
5573<li>
5574
5575<p>Example:</p>
5576
5577<div>
5578<div>
5579<pre class="source">{
5580 &quot;date&quot;: date_from_unix_time_in_days(15800),
5581 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5582 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5583}
5584</pre></div></div>
5585</li>
5586<li>
5587
5588<p>The expected result is:</p>
5589
5590<div>
5591<div>
5592<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;) }
5593</pre></div></div>
5594</li>
5595</ul></div>
5596<div class="section">
5597<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5598<ul>
5599
5600<li>Syntax:</li>
5601</ul>
5602<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5603<ul>
5604
5605<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5606<li>Arguments:
5607<ul>
5608
5609<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5610<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>
5611<li><tt>h</tt> hours</li>
5612<li><tt>m</tt> minutes</li>
5613<li><tt>s</tt> seconds</li>
5614<li><tt>n</tt> milliseconds</li>
5615<li><tt>a</tt> am/pm</li>
5616<li><tt>z</tt> timezone</li>
5617<li><tt>Y</tt> year</li>
5618<li><tt>M</tt> month</li>
5619<li><tt>D</tt> day</li>
5620<li><tt>W</tt> weekday</li>
5621<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5622</ul>
5623</li>
5624<li>Return Value:
5625<ul>
5626
5627<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5628<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5629<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5630<li>a type error will be raised if:</li>
5631<li>the first argument is any other non-date value,</li>
5632<li>the second argument is any other non-string value.</li>
5633</ul>
5634</li>
5635<li>
5636
5637<p>Example:</p>
5638
5639<div>
5640<div>
5641<pre class="source">parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5642</pre></div></div>
5643</li>
5644<li>
5645
5646<p>The expected result is:</p>
5647
5648<div>
5649<div>
5650<pre class="source">time(&quot;00:30:30.000Z&quot;)
5651</pre></div></div>
5652</li>
5653</ul></div>
5654<div class="section">
5655<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
5656<ul>
5657
5658<li>
5659
5660<p>Syntax:</p>
5661
5662<div>
5663<div>
5664<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
5665</pre></div></div>
5666</li>
5667<li>
5668
5669<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>
5670</li>
5671<li>Arguments:
5672<ul>
5673
5674<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5675<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>
5676<li><tt>h</tt> hours</li>
5677<li><tt>m</tt> minutes</li>
5678<li><tt>s</tt> seconds</li>
5679<li><tt>n</tt> milliseconds</li>
5680<li><tt>a</tt> am/pm</li>
5681<li><tt>z</tt> timezone</li>
5682<li><tt>Y</tt> year</li>
5683<li><tt>M</tt> month</li>
5684<li><tt>D</tt> day</li>
5685<li><tt>W</tt> weekday</li>
5686<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5687</ul>
5688</li>
5689<li>Return Value:
5690<ul>
5691
5692<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5693<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5694<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5695<li>a type error will be raised if:
5696<ul>
5697
5698<li>the first argument is any other non-date value,</li>
5699<li>the second argument is any other non-string value.</li>
5700</ul>
5701</li>
5702</ul>
5703</li>
5704<li>
5705
5706<p>Example:</p>
5707
5708<div>
5709<div>
5710<pre class="source">print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5711</pre></div></div>
5712</li>
5713<li>
5714
5715<p>The expected result is:</p>
5716
5717<div>
5718<div>
5719<pre class="source">&quot;30:30&quot;
5720</pre></div></div>
5721</li>
5722</ul></div>
5723<div class="section">
5724<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5725<ul>
5726
5727<li>
5728
5729<p>Syntax:</p>
5730
5731<div>
5732<div>
5733<pre class="source">get_interval_start/get_interval_end(interval)
5734</pre></div></div>
5735</li>
5736<li>
5737
5738<p>Gets the start/end of the given interval.</p>
5739</li>
5740<li>Arguments:
5741<ul>
5742
5743<li><tt>interval</tt>: the interval to be accessed.</li>
5744</ul>
5745</li>
5746<li>Return Value:
5747<ul>
5748
5749<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>
5750<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5751<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5752<li>any other non-interval value will cause a type error.</li>
5753</ul>
5754</li>
5755<li>
5756
5757<p>Example:</p>
5758
5759<div>
5760<div>
5761<pre class="source">{
5762 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5763 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5764};
5765</pre></div></div>
5766</li>
5767<li>
5768
5769<p>The expected result is:</p>
5770
5771<div>
5772<div>
5773<pre class="source">{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5774</pre></div></div>
5775</li>
5776</ul></div>
5777<div class="section">
5778<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>
5779<ul>
5780
5781<li>
5782
5783<p>Syntax:</p>
5784
5785<div>
5786<div>
5787<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)
5788</pre></div></div>
5789</li>
5790<li>
5791
5792<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5793</li>
5794<li>Arguments:
5795<ul>
5796
5797<li><tt>interval</tt>: the interval to be accessed.</li>
5798</ul>
5799</li>
5800<li>Return Value:
5801<ul>
5802
5803<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5804<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5805<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5806<li>any other non-interval value will cause a type error.</li>
5807</ul>
5808</li>
5809<li>
5810
5811<p>Example:</p>
5812
5813<div>
5814<div>
5815<pre class="source">{
5816 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5817 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5818 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5819 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5820 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5821 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5822};
5823</pre></div></div>
5824</li>
5825<li>
5826
5827<p>The expected result is:</p>
5828
5829<div>
5830<div>
5831<pre class="source">{
5832 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5833 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5834 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5835 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5836 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5837 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5838}
5839</pre></div></div>
5840</li>
5841</ul></div>
5842<div class="section">
5843<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5844<ul>
5845
5846<li>
5847
5848<p>Syntax:</p>
5849
5850<div>
5851<div>
5852<pre class="source">get_overlapping_interval(interval1, interval2)
5853</pre></div></div>
5854</li>
5855<li>
5856
5857<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5858</li>
5859<li>Arguments:
5860<ul>
5861
5862<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5863<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5864</ul>
5865</li>
5866<li>Return Value:
5867<ul>
5868
5869<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>
5870<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5871<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5872<li>any other non-interval input value will cause a type error.</li>
5873</ul>
5874</li>
5875<li>
5876
5877<p>Example:</p>
5878
5879<div>
5880<div>
5881<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;))),
5882 &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;))),
5883 &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;))),
5884 &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;))),
5885 &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;))),
5886 &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;)))
5887};
5888</pre></div></div>
5889</li>
5890<li>
5891
5892<p>The expected result is:</p>
5893
5894<div>
5895<div>
5896<pre class="source">{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5897 &quot;overlap2&quot;: null,
5898 &quot;overlap3&quot;: null,
5899 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5900 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5901 &quot;overlap6&quot;: null
5902}
5903</pre></div></div>
5904</li>
5905</ul></div>
5906<div class="section">
5907<h3><a name="interval_bin"></a>interval_bin</h3>
5908<ul>
5909
5910<li>
5911
5912<p>Syntax:</p>
5913
5914<div>
5915<div>
5916<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5917</pre></div></div>
5918</li>
5919<li>
5920
5921<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
5922</li>
5923<li>Arguments:
5924<ul>
5925
5926<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5927<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>
5928<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:
5929<ul>
5930
5931<li>datetime +|_ year_month_duration</li>
5932<li>datetime +|_ day_time_duration</li>
5933<li>date +|_ year_month_duration</li>
5934<li>date +|_ day_time_duration</li>
5935<li>time +|_ day_time_duration</li>
5936</ul>
5937</li>
5938</ul>
5939</li>
5940<li>Return Value:
5941<ul>
5942
5943<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>
5944<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5945<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5946<li>a type error will be raised if:
5947<ul>
5948
5949<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5950<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5951</ul>
5952</li>
5953</ul>
5954</li>
5955<li>
5956
5957<p>Example:</p>
5958
5959<div>
5960<div>
5961<pre class="source">{
5962 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5963 &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;)),
5964 &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;)),
5965 &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;))
5966};
5967</pre></div></div>
5968</li>
5969<li>
5970
5971<p>The expected result is:</p>
5972
5973<div>
5974<div>
5975<pre class="source">{
5976 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5977 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5978 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5979 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5980}
5981</pre></div></div>
5982</li>
5983</ul></div>
5984<div class="section">
5985<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
5986<ul>
5987
5988<li>
5989
5990<p>Syntax:</p>
5991
5992<div>
5993<div>
5994<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
5995</pre></div></div>
5996</li>
5997<li>
5998
5999<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>
6000</li>
6001<li>Arguments:
6002<ul>
6003
6004<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>
6005<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>
6006</ul>
6007</li>
6008<li>Return Value:
6009<ul>
6010
6011<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
6012<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6013<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6014<li>a type error will be raised if:
6015<ul>
6016
6017<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
6018<li>or, the second argument is any other non-duration value.</li>
6019</ul>
6020</li>
6021</ul>
6022</li>
6023<li>
6024
6025<p>Example:</p>
6026
6027<div>
6028<div>
6029<pre class="source">{
6030 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
6031 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
6032 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
6033};
6034</pre></div></div>
6035</li>
6036<li>
6037
6038<p>The expectecd result is:</p>
6039
6040<div>
6041<div>
6042<pre class="source">{
6043 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
6044 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
6045 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
6046}
6047</pre></div></div>
6048</li>
6049</ul></div>
6050<div class="section">
6051<h3><a name="overlap_bins"></a>overlap_bins</h3>
6052<ul>
6053
6054<li>
6055
6056<p>Return Value:</p>
6057<ul>
6058
6059<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>
6060</ul>
6061</li>
6062<li>
6063
6064<p>Syntax:</p>
6065
6066<div>
6067<div>
6068<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
6069</pre></div></div>
6070</li>
6071<li>
6072
6073<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
6074</li>
6075<li>Arguments:
6076<ul>
6077
6078<li><tt>interval</tt>: an <tt>interval</tt> value</li>
6079<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>
6080<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:
6081<ul>
6082
6083<li>datetime +|_ year_month_duration</li>
6084<li>datetime +|_ day_time_duration</li>
6085<li>date +|_ year_month_duration</li>
6086<li>date +|_ day_time_duration</li>
6087<li>time +|_ day_time_duration</li>
6088</ul>
6089</li>
6090</ul>
6091</li>
6092<li>Return Value:
6093<ul>
6094
6095<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>
6096<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6097<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6098<li>a type error will be raised if:
6099<ul>
6100
6101<li>the first arugment is any other non-interval value,</li>
6102<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
6103<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
6104</ul>
6105</li>
6106</ul>
6107</li>
6108<li>
6109
6110<p>Example:</p>
6111
6112<div>
6113<div>
6114<pre class="source">{
6115 &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;)),
6116 &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;)),
6117 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
6118 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
6119};
6120</pre></div></div>
6121</li>
6122<li>
6123
6124<p>The expected result is:</p>
6125
6126<div>
6127<div>
6128<pre class="source">{
6129 &quot;timebins&quot;: [
6130 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
6131 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
6132 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
6133 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
6134 ],
6135 &quot;datebins&quot;: [
6136 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
6137 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
6138 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
6139 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
6140 ],
6141 &quot;datetimebins&quot;: [
6142 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
6143 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
6144 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
6145 ]
6146};
6147</pre></div></div>
6148</li>
6149</ul><!--
6150 ! Licensed to the Apache Software Foundation (ASF) under one
6151 ! or more contributor license agreements. See the NOTICE file
6152 ! distributed with this work for additional information
6153 ! regarding copyright ownership. The ASF licenses this file
6154 ! to you under the Apache License, Version 2.0 (the
6155 ! "License"); you may not use this file except in compliance
6156 ! with the License. You may obtain a copy of the License at
6157 !
6158 ! http://www.apache.org/licenses/LICENSE-2.0
6159 !
6160 ! Unless required by applicable law or agreed to in writing,
6161 ! software distributed under the License is distributed on an
6162 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6163 ! KIND, either express or implied. See the License for the
6164 ! specific language governing permissions and limitations
6165 ! under the License.
6166 !-->
6167</div>
6168<div class="section">
6169<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
6170<ul>
6171
6172<li>
6173
6174<p>Syntax:</p>
6175
6176<div>
6177<div>
6178<pre class="source">interval_before(interval1, interval2)
6179interval_after(interval1, interval2)
6180</pre></div></div>
6181</li>
6182<li>
6183
6184<p>These two functions check whether an interval happens before/after another interval.</p>
6185</li>
6186<li>Arguments:
6187<ul>
6188
6189<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6190</ul>
6191</li>
6192<li>Return Value:
6193<ul>
6194
6195<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>
6196<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6197<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6198<li>any other non-interval input value will cause a type error.</li>
6199</ul>
6200</li>
6201<li>
6202
6203<p>Examples:</p>
6204
6205<div>
6206<div>
6207<pre class="source">{
6208 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6209 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6210 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6211 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6212};
6213</pre></div></div>
6214</li>
6215<li>
6216
6217<p>The expected result is:</p>
6218
6219<div>
6220<div>
6221<pre class="source">{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6222</pre></div></div>
6223</li>
6224</ul></div>
6225<div class="section">
6226<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6227<ul>
6228
6229<li>
6230
6231<p>Syntax:</p>
6232
6233<div>
6234<div>
6235<pre class="source">interval_covers(interval1, interval2)
6236interval_covered_by(interval1, interval2)
6237</pre></div></div>
6238</li>
6239<li>
6240
6241<p>These two functions check whether one interval covers the other interval.</p>
6242</li>
6243<li>Arguments:
6244<ul>
6245
6246<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6247</ul>
6248</li>
6249<li>Return Value:
6250<ul>
6251
6252<li>
6253
6254<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
6255<p>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end</p>
6256<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
6257<p>interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end</p>
6258</li>
6259<li>
6260
6261<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6262</li>
6263<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6264<li>any other non-interval input value will cause a type error.</li>
6265</ul>
6266</li>
6267<li>
6268
6269<p>Examples:</p>
6270
6271<div>
6272<div>
6273<pre class="source">{
6274 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6275 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6276 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6277 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6278};
6279</pre></div></div>
6280</li>
6281<li>
6282
6283<p>The expected result is:</p>
6284
6285<div>
6286<div>
6287<pre class="source">{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6288</pre></div></div>
6289</li>
6290</ul></div>
6291<div class="section">
6292<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6293<ul>
6294
6295<li>
6296
6297<p>Syntax:</p>
6298
6299<div>
6300<div>
6301<pre class="source">interval_overlaps(interval1, interval2)
6302interval_overlapped_by(interval1, interval2)
6303</pre></div></div>
6304</li>
6305<li>
6306
6307<p>These functions check whether two intervals overlap with each other.</p>
6308</li>
6309<li>Arguments:
6310<ul>
6311
6312<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6313</ul>
6314</li>
6315<li>Return Value:
6316<ul>
6317
6318<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
6319<p>interval1.start &lt; interval2.start AND interval2.end &gt; interval1.end AND interval1.end &gt; interval2.start</p></li>
6320</ul>
6321<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6322
6323<div>
6324<div>
6325<pre class="source">interval2.start &lt; interval1.start
6326AND interval1.end &gt; interval2.end
6327AND interval2.end &gt; interval1.start
6328</pre></div></div>
6329
6330<ul>
6331
6332<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6333<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6334<li>any other non-interval input value will cause a type error.</li>
6335</ul>
6336<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>
6337</li>
6338<li>
6339
6340<p>Examples:</p>
6341
6342<div>
6343<div>
6344<pre class="source">{
6345 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6346 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6347 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6348 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6349};
6350</pre></div></div>
6351</li>
6352<li>
6353
6354<p>The expected result is:</p>
6355
6356<div>
6357<div>
6358<pre class="source">{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6359</pre></div></div>
6360</li>
6361</ul></div>
6362<div class="section">
6363<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6364<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>
6365<ul>
6366
6367<li>
6368
6369<p>Syntax:</p>
6370
6371<div>
6372<div>
6373<pre class="source">interval_overlapping(interval1, interval2)
6374</pre></div></div>
6375</li>
6376<li>
6377
6378<p>This functions check whether two intervals share any points with each other.</p>
6379</li>
6380<li>Arguments:
6381<ul>
6382
6383<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6384</ul>
6385</li>
6386<li>Return Value:
6387<ul>
6388
6389<li>
6390
6391<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
6392<p>interval1.start &lt; interval2.end AND interval1.end &gt; interval2.start</p>
6393</li>
6394<li>
6395
6396<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6397</li>
6398<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6399<li>any other non-interval input value will cause a type error.</li>
6400</ul>
6401</li>
6402<li>
6403
6404<p>Examples:</p>
6405
6406<div>
6407<div>
6408<pre class="source">{
6409 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6410 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6411 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6412 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6413};
6414</pre></div></div>
6415</li>
6416<li>
6417
6418<p>The expected result is:</p>
6419
6420<div>
6421<div>
6422<pre class="source">{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6423</pre></div></div>
6424</li>
6425</ul></div>
6426<div class="section">
6427<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
6428<ul>
6429
6430<li>
6431
6432<p>Syntax:</p>
6433
6434<div>
6435<div>
6436<pre class="source">interval_meets(interval1, interval2)
6437interval_met_by(interval1, interval2)
6438</pre></div></div>
6439</li>
6440<li>
6441
6442<p>These two functions check whether an interval meets with another interval.</p>
6443</li>
6444<li>Arguments:
6445<ul>
6446
6447<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6448</ul>
6449</li>
6450<li>Return Value:
6451<ul>
6452
6453<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>
6454<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6455<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6456<li>any other non-interval input value will cause a type error.</li>
6457</ul>
6458</li>
6459<li>
6460
6461<p>Examples:</p>
6462
6463<div>
6464<div>
6465<pre class="source">{
6466 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6467 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6468 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6469 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6470};
6471</pre></div></div>
6472</li>
6473<li>
6474
6475<p>The expected result is:</p>
6476
6477<div>
6478<div>
6479<pre class="source">{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6480</pre></div></div>
6481</li>
6482</ul></div>
6483<div class="section">
6484<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
6485<ul>
6486
6487<li>
6488
6489<p>Syntax:</p>
6490
6491<div>
6492<div>
6493<pre class="source">interval_starts(interval1, interval2)
6494interval_started_by(interval1, interval2)
6495</pre></div></div>
6496</li>
6497<li>
6498
6499<p>These two functions check whether one interval starts with the other interval.</p>
6500</li>
6501<li>Arguments:
6502<ul>
6503
6504<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6505</ul>
6506</li>
6507<li>Return Value:
6508<ul>
6509
6510<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
6511<p>interval1.start = interval2.start AND interval1.end &lt;= interval2.end</p></li>
6512</ul>
6513<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6514
6515<div>
6516<div>
6517<pre class="source">interval1.start = interval2.start
6518AND interval2.end &lt;= interval1.end
6519</pre></div></div>
6520
6521<ul>
6522
6523<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6524<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6525<li>any other non-interval input value will cause a type error.</li>
6526</ul>
6527</li>
6528<li>
6529
6530<p>Examples:</p>
6531
6532<div>
6533<div>
6534<pre class="source">{
6535 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6536 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6537 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6538 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6539};
6540</pre></div></div>
6541</li>
6542<li>
6543
6544<p>The expected result is:</p>
6545
6546<div>
6547<div>
6548<pre class="source">{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6549</pre></div></div>
6550</li>
6551</ul></div>
6552<div class="section">
6553<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6554<ul>
6555
6556<li>
6557
6558<p>Syntax:</p>
6559
6560<div>
6561<div>
6562<pre class="source">interval_ends(interval1, interval2)
6563interval_ended_by(interval1, interval2)
6564</pre></div></div>
6565</li>
6566<li>
6567
6568<p>These two functions check whether one interval ends with the other interval.</p>
6569</li>
6570<li>Arguments:
6571<ul>
6572
6573<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6574</ul>
6575</li>
6576<li>Return Value:
6577<ul>
6578
6579<li>
6580
6581<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
6582<p>interval1.end = interval2.end AND interval1.start &gt;= interval2.start</p>
6583<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
6584<p>interval2.end = interval1.end AND interval2.start &gt;= interval1.start</p>
6585</li>
6586<li>
6587
6588<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6589</li>
6590<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6591<li>any other non-interval input value will cause a type error.</li>
6592</ul>
6593</li>
6594<li>
6595
6596<p>Examples:</p>
6597
6598<div>
6599<div>
6600<pre class="source">{
6601 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6602 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6603 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6604 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6605};
6606</pre></div></div>
6607</li>
6608<li>
6609
6610<p>The expected result is:</p>
6611
6612<div>
6613<div>
6614<pre class="source">{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6615</pre></div></div>
6616</li>
6617</ul><!--
6618 ! Licensed to the Apache Software Foundation (ASF) under one
6619 ! or more contributor license agreements. See the NOTICE file
6620 ! distributed with this work for additional information
6621 ! regarding copyright ownership. The ASF licenses this file
6622 ! to you under the Apache License, Version 2.0 (the
6623 ! "License"); you may not use this file except in compliance
6624 ! with the License. You may obtain a copy of the License at
6625 !
6626 ! http://www.apache.org/licenses/LICENSE-2.0
6627 !
6628 ! Unless required by applicable law or agreed to in writing,
6629 ! software distributed under the License is distributed on an
6630 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6631 ! KIND, either express or implied. See the License for the
6632 ! specific language governing permissions and limitations
6633 ! under the License.
6634 !-->
6635</div></div>
6636<div class="section">
6637<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6638<div class="section">
6639<h3><a name="get_object_fields"></a>get_object_fields</h3>
6640<ul>
6641
6642<li>
6643
6644<p>Syntax:</p>
6645
6646<div>
6647<div>
6648<pre class="source">get_object_fields(input_object)
6649</pre></div></div>
6650</li>
6651<li>
6652
6653<p>Access the object field names, type and open status for a given object.</p>
6654</li>
6655<li>Arguments:
6656<ul>
6657
6658<li><tt>input_object</tt> : a object value.</li>
6659</ul>
6660</li>
6661<li>Return Value:
6662<ul>
6663
6664<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>
6665<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6666<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6667<li>any other non-object input value will cause a type error.</li>
6668</ul>
6669</li>
6670<li>
6671
6672<p>Example:</p>
6673
6674<div>
6675<div>
6676<pre class="source">get_object_fields(
6677 {
6678 &quot;id&quot;: 1,
6679 &quot;project&quot;: &quot;AsterixDB&quot;,
6680 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6681 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6682 }
6683 );
6684</pre></div></div>
6685</li>
6686<li>
6687
6688<p>The expected result is:</p>
6689
6690<div>
6691<div>
6692<pre class="source">[
6693 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6694 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6695 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6696 &quot;nested&quot;: [
6697 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6698 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6699 ]
6700 },
6701 { &quot;field-name&quot;:
6702 &quot;related&quot;,
6703 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6704 &quot;is-open&quot;: false,
6705 &quot;list&quot;: [
6706 { &quot;field-type&quot;: &quot;STRING&quot; },
6707 { &quot;field-type&quot;: &quot;STRING&quot; },
6708 { &quot;field-type&quot;: &quot;STRING&quot; }
6709 ]
6710 }
6711]
6712</pre></div></div>
6713</li>
6714</ul>
6715<p>]</p></div>
6716<div class="section">
6717<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6718<ul>
6719
6720<li>
6721
6722<p>Syntax:</p>
6723
6724<div>
6725<div>
6726<pre class="source">get_object_field_value(input_object, string)
6727</pre></div></div>
6728</li>
6729<li>
6730
6731<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
6732</li>
6733<li>Arguments:
6734<ul>
6735
6736<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6737<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6738</ul>
6739</li>
6740<li>Return Value:
6741<ul>
6742
6743<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6744<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6745<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6746<li>a type error will be raised if:
6747<ul>
6748
6749<li>the first argument is any other non-object value,</li>
6750<li>or, the second argument is any other non-string value.</li>
6751</ul>
6752</li>
6753</ul>
6754</li>
6755<li>
6756
6757<p>Example:</p>
6758
6759<div>
6760<div>
6761<pre class="source">get_object_field_value({
6762 &quot;id&quot;: 1,
6763 &quot;project&quot;: &quot;AsterixDB&quot;,
6764 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6765 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6766 },
6767 &quot;project&quot;
6768 );
6769</pre></div></div>
6770</li>
6771<li>
6772
6773<p>The expected result is:</p>
6774
6775<div>
6776<div>
6777<pre class="source">&quot;AsterixDB&quot;
6778</pre></div></div>
6779</li>
6780</ul></div>
6781<div class="section">
6782<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6783<ul>
6784
6785<li>
6786
6787<p>Syntax:</p>
6788
6789<div>
6790<div>
6791<pre class="source">object_remove_fields(input_object, field_names)
6792</pre></div></div>
6793</li>
6794<li>
6795
6796<p>Remove indicated fields from a object given a list of field names.</p>
6797</li>
6798<li>Arguments:
6799<ul>
6800
6801<li><tt>input_object</tt>: a object value.</li>
6802<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6803</ul>
6804</li>
6805<li>
6806
6807<p>Return Value:</p>
6808<ul>
6809
6810<li>a new object value without the fields listed in the second argument,</li>
6811<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6812<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6813<li>a type error will be raised if:
6814<ul>
6815
6816<li>the first argument is any other non-object value,</li>
6817<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6818</ul>
6819</li>
6820</ul>
6821</li>
6822<li>
6823
6824<p>Example:</p>
6825
6826<div>
6827<div>
6828<pre class="source">object_remove_fields(
6829 {
6830 &quot;id&quot;:1,
6831 &quot;project&quot;:&quot;AsterixDB&quot;,
6832 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6833 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6834 },
6835 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6836 );
6837</pre></div></div>
6838</li>
6839<li>
6840
6841<p>The expected result is:</p>
6842
6843<div>
6844<div>
6845<pre class="source">{
6846 &quot;id&quot;:1,
6847 &quot;project&quot;:&quot;AsterixDB&quot;,
6848 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6849}
6850</pre></div></div>
6851</li>
6852</ul></div>
6853<div class="section">
6854<h3><a name="object_add_fields"></a>object_add_fields</h3>
6855<ul>
6856
6857<li>
6858
6859<p>Syntax:</p>
6860
6861<div>
6862<div>
6863<pre class="source">object_add_fields(input_object, fields)
6864</pre></div></div>
6865</li>
6866<li>
6867
6868<p>Add fields to a object given a list of field names.</p>
6869</li>
6870<li>Arguments:
6871<ul>
6872
6873<li><tt>input_object</tt> : a object value.</li>
6874<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6875</ul>
6876</li>
6877<li>Return Value:
6878<ul>
6879
6880<li>a new object value with the new fields included,</li>
6881<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6882<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6883<li>a type error will be raised if:
6884<ul>
6885
6886<li>the first argument is any other non-object value,</li>
6887<li>the second argument is any other non-array value, or contains non-object items.</li>
6888</ul>
6889</li>
6890</ul>
6891</li>
6892<li>
6893
6894<p>Example:</p>
6895
6896<div>
6897<div>
6898<pre class="source">object_add_fields(
6899 {
6900 &quot;id&quot;:1,
6901 &quot;project&quot;:&quot;AsterixDB&quot;,
6902 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6903 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6904 },
6905 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6906 );
6907</pre></div></div>
6908</li>
6909<li>
6910
6911<p>The expected result is:</p>
6912
6913<div>
6914<div>
6915<pre class="source">{
6916 &quot;id&quot;:1,
6917 &quot;project&quot;:&quot;AsterixDB&quot;,
6918 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6919 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6920 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6921 }
6922</pre></div></div>
6923</li>
6924</ul></div>
6925<div class="section">
6926<h3><a name="object_merge"></a>object_merge</h3>
6927<ul>
6928
6929<li>
6930
6931<p>Syntax:</p>
6932
6933<div>
6934<div>
6935<pre class="source">object_merge(object1, object2)
6936</pre></div></div>
6937</li>
6938<li>
6939
6940<p>Merge two different objects into a new object.</p>
6941</li>
6942<li>Arguments:
6943<ul>
6944
6945<li><tt>object1</tt> : a object value.</li>
6946<li><tt>object2</tt> : a object value.</li>
6947</ul>
6948</li>
6949<li>Return Value:
6950<ul>
6951
6952<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>
6953<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6954<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6955<li>any other non-object input value will cause a type error.</li>
6956</ul>
6957</li>
6958<li>
6959
6960<p>Example:</p>
6961
6962<div>
6963<div>
6964<pre class="source">object_merge(
6965 {
6966 &quot;id&quot;:1,
6967 &quot;project&quot;:&quot;AsterixDB&quot;,
6968 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6969 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6970 },
6971 {
6972 &quot;user_id&quot;: 22,
6973 &quot;employer&quot;: &quot;UC Irvine&quot;,
6974 &quot;employment_type&quot;: &quot;visitor&quot;
6975 }
6976 );
6977</pre></div></div>
6978</li>
6979<li>
6980
6981<p>The expected result is:</p>
6982
6983<div>
6984<div>
6985<pre class="source">{
6986 &quot;employment_type&quot;: &quot;visitor&quot;,
6987 &quot;address&quot;: {
6988 &quot;city&quot;: &quot;Irvine&quot;,
6989 &quot;state&quot;: &quot;CA&quot;
6990 },
6991 &quot;related&quot;: [
6992 &quot;Hivestrix&quot;,
6993 &quot;Preglix&quot;,
6994 &quot;Apache VXQuery&quot;
6995 ],
6996 &quot;user_id&quot;: 22,
6997 &quot;project&quot;: &quot;AsterixDB&quot;,
6998 &quot;employer&quot;: &quot;UC Irvine&quot;,
6999 &quot;id&quot;: 1
7000}
7001</pre></div></div>
7002</li>
7003</ul></div>
7004<div class="section">
7005<h3><a name="object_length"></a>object_length</h3>
7006<ul>
7007
7008<li>
7009
7010<p>Syntax:</p>
7011
7012<div>
7013<div>
7014<pre class="source">object_length(input_object)
7015</pre></div></div>
7016</li>
7017<li>
7018
7019<p>Returns number of top-level fields in the given object</p>
7020</li>
7021<li>Arguments:
7022<ul>
7023
7024<li><tt>input_object</tt> : an object value.</li>
7025</ul>
7026</li>
7027<li>Return Value:
7028<ul>
7029
7030<li>an integer that represents the number of top-level fields in the given object,</li>
7031<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7032<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7033</ul>
7034</li>
7035<li>
7036
7037<p>Example:</p>
7038
7039<div>
7040<div>
7041<pre class="source">object_length(
7042 {
7043 &quot;id&quot;: 1,
7044 &quot;project&quot;: &quot;AsterixDB&quot;,
7045 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7046 }
7047 );
7048</pre></div></div>
7049</li>
7050<li>
7051
7052<p>The expected result is:</p>
7053
7054<div>
7055<div>
7056<pre class="source">3
7057</pre></div></div>
7058</li>
7059</ul></div>
7060<div class="section">
7061<h3><a name="object_names"></a>object_names</h3>
7062<ul>
7063
7064<li>
7065
7066<p>Syntax:</p>
7067
7068<div>
7069<div>
7070<pre class="source">object_names(input_object)
7071</pre></div></div>
7072</li>
7073<li>
7074
7075<p>Returns names of top-level fields in the given object</p>
7076</li>
7077<li>Arguments:
7078<ul>
7079
7080<li><tt>input_object</tt> : an object value.</li>
7081</ul>
7082</li>
7083<li>Return Value:
7084<ul>
7085
7086<li>an array with top-level field names of the given object,</li>
7087<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7088<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7089</ul>
7090</li>
7091<li>
7092
7093<p>Example:</p>
7094
7095<div>
7096<div>
7097<pre class="source">object_names(
7098 {
7099 &quot;id&quot;: 1,
7100 &quot;project&quot;: &quot;AsterixDB&quot;,
7101 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7102 }
7103 );
7104</pre></div></div>
7105</li>
7106<li>
7107
7108<p>The expected result is:</p>
7109
7110<div>
7111<div>
7112<pre class="source">[ &quot;id&quot;, &quot;project&quot;, &quot;address&quot; ]
7113</pre></div></div>
7114</li>
7115</ul></div>
7116<div class="section">
7117<h3><a name="object_remove"></a>object_remove</h3>
7118<ul>
7119
7120<li>
7121
7122<p>Syntax:</p>
7123
7124<div>
7125<div>
7126<pre class="source">object_remove(input_object, field_name)
7127</pre></div></div>
7128</li>
7129<li>
7130
7131<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
7132</li>
7133<li>Arguments:
7134<ul>
7135
7136<li><tt>input_object</tt> : an object value.</li>
7137<li><tt>field_name</tt> : a string field name.</li>
7138</ul>
7139</li>
7140<li>Return Value:
7141<ul>
7142
7143<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
7144<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
7145<li><tt>null</tt> if the argument <tt>input_object</tt> is <tt>null</tt> or any other non-object value, or the argument <tt>field_name</tt> is <tt>null</tt> or any other non-string value.</li>
7146</ul>
7147</li>
7148<li>
7149
7150<p>Example:</p>
7151
7152<div>
7153<div>
7154<pre class="source">object_remove(
7155 {
7156 &quot;id&quot;: 1,
7157 &quot;project&quot;: &quot;AsterixDB&quot;,
7158 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7159 }
7160 , &quot;address&quot;
7161 );
7162</pre></div></div>
7163</li>
7164<li>
7165
7166<p>The expected result is:</p>
7167
7168<div>
7169<div>
7170<pre class="source">{
7171 &quot;id&quot;: 1,
7172 &quot;project&quot;: &quot;AsterixDB&quot;,
7173}
7174</pre></div></div>
7175</li>
7176</ul></div>
7177<div class="section">
7178<h3><a name="object_rename"></a>object_rename</h3>
7179<ul>
7180
7181<li>
7182
7183<p>Syntax:</p>
7184
7185<div>
7186<div>
7187<pre class="source">object_rename(input_object, old_field, new_field)
7188</pre></div></div>
7189</li>
7190<li>
7191
7192<p>Returns a new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt></p>
7193</li>
7194<li>Arguments:
7195<ul>
7196
7197<li><tt>input_object</tt> : an object value.</li>
7198<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
7199<li><tt>new_field</tt> : a string representing the new field name to replace <tt>old_field</tt> inside the object <tt>input_object</tt>.</li>
7200</ul>
7201</li>
7202<li>Return Value:
7203<ul>
7204
7205<li>A new object that has the same fields as <tt>input_object</tt> with field <tt>old_field</tt> replaced by <tt>new_field</tt>,</li>
7206<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7207<li><tt>null</tt> if any argument is <tt>null</tt> or <tt>input_object</tt> is non-object value, or <tt>old_field</tt> is non-string value, or <tt>new_field</tt> is any non-string value.</li>
7208</ul>
7209</li>
7210<li>
7211
7212<p>Example:</p>
7213
7214<div>
7215<div>
7216<pre class="source">object_rename(
7217 {
7218 &quot;id&quot;: 1,
7219 &quot;project&quot;: &quot;AsterixDB&quot;,
7220 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7221 }
7222 , &quot;address&quot;
7223 , &quot;location&quot;
7224 );
7225</pre></div></div>
7226</li>
7227<li>
7228
7229<p>The expected result is:</p>
7230
7231<div>
7232<div>
7233<pre class="source">{
7234 &quot;id&quot;: 1,
7235 &quot;project&quot;: &quot;AsterixDB&quot;,
7236 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7237}
7238</pre></div></div>
7239</li>
7240</ul></div>
7241<div class="section">
7242<h3><a name="object_unwrap"></a>object_unwrap</h3>
7243<ul>
7244
7245<li>
7246
7247<p>Syntax:</p>
7248
7249<div>
7250<div>
7251<pre class="source">object_unwrap(input_object)
7252</pre></div></div>
7253</li>
7254<li>
7255
7256<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
7257</li>
7258<li>Arguments:
7259<ul>
7260
7261<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
7262</ul>
7263</li>
7264<li>Return Value:
7265<ul>
7266
7267<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
7268<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7269<li><tt>null</tt> if <tt>input_object</tt> is null, or an empty object, or there is more than one name-value pair in <tt>input_object</tt>, or any non-object value.</li>
7270</ul>
7271</li>
7272<li>
7273
7274<p>Example:</p>
7275
7276<div>
7277<div>
7278<pre class="source">object_unwrap(
7279 {
7280 &quot;id&quot;: 1
7281 }
7282 );
7283</pre></div></div>
7284</li>
7285<li>
7286
7287<p>The expected result is:</p>
7288
7289<div>
7290<div>
7291<pre class="source">{
7292 1
7293}
7294</pre></div></div>
7295</li>
7296</ul></div>
7297<div class="section">
7298<h3><a name="object_replace"></a>object_replace</h3>
7299<ul>
7300
7301<li>
7302
7303<p>Syntax:</p>
7304
7305<div>
7306<div>
7307<pre class="source">object_replace(input_object, old_value, new_value)
7308</pre></div></div>
7309</li>
7310<li>
7311
7312<p>Returns a new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt></p>
7313</li>
7314<li>Arguments:
7315<ul>
7316
7317<li><tt>input_object</tt> : an object value.</li>
7318<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
7319<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
7320</ul>
7321</li>
7322<li>Return Value:
7323<ul>
7324
7325<li>A new object that has the same fields as <tt>input_object</tt> with all occurrences of value <tt>old_value</tt> replaced by <tt>new_value</tt>,</li>
7326<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7327<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
7328<li>a type error will be raised if:
7329<ul>
7330
7331<li><tt>old_value</tt> is not a primitive type value.</li>
7332</ul>
7333</li>
7334</ul>
7335</li>
7336<li>
7337
7338<p>Example:</p>
7339
7340<div>
7341<div>
7342<pre class="source">object_replace(
7343 {
7344 &quot;id&quot;: 1,
7345 &quot;project&quot;: &quot;AsterixDB&quot;,
7346 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7347 }
7348 , &quot;AsterixDB&quot;
7349 , &quot;Apache AsterixDB&quot;
7350 );
7351</pre></div></div>
7352</li>
7353<li>
7354
7355<p>The expected result is:</p>
7356
7357<div>
7358<div>
7359<pre class="source">{
7360 &quot;id&quot;: 1,
7361 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7362 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7363}
7364</pre></div></div>
7365</li>
7366</ul></div>
7367<div class="section">
7368<h3><a name="object_add"></a>object_add</h3>
7369<ul>
7370
7371<li>
7372
7373<p>Syntax:</p>
7374
7375<div>
7376<div>
7377<pre class="source">object_add(input_object, field_name, field_value)
7378</pre></div></div>
7379</li>
7380<li>
7381
7382<p>Returns a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>.</p>
7383</li>
7384<li>Arguments:
7385<ul>
7386
7387<li><tt>input_object</tt> : an object value.</li>
7388<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7389<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7390</ul>
7391</li>
7392<li>Return Value:
7393<ul>
7394
7395<li>A new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>,</li>
7396<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7397<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not a string,</li>
7398<li><tt>input_object</tt> if <tt>field_name</tt>already exists in <tt>input_object</tt> or <tt>field_value</tt> is missing.</li>
7399</ul>
7400</li>
7401<li>
7402
7403<p>Example:</p>
7404
7405<div>
7406<div>
7407<pre class="source">object_add(
7408 {
7409 &quot;id&quot;: 1,
7410 &quot;project&quot;: &quot;AsterixDB&quot;,
7411 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7412 }
7413 , &quot;company&quot;
7414 , &quot;Apache&quot;
7415 );
7416</pre></div></div>
7417</li>
7418<li>
7419
7420<p>The expected result is:</p>
7421
7422<div>
7423<div>
7424<pre class="source">{
7425 &quot;id&quot;: 1,
7426 &quot;project&quot;: &quot;AsterixDB&quot;,
7427 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7428 &quot;company&quot;: &quot;Apache&quot;
7429}
7430</pre></div></div>
7431</li>
7432</ul></div>
7433<div class="section">
7434<h3><a name="object_put"></a>object_put</h3>
7435<ul>
7436
7437<li>
7438
7439<p>Syntax:</p>
7440
7441<div>
7442<div>
7443<pre class="source">object_put(input_object, field_name, field_value)
7444</pre></div></div>
7445</li>
7446<li>
7447
7448<p>Adds, modifies, or removes a field of an object.</p>
7449</li>
7450<li>Arguments:
7451<ul>
7452
7453<li><tt>input_object</tt> : an object value.</li>
7454<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7455<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7456</ul>
7457</li>
7458<li>Return Value:
7459<ul>
7460
7461<li>a new object that has the same fields as <tt>input_object</tt> as well as the new field <tt>field_name</tt>, or with updated <tt>field_name</tt> value to <tt>field_value</tt> if <tt>field_name</tt> already exists in <tt>input_object</tt>, or with <tt>field_name</tt>removed if <tt>field_name</tt> already exists in <tt>input_object</tt> and <tt>field_value</tt> is <tt>missing</tt>,</li>
7462<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7463<li><tt>null</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>null</tt>, or <tt>input_object</tt> is not an object, or <tt>field_name</tt> is not not a string.</li>
7464</ul>
7465</li>
7466<li>
7467
7468<p>Example:</p>
7469
7470<div>
7471<div>
7472<pre class="source">object_put(
7473 {
7474 &quot;id&quot;: 1,
7475 &quot;project&quot;: &quot;AsterixDB&quot;,
7476 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7477 }
7478 , &quot;project&quot;
7479 , &quot;Apache AsterixDB&quot;
7480 );
7481</pre></div></div>
7482</li>
7483<li>
7484
7485<p>The expected result is:</p>
7486
7487<div>
7488<div>
7489<pre class="source">{
7490 &quot;id&quot;: 1,
7491 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7492 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7493}
7494</pre></div></div>
7495</li>
7496</ul></div>
7497<div class="section">
7498<h3><a name="object_values"></a>object_values</h3>
7499<ul>
7500
7501<li>
7502
7503<p>Syntax:</p>
7504
7505<div>
7506<div>
7507<pre class="source">object_values(input_object)
7508</pre></div></div>
7509</li>
7510<li>
7511
7512<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
7513</li>
7514<li>Arguments:
7515<ul>
7516
7517<li><tt>input_object</tt> : an object value.</li>
7518</ul>
7519</li>
7520<li>Return Value:
7521<ul>
7522
7523<li>An array of the values of the fields in <tt>input_object</tt>,</li>
7524<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7525<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7526</ul>
7527</li>
7528<li>
7529
7530<p>Example:</p>
7531
7532<div>
7533<div>
7534<pre class="source">object_values(
7535 {
7536 &quot;id&quot;: 1,
7537 &quot;project&quot;: &quot;AsterixDB&quot;,
7538 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7539 }
7540 );
7541</pre></div></div>
7542</li>
7543<li>
7544
7545<p>The expected result is:</p>
7546
7547<div>
7548<div>
7549<pre class="source">[
7550 1,
7551 &quot;AsterixDB&quot;,
7552 {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7553]
7554</pre></div></div>
7555</li>
7556</ul></div>
7557<div class="section">
7558<h3><a name="object_pairs"></a>object_pairs</h3>
7559<ul>
7560
7561<li>
7562
7563<p>Syntax:</p>
7564
7565<div>
7566<div>
7567<pre class="source">object_pairs(input_object)
7568</pre></div></div>
7569</li>
7570<li>
7571
7572<p>Returns an array of objects describing fields of <tt>input_object</tt>. For each field of the <tt>input_object</tt> the returned array contains an object with two fields <tt>name</tt> and <tt>value</tt> which are set to the <tt>input_object</tt>&#x2019;s field name and value.</p>
7573</li>
7574<li>
7575
7576<p>Arguments:</p>
7577<ul>
7578
7579<li><tt>input_object</tt> : an object value.</li>
7580</ul>
7581</li>
7582<li>Return Value:
7583<ul>
7584
7585<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
7586<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7587<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7588</ul>
7589</li>
7590<li>
7591
7592<p>Example:</p>
7593
7594<div>
7595<div>
7596<pre class="source">object_pairs(
7597 {
7598 &quot;id&quot;: 1,
7599 &quot;project&quot;: &quot;AsterixDB&quot;,
7600 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7601 }
7602 );
7603</pre></div></div>
7604</li>
7605<li>
7606
7607<p>The expected result is:</p>
7608
7609<div>
7610<div>
7611<pre class="source">[
7612 { &quot;name&quot;: &quot;id&quot;, &quot;value&quot;: 1 },
7613 { &quot;name&quot;: &quot;project&quot;, &quot;value&quot;: &quot;AsterixDB&quot; },
7614 { &quot;name&quot;: &quot;address&quot;, &quot;value&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;} }
7615]
7616</pre></div></div>
7617</li>
7618</ul></div>
7619<div class="section">
7620<h3><a name="pairs"></a>pairs</h3>
7621<ul>
7622
7623<li>
7624
7625<p>Syntax:</p>
7626
7627<div>
7628<div>
7629<pre class="source">pairs(input_object)
7630</pre></div></div>
7631</li>
7632<li>
7633
7634<p>Returns an array of arrays describing fields of <tt>input_object</tt>, including nested fields. For each field of the <tt>input_object</tt> the returned array contains an array with two elements. The first element is the name and the second one is the value of the <tt>input_object</tt>&#x2019;s field. The input object is introspected recursively, so all fields of its nested objects are returned. Nested objects contained in arrays and multisets are also processed by this function.</p>
7635</li>
7636<li>
7637
7638<p>Arguments:</p>
7639<ul>
7640
7641<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
7642</ul>
7643</li>
7644<li>Return Value:
7645<ul>
7646
7647<li>An array of arrays with name, value pairs of the fields in <tt>input_object</tt>, including nested fields. Each inner array has exactly two items: name and value of the <tt>input_object</tt>&#x2019;s field.</li>
7648<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7649<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
7650</ul>
7651</li>
7652<li>
7653
7654<p>Example:</p>
7655
7656<div>
7657<div>
7658<pre class="source">pairs(
7659 {
7660 &quot;id&quot;: 1,
7661 &quot;project&quot;: &quot;AsterixDB&quot;,
7662 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7663 }
7664 );
7665</pre></div></div>
7666</li>
7667<li>
7668
7669<p>The expected result is:</p>
7670
7671<div>
7672<div>
7673<pre class="source">[
7674 [ &quot;id&quot;, 1 ],
7675 [ &quot;project&quot;, &quot;AsterixDB&quot; ],
7676 [ &quot;address&quot;, { &quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot; } ],
7677 [ &quot;city&quot;, &quot;Irvine&quot; ],
7678 [ &quot;state&quot;, &quot;CA&quot; ]
7679]
7680</pre></div></div>
7681</li>
7682</ul><!--
7683 ! Licensed to the Apache Software Foundation (ASF) under one
7684 ! or more contributor license agreements. See the NOTICE file
7685 ! distributed with this work for additional information
7686 ! regarding copyright ownership. The ASF licenses this file
7687 ! to you under the Apache License, Version 2.0 (the
7688 ! "License"); you may not use this file except in compliance
7689 ! with the License. You may obtain a copy of the License at
7690 !
7691 ! http://www.apache.org/licenses/LICENSE-2.0
7692 !
7693 ! Unless required by applicable law or agreed to in writing,
7694 ! software distributed under the License is distributed on an
7695 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7696 ! KIND, either express or implied. See the License for the
7697 ! specific language governing permissions and limitations
7698 ! under the License.
7699 !-->
7700</div></div>
7701<div class="section">
7702<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
7703<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
7704<p>The query language also supports standard SQL aggregate functions (e.g., <tt>MIN</tt>, <tt>MAX</tt>, <tt>SUM</tt>, <tt>COUNT</tt>, and <tt>AVG</tt>). Note that these are not real functions in the query language, but just syntactic sugars over corresponding 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>). Refer to <a href="manual.html#Aggregation_PseudoFunctions">Aggregation Pseudo-Functions</a> for details.</p>
7705<p>The <tt>DISTINCT</tt> keyword may be used with built-in aggregate functions and standard SQL aggregate functions. It may also be used with aggregate functions used as window functions. It determines whether the function aggregates all values in the group, or distinct values only. Refer to <a href="manual.html#Function_call_expressions">Function Calls</a> for details.</p>
7706<p>Aggregate functions may be used as window functions when they are used with an OVER clause. Refer to <a href="manual.html#Over_clauses">OVER Clauses</a> for details.</p>
7707<div class="section">
7708<h3><a name="array_count"></a>array_count</h3>
7709<ul>
7710
7711<li>
7712
7713<p>Syntax:</p>
7714
7715<div>
7716<div>
7717<pre class="source">array_count(collection)
7718</pre></div></div>
7719</li>
7720<li>
7721
7722<p>Gets the number of non-null and non-missing items in the given collection.</p>
7723</li>
7724<li>Arguments:
7725<ul>
7726
7727<li><tt>collection</tt> could be:
7728<ul>
7729
7730<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
7731<li>or, a <tt>null</tt> value,</li>
7732<li>or, a <tt>missing</tt> value.</li>
7733</ul>
7734</li>
7735</ul>
7736</li>
7737<li>Return Value:
7738<ul>
7739
7740<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
7741<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7742<li>any other non-array and non-multiset input value will cause an error.</li>
7743</ul>
7744</li>
7745<li>
7746
7747<p>Example:</p>
7748
7749<div>
7750<div>
7751<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
7752</pre></div></div>
7753</li>
7754<li>
7755
7756<p>The expected result is:</p>
7757
7758<div>
7759<div>
7760<pre class="source">5
7761</pre></div></div>
7762</li>
7763</ul></div>
7764<div class="section">
7765<h3><a name="array_avg"></a>array_avg</h3>
7766<ul>
7767
7768<li>
7769
7770<p>Syntax:</p>
7771
7772<div>
7773<div>
7774<pre class="source">array_avg(num_collection)
7775</pre></div></div>
7776</li>
7777<li>
7778
7779<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
7780</li>
7781<li>Arguments:
7782<ul>
7783
7784<li><tt>num_collection</tt> could be:
7785<ul>
7786
7787<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7788<li>or, a <tt>null</tt> value,</li>
7789<li>or, a <tt>missing</tt> value.</li>
7790</ul>
7791</li>
7792</ul>
7793</li>
7794<li>Return Value:
7795<ul>
7796
7797<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
7798<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7799<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7800<li>any other non-array and non-multiset input value will cause a type error,</li>
7801<li>any other non-numeric value in the input collection will cause a type error.</li>
7802</ul>
7803</li>
7804<li>
7805
7806<p>Example:</p>
7807
7808<div>
7809<div>
7810<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
7811</pre></div></div>
7812</li>
7813<li>
7814
7815<p>The expected result is:</p>
7816
7817<div>
7818<div>
7819<pre class="source">1.725
7820</pre></div></div>
7821</li>
7822</ul></div>
7823<div class="section">
7824<h3><a name="array_sum"></a>array_sum</h3>
7825<ul>
7826
7827<li>
7828
7829<p>Syntax:</p>
7830
7831<div>
7832<div>
7833<pre class="source">array_sum(num_collection)
7834</pre></div></div>
7835</li>
7836<li>
7837
7838<p>Gets the sum of non-null and non-missing items in the given collection.</p>
7839</li>
7840<li>Arguments:
7841<ul>
7842
7843<li><tt>num_collection</tt> could be:
7844<ul>
7845
7846<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7847<li>or, a <tt>null</tt> value,</li>
7848<li>or, a <tt>missing</tt> value.</li>
7849</ul>
7850</li>
7851</ul>
7852</li>
7853<li>Return Value:
7854<ul>
7855
7856<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>
7857<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7858<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7859<li>any other non-array and non-multiset input value will cause a type error,</li>
7860<li>any other non-numeric value in the input collection will cause a type error.</li>
7861</ul>
7862</li>
7863<li>
7864
7865<p>Example:</p>
7866
7867<div>
7868<div>
7869<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
7870</pre></div></div>
7871</li>
7872<li>
7873
7874<p>The expected result is:</p>
7875
7876<div>
7877<div>
7878<pre class="source">6.9
7879</pre></div></div>
7880</li>
7881</ul></div>
7882<div class="section">
7883<h3><a name="array_min"></a>array_min</h3>
7884<ul>
7885
7886<li>
7887
7888<p>Syntax:</p>
7889
7890<div>
7891<div>
7892<pre class="source">array_min(num_collection)
7893</pre></div></div>
7894</li>
7895<li>
7896
7897<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
7898</li>
7899<li>Arguments:
7900<ul>
7901
7902<li><tt>num_collection</tt> could be:
7903<ul>
7904
7905<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7906<li>or, a <tt>null</tt> value,</li>
7907<li>or, a <tt>missing</tt> value.</li>
7908</ul>
7909</li>
7910</ul>
7911</li>
7912<li>Return Value:
7913<ul>
7914
7915<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>
7916<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7917<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7918<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7919<li>any other non-array and non-multiset input value will cause a type error.</li>
7920</ul>
7921</li>
7922<li>
7923
7924<p>Example:</p>
7925
7926<div>
7927<div>
7928<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
7929</pre></div></div>
7930</li>
7931<li>
7932
7933<p>The expected result is:</p>
7934
7935<div>
7936<div>
7937<pre class="source">0.0
7938</pre></div></div>
7939</li>
7940</ul></div>
7941<div class="section">
7942<h3><a name="array_max"></a>array_max</h3>
7943<ul>
7944
7945<li>
7946
7947<p>Syntax:</p>
7948
7949<div>
7950<div>
7951<pre class="source">array_max(num_collection)
7952</pre></div></div>
7953</li>
7954<li>
7955
7956<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
7957</li>
7958<li>Arguments:
7959<ul>
7960
7961<li><tt>num_collection</tt> could be:
7962<ul>
7963
7964<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7965<li>or, a <tt>null</tt> value,</li>
7966<li>or, a <tt>missing</tt> value.</li>
7967</ul>
7968</li>
7969</ul>
7970</li>
7971<li>Return Value:
7972<ul>
7973
7974<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>
7975<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7976<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7977<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7978<li>any other non-array and non-multiset input value will cause a type error.</li>
7979</ul>
7980</li>
7981<li>
7982
7983<p>Example:</p>
7984
7985<div>
7986<div>
7987<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
7988</pre></div></div>
7989</li>
7990<li>
7991
7992<p>The expected result is:</p>
7993
7994<div>
7995<div>
7996<pre class="source">3.4
7997</pre></div></div>
7998</li>
7999</ul></div>
8000<div class="section">
8001<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
8002<ul>
8003
8004<li>
8005
8006<p>Syntax:</p>
8007
8008<div>
8009<div>
8010<pre class="source">array_stddev_samp(num_collection)
8011</pre></div></div>
8012</li>
8013<li>
8014
8015<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8016</li>
8017<li>Arguments:
8018<ul>
8019
8020<li><tt>num_collection</tt> could be:
8021<ul>
8022
8023<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8024<li>or, a <tt>null</tt> value,</li>
8025<li>or, a <tt>missing</tt> value.</li>
8026</ul>
8027</li>
8028</ul>
8029</li>
8030<li>Return Value:
8031<ul>
8032
8033<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
8034<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8035<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8036<li>any other non-array and non-multiset input value will cause a type error,</li>
8037<li>any other non-numeric value in the input collection will cause a type error.</li>
8038</ul>
8039</li>
8040<li>
8041
8042<p>Example:</p>
8043
8044<div>
8045<div>
8046<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
8047</pre></div></div>
8048</li>
8049<li>
8050
8051<p>The expected result is:</p>
8052
8053<div>
8054<div>
8055<pre class="source">1.4591664287073858
8056</pre></div></div>
8057</li>
8058</ul></div>
8059<div class="section">
8060<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
8061<ul>
8062
8063<li>
8064
8065<p>Syntax:</p>
8066
8067<div>
8068<div>
8069<pre class="source">array_stddev_pop(num_collection)
8070</pre></div></div>
8071</li>
8072<li>
8073
8074<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8075</li>
8076<li>Arguments:
8077<ul>
8078
8079<li><tt>num_collection</tt> could be:
8080<ul>
8081
8082<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8083<li>or, a <tt>null</tt> value,</li>
8084<li>or, a <tt>missing</tt> value.</li>
8085</ul>
8086</li>
8087</ul>
8088</li>
8089<li>Return Value:
8090<ul>
8091
8092<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
8093<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8094<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8095<li>any other non-array and non-multiset input value will cause a type error,</li>
8096<li>any other non-numeric value in the input collection will cause a type error.</li>
8097</ul>
8098</li>
8099<li>
8100
8101<p>Example:</p>
8102
8103<div>
8104<div>
8105<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
8106</pre></div></div>
8107</li>
8108<li>
8109
8110<p>The expected result is:</p>
8111
8112<div>
8113<div>
8114<pre class="source">1.2636751956100112
8115</pre></div></div>
8116</li>
8117</ul></div>
8118<div class="section">
8119<h3><a name="array_var_samp"></a>array_var_samp</h3>
8120<ul>
8121
8122<li>
8123
8124<p>Syntax:</p>
8125
8126<div>
8127<div>
8128<pre class="source">array_var_samp(num_collection)
8129</pre></div></div>
8130</li>
8131<li>
8132
8133<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
8134</li>
8135<li>Arguments:
8136<ul>
8137
8138<li><tt>num_collection</tt> could be:
8139<ul>
8140
8141<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8142<li>or, a <tt>null</tt> value,</li>
8143<li>or, a <tt>missing</tt> value.</li>
8144</ul>
8145</li>
8146</ul>
8147</li>
8148<li>Return Value:
8149<ul>
8150
8151<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
8152<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8153<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8154<li>any other non-array and non-multiset input value will cause a type error,</li>
8155<li>any other non-numeric value in the input collection will cause a type error.</li>
8156</ul>
8157</li>
8158<li>
8159
8160<p>Example:</p>
8161
8162<div>
8163<div>
8164<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
8165</pre></div></div>
8166</li>
8167<li>
8168
8169<p>The expected result is:</p>
8170
8171<div>
8172<div>
8173<pre class="source">2.1291666666666664
8174</pre></div></div>
8175</li>
8176</ul></div>
8177<div class="section">
8178<h3><a name="array_var_pop"></a>array_var_pop</h3>
8179<ul>
8180
8181<li>
8182
8183<p>Syntax:</p>
8184
8185<div>
8186<div>
8187<pre class="source">array_var_pop(num_collection)
8188</pre></div></div>
8189</li>
8190<li>
8191
8192<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
8193</li>
8194<li>Arguments:
8195<ul>
8196
8197<li><tt>num_collection</tt> could be:
8198<ul>
8199
8200<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8201<li>or, a <tt>null</tt> value,</li>
8202<li>or, a <tt>missing</tt> value.</li>
8203</ul>
8204</li>
8205</ul>
8206</li>
8207<li>Return Value:
8208<ul>
8209
8210<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
8211<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8212<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8213<li>any other non-array and non-multiset input value will cause a type error,</li>
8214<li>any other non-numeric value in the input collection will cause a type error.</li>
8215</ul>
8216</li>
8217<li>
8218
8219<p>Example:</p>
8220
8221<div>
8222<div>
8223<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
8224</pre></div></div>
8225</li>
8226<li>
8227
8228<p>The expected result is:</p>
8229
8230<div>
8231<div>
8232<pre class="source">1.5968749999999998
8233</pre></div></div>
8234</li>
8235</ul></div>
8236<div class="section">
8237<h3><a name="array_skewness"></a>array_skewness</h3>
8238<ul>
8239
8240<li>
8241
8242<p>Syntax:</p>
8243
8244<div>
8245<div>
8246<pre class="source">array_skewness(num_collection)
8247</pre></div></div>
8248</li>
8249<li>
8250
8251<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
8252</li>
8253<li>Arguments:
8254<ul>
8255
8256<li><tt>num_collection</tt> could be:
8257<ul>
8258
8259<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8260<li>or, a <tt>null</tt> value,</li>
8261<li>or, a <tt>missing</tt> value.</li>
8262</ul>
8263</li>
8264</ul>
8265</li>
8266<li>Return Value:
8267<ul>
8268
8269<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
8270<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8271<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8272<li>any other non-array and non-multiset input value will cause a type error,</li>
8273<li>any other non-numeric value in the input collection will cause a type error.</li>
8274</ul>
8275</li>
8276<li>
8277
8278<p>Example:</p>
8279
8280<div>
8281<div>
8282<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
8283</pre></div></div>
8284</li>
8285<li>
8286
8287<p>The expected result is:</p>
8288
8289<div>
8290<div>
8291<pre class="source">-0.04808451539164242
8292</pre></div></div>
8293</li>
8294</ul></div>
8295<div class="section">
8296<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
8297<ul>
8298
8299<li>
8300
8301<p>Syntax:</p>
8302
8303<div>
8304<div>
8305<pre class="source">array_kurtosis(num_collection)
8306</pre></div></div>
8307</li>
8308<li>
8309
8310<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
8311</li>
8312<li>Arguments:
8313<ul>
8314
8315<li><tt>num_collection</tt> could be:
8316<ul>
8317
8318<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8319<li>or, a <tt>null</tt> value,</li>
8320<li>or, a <tt>missing</tt> value.</li>
8321</ul>
8322</li>
8323</ul>
8324</li>
8325<li>Return Value:
8326<ul>
8327
8328<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the non-null and non-missing numbers in the given collection,</li>
8329<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8330<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8331<li>any other non-array and non-multiset input value will cause a type error,</li>
8332<li>any other non-numeric value in the input collection will cause a type error.</li>
8333</ul>
8334</li>
8335<li>
8336
8337<p>Example:</p>
8338
8339<div>
8340<div>
8341<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
8342</pre></div></div>
8343</li>
8344<li>
8345
8346<p>The expected result is:</p>
8347
8348<div>
8349<div>
8350<pre class="source">-1.342049701096427
8351</pre></div></div>
8352</li>
8353</ul></div>
8354<div class="section">
8355<h3><a name="strict_count"></a>strict_count</h3>
8356<ul>
8357
8358<li>
8359
8360<p>Syntax:</p>
8361
8362<div>
8363<div>
8364<pre class="source">strict_count(collection)
8365</pre></div></div>
8366</li>
8367<li>
8368
8369<p>Gets the number of items in the given collection.</p>
8370</li>
8371<li>Arguments:
8372<ul>
8373
8374<li><tt>collection</tt> could be:
8375<ul>
8376
8377<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
8378<li>or a <tt>null</tt> value,</li>
8379<li>or a <tt>missing</tt> value.</li>
8380</ul>
8381</li>
8382</ul>
8383</li>
8384<li>Return Value:
8385<ul>
8386
8387<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
8388<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
8389</ul>
8390</li>
8391<li>
8392
8393<p>Example:</p>
8394
8395<div>
8396<div>
8397<pre class="source">strict_count( [1, 2, null, missing] );
8398</pre></div></div>
8399</li>
8400<li>
8401
8402<p>The expected result is:</p>
8403
8404<div>
8405<div>
8406<pre class="source">4
8407</pre></div></div>
8408</li>
8409</ul></div>
8410<div class="section">
8411<h3><a name="strict_avg"></a>strict_avg</h3>
8412<ul>
8413
8414<li>
8415
8416<p>Syntax:</p>
8417
8418<div>
8419<div>
8420<pre class="source">strict_avg(num_collection)
8421</pre></div></div>
8422</li>
8423<li>
8424
8425<p>Gets the average value of the numeric items in the given collection.</p>
8426</li>
8427<li>Arguments:
8428<ul>
8429
8430<li><tt>num_collection</tt> could be:
8431<ul>
8432
8433<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8434<li>or, a <tt>null</tt> value,</li>
8435<li>or, a <tt>missing</tt> value.</li>
8436</ul>
8437</li>
8438</ul>
8439</li>
8440<li>Return Value:
8441<ul>
8442
8443<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
8444<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8445<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8446<li>any other non-numeric value in the input collection will cause a type error.</li>
8447</ul>
8448</li>
8449<li>
8450
8451<p>Example:</p>
8452
8453<div>
8454<div>
8455<pre class="source">strict_avg( [100, 200, 300] );
8456</pre></div></div>
8457</li>
8458<li>
8459
8460<p>The expected result is:</p>
8461
8462<div>
8463<div>
8464<pre class="source">200.0
8465</pre></div></div>
8466</li>
8467</ul></div>
8468<div class="section">
8469<h3><a name="strict_sum"></a>strict_sum</h3>
8470<ul>
8471
8472<li>
8473
8474<p>Syntax:</p>
8475
8476<div>
8477<div>
8478<pre class="source">strict_sum(num_collection)
8479</pre></div></div>
8480</li>
8481<li>
8482
8483<p>Gets the sum of the items in the given collection.</p>
8484</li>
8485<li>Arguments:
8486<ul>
8487
8488<li><tt>num_collection</tt> could be:
8489<ul>
8490
8491<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8492<li>or, a <tt>null</tt> value,</li>
8493<li>or, a <tt>missing</tt> value.</li>
8494</ul>
8495</li>
8496</ul>
8497</li>
8498<li>Return Value:
8499<ul>
8500
8501<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>
8502<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8503<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8504<li>any other non-numeric value in the input collection will cause a type error.</li>
8505</ul>
8506</li>
8507<li>
8508
8509<p>Example:</p>
8510
8511<div>
8512<div>
8513<pre class="source">strict_sum( [100, 200, 300] );
8514</pre></div></div>
8515</li>
8516<li>
8517
8518<p>The expected result is:</p>
8519
8520<div>
8521<div>
8522<pre class="source">600
8523</pre></div></div>
8524</li>
8525</ul></div>
8526<div class="section">
8527<h3><a name="strict_min"></a>strict_min</h3>
8528<ul>
8529
8530<li>
8531
8532<p>Syntax:</p>
8533
8534<div>
8535<div>
8536<pre class="source">strict_min(num_collection)
8537</pre></div></div>
8538</li>
8539<li>
8540
8541<p>Gets the min value of comparable items in the given collection.</p>
8542</li>
8543<li>Arguments:
8544<ul>
8545
8546<li><tt>num_collection</tt> could be:
8547<ul>
8548
8549<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8550<li>or, a <tt>null</tt> value,</li>
8551<li>or, a <tt>missing</tt> value.</li>
8552</ul>
8553</li>
8554</ul>
8555</li>
8556<li>Return Value:
8557<ul>
8558
8559<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>
8560<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8561<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8562<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8563<li>any other non-array and non-multiset input value will cause a type error.</li>
8564</ul>
8565</li>
8566<li>
8567
8568<p>Example:</p>
8569
8570<div>
8571<div>
8572<pre class="source">strict_min( [10.2, 100, 5] );
8573</pre></div></div>
8574</li>
8575<li>
8576
8577<p>The expected result is:</p>
8578
8579<div>
8580<div>
8581<pre class="source">5.0
8582</pre></div></div>
8583</li>
8584</ul></div>
8585<div class="section">
8586<h3><a name="strict_max"></a>strict_max</h3>
8587<ul>
8588
8589<li>
8590
8591<p>Syntax:</p>
8592
8593<div>
8594<div>
8595<pre class="source">strict_max(num_collection)
8596</pre></div></div>
8597</li>
8598<li>
8599
8600<p>Gets the max value of numeric items in the given collection.</p>
8601</li>
8602<li>Arguments:
8603<ul>
8604
8605<li><tt>num_collection</tt> could be:
8606<ul>
8607
8608<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8609<li>or, a <tt>null</tt> value,</li>
8610<li>or, a <tt>missing</tt> value.</li>
8611</ul>
8612</li>
8613</ul>
8614</li>
8615<li>Return Value:
8616<ul>
8617
8618<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>
8619<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8620<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8621<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8622<li>any other non-array and non-multiset input value will cause a type error.</li>
8623</ul>
8624</li>
8625<li>
8626
8627<p>Example:</p>
8628
8629<div>
8630<div>
8631<pre class="source">strict_max( [10.2, 100, 5] );
8632</pre></div></div>
8633</li>
8634<li>
8635
8636<p>The expected result is:</p>
8637
8638<div>
8639<div>
8640<pre class="source">100.0
8641</pre></div></div>
8642</li>
8643</ul></div>
8644<div class="section">
8645<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
8646<ul>
8647
8648<li>
8649
8650<p>Syntax:</p>
8651
8652<div>
8653<div>
8654<pre class="source">strict_stddev_samp(num_collection)
8655</pre></div></div>
8656</li>
8657<li>
8658
8659<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
8660</li>
8661<li>Arguments:
8662<ul>
8663
8664<li><tt>num_collection</tt> could be:
8665<ul>
8666
8667<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8668<li>or, a <tt>null</tt> value,</li>
8669<li>or, a <tt>missing</tt> value.</li>
8670</ul>
8671</li>
8672</ul>
8673</li>
8674<li>Return Value:
8675<ul>
8676
8677<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
8678<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8679<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8680<li>any other non-numeric value in the input collection will cause a type error.</li>
8681</ul>
8682</li>
8683<li>
8684
8685<p>Example:</p>
8686
8687<div>
8688<div>
8689<pre class="source">strict_stddev_samp( [100, 200, 300] );
8690</pre></div></div>
8691</li>
8692<li>
8693
8694<p>The expected result is:</p>
8695
8696<div>
8697<div>
8698<pre class="source">100.0
8699</pre></div></div>
8700</li>
8701</ul></div>
8702<div class="section">
8703<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
8704<ul>
8705
8706<li>
8707
8708<p>Syntax:</p>
8709
8710<div>
8711<div>
8712<pre class="source">strict_stddev_pop(num_collection)
8713</pre></div></div>
8714</li>
8715<li>
8716
8717<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
8718</li>
8719<li>Arguments:
8720<ul>
8721
8722<li><tt>num_collection</tt> could be:
8723<ul>
8724
8725<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8726<li>or, a <tt>null</tt> value,</li>
8727<li>or, a <tt>missing</tt> value.</li>
8728</ul>
8729</li>
8730</ul>
8731</li>
8732<li>Return Value:
8733<ul>
8734
8735<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
8736<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8737<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8738<li>any other non-numeric value in the input collection will cause a type error.</li>
8739</ul>
8740</li>
8741<li>
8742
8743<p>Example:</p>
8744
8745<div>
8746<div>
8747<pre class="source">strict_stddev_pop( [100, 200, 300] );
8748</pre></div></div>
8749</li>
8750<li>
8751
8752<p>The expected result is:</p>
8753
8754<div>
8755<div>
8756<pre class="source">81.64965809277261
8757</pre></div></div>
8758</li>
8759</ul></div>
8760<div class="section">
8761<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
8762<ul>
8763
8764<li>
8765
8766<p>Syntax:</p>
8767
8768<div>
8769<div>
8770<pre class="source">strict_var_samp(num_collection)
8771</pre></div></div>
8772</li>
8773<li>
8774
8775<p>Gets the sample variance value of the numeric items in the given collection.</p>
8776</li>
8777<li>Arguments:
8778<ul>
8779
8780<li><tt>num_collection</tt> could be:
8781<ul>
8782
8783<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8784<li>or, a <tt>null</tt> value,</li>
8785<li>or, a <tt>missing</tt> value.</li>
8786</ul>
8787</li>
8788</ul>
8789</li>
8790<li>Return Value:
8791<ul>
8792
8793<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
8794<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8795<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8796<li>any other non-numeric value in the input collection will cause a type error.</li>
8797</ul>
8798</li>
8799<li>
8800
8801<p>Example:</p>
8802
8803<div>
8804<div>
8805<pre class="source">strict_var_samp( [100, 200, 300] );
8806</pre></div></div>
8807</li>
8808<li>
8809
8810<p>The expected result is:</p>
8811
8812<div>
8813<div>
8814<pre class="source">10000.0
8815</pre></div></div>
8816</li>
8817</ul></div>
8818<div class="section">
8819<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
8820<ul>
8821
8822<li>
8823
8824<p>Syntax:</p>
8825
8826<div>
8827<div>
8828<pre class="source">strict_var_pop(num_collection)
8829</pre></div></div>
8830</li>
8831<li>
8832
8833<p>Gets the population variance value of the numeric items in the given collection.</p>
8834</li>
8835<li>Arguments:
8836<ul>
8837
8838<li><tt>num_collection</tt> could be:
8839<ul>
8840
8841<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8842<li>or, a <tt>null</tt> value,</li>
8843<li>or, a <tt>missing</tt> value.</li>
8844</ul>
8845</li>
8846</ul>
8847</li>
8848<li>Return Value:
8849<ul>
8850
8851<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
8852<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8853<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8854<li>any other non-numeric value in the input collection will cause a type error.</li>
8855</ul>
8856</li>
8857<li>
8858
8859<p>Example:</p>
8860
8861<div>
8862<div>
8863<pre class="source">strict_var_pop( [100, 200, 300] );
8864</pre></div></div>
8865</li>
8866<li>
8867
8868<p>The expected result is:</p>
8869
8870<div>
8871<div>
8872<pre class="source">6666.666666666667
8873</pre></div></div>
8874</li>
8875</ul></div>
8876<div class="section">
8877<h3><a name="strict_skewness"></a>strict_skewness</h3>
8878<ul>
8879
8880<li>
8881
8882<p>Syntax:</p>
8883
8884<div>
8885<div>
8886<pre class="source">strict_skewness(num_collection)
8887</pre></div></div>
8888</li>
8889<li>
8890
8891<p>Gets the skewness value of the numeric items in the given collection.</p>
8892</li>
8893<li>Arguments:
8894<ul>
8895
8896<li><tt>num_collection</tt> could be:
8897<ul>
8898
8899<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8900<li>or, a <tt>null</tt> value,</li>
8901<li>or, a <tt>missing</tt> value.</li>
8902</ul>
8903</li>
8904</ul>
8905</li>
8906<li>Return Value:
8907<ul>
8908
8909<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
8910<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8911<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8912<li>any other non-numeric value in the input collection will cause a type error.</li>
8913</ul>
8914</li>
8915<li>
8916
8917<p>Example:</p>
8918
8919<div>
8920<div>
8921<pre class="source">strict_skewness( [100, 200, 300] );
8922</pre></div></div>
8923</li>
8924<li>
8925
8926<p>The expected result is:</p>
8927
8928<div>
8929<div>
8930<pre class="source">0.0
8931</pre></div></div>
8932</li>
8933</ul></div>
8934<div class="section">
8935<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
8936<ul>
8937
8938<li>
8939
8940<p>Syntax:</p>
8941
8942<div>
8943<div>
8944<pre class="source">strict_kurtosis(num_collection)
8945</pre></div></div>
8946</li>
8947<li>
8948
8949<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
8950</li>
8951<li>Arguments:
8952<ul>
8953
8954<li><tt>num_collection</tt> could be:
8955<ul>
8956
8957<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8958<li>or, a <tt>null</tt> value,</li>
8959<li>or, a <tt>missing</tt> value.</li>
8960</ul>
8961</li>
8962</ul>
8963</li>
8964<li>Return Value:
8965<ul>
8966
8967<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
8968<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8969<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8970<li>any other non-numeric value in the input collection will cause a type error.</li>
8971</ul>
8972</li>
8973<li>
8974
8975<p>Example:</p>
8976
8977<div>
8978<div>
8979<pre class="source">strict_kurtosis( [100, 200, 300] );
8980</pre></div></div>
8981</li>
8982<li>
8983
8984<p>The expected result is:</p>
8985
8986<div>
8987<div>
8988<pre class="source">-1.5
8989</pre></div></div>
8990</li>
8991</ul><!--
8992 ! Licensed to the Apache Software Foundation (ASF) under one
8993 ! or more contributor license agreements. See the NOTICE file
8994 ! distributed with this work for additional information
8995 ! regarding copyright ownership. The ASF licenses this file
8996 ! to you under the Apache License, Version 2.0 (the
8997 ! "License"); you may not use this file except in compliance
8998 ! with the License. You may obtain a copy of the License at
8999 !
9000 ! http://www.apache.org/licenses/LICENSE-2.0
9001 !
9002 ! Unless required by applicable law or agreed to in writing,
9003 ! software distributed under the License is distributed on an
9004 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9005 ! KIND, either express or implied. See the License for the
9006 ! specific language governing permissions and limitations
9007 ! under the License.
9008 !-->
9009</div></div>
9010<div class="section">
9011<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
9012<div class="section">
9013<h3><a name="greatest"></a>greatest</h3>
9014<ul>
9015
9016<li>
9017
9018<p>Syntax:</p>
9019
9020<div>
9021<div>
9022<pre class="source">greatest(numeric_value1, numeric_value2, ...)
9023</pre></div></div>
9024</li>
9025<li>
9026
9027<p>Computes the greatest value among arguments.</p>
9028</li>
9029<li>Arguments:
9030<ul>
9031
9032<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>
9033<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>
9034<li>&#x2026;.</li>
9035</ul>
9036</li>
9037<li>Return Value:
9038<ul>
9039
9040<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>
9041<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9042<li>any other non-numeric input value will cause a type error.</li>
9043</ul>
9044</li>
9045<li>
9046
9047<p>Example:</p>
9048
9049<div>
9050<div>
9051<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) };
9052</pre></div></div>
9053</li>
9054<li>
9055
9056<p>The expected result is:</p>
9057
9058<div>
9059<div>
9060<pre class="source">{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
9061</pre></div></div>
9062</li>
9063</ul></div>
9064<div class="section">
9065<h3><a name="least"></a>least</h3>
9066<ul>
9067
9068<li>
9069
9070<p>Syntax:</p>
9071
9072<div>
9073<div>
9074<pre class="source">least(numeric_value1, numeric_value2, ...)
9075</pre></div></div>
9076</li>
9077<li>
9078
9079<p>Computes the least value among arguments.</p>
9080</li>
9081<li>Arguments:
9082<ul>
9083
9084<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>
9085<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>
9086<li>&#x2026;.</li>
9087</ul>
9088</li>
9089<li>Return Value:
9090<ul>
9091
9092<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>
9093<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9094<li>any other non-numeric input value will cause a type error.</li>
9095</ul>
9096</li>
9097<li>
9098
9099<p>Example:</p>
9100
9101<div>
9102<div>
9103<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) };
9104</pre></div></div>
9105</li>
9106<li>
9107
9108<p>The expected result is:</p>
9109
9110<div>
9111<div>
9112<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
9113</pre></div></div>
9114</li>
9115</ul><!--
9116 ! Licensed to the Apache Software Foundation (ASF) under one
9117 ! or more contributor license agreements. See the NOTICE file
9118 ! distributed with this work for additional information
9119 ! regarding copyright ownership. The ASF licenses this file
9120 ! to you under the Apache License, Version 2.0 (the
9121 ! "License"); you may not use this file except in compliance
9122 ! with the License. You may obtain a copy of the License at
9123 !
9124 ! http://www.apache.org/licenses/LICENSE-2.0
9125 !
9126 ! Unless required by applicable law or agreed to in writing,
9127 ! software distributed under the License is distributed on an
9128 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9129 ! KIND, either express or implied. See the License for the
9130 ! specific language governing permissions and limitations
9131 ! under the License.
9132 !-->
9133</div></div>
9134<div class="section">
9135<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
9136<div class="section">
9137<h3><a name="is_array"></a>is_array</h3>
9138<ul>
9139
9140<li>
9141
9142<p>Syntax:</p>
9143
9144<div>
9145<div>
9146<pre class="source">is_array(expr)
9147</pre></div></div>
9148</li>
9149<li>
9150
9151<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
9152</li>
9153<li>Arguments:
9154<ul>
9155
9156<li><tt>expr</tt> : an expression (any type is allowed).</li>
9157</ul>
9158</li>
9159<li>Return Value:
9160<ul>
9161
9162<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
9163<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9164<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9165</ul>
9166</li>
9167<li>
9168
9169<p>Example:</p>
9170
9171<div>
9172<div>
9173<pre class="source">{
9174 &quot;a&quot;: is_array(true),
9175 &quot;b&quot;: is_array(false),
9176 &quot;c&quot;: isarray(null),
9177 &quot;d&quot;: isarray(missing),
9178 &quot;e&quot;: isarray(&quot;d&quot;),
9179 &quot;f&quot;: isarray(4.0),
9180 &quot;g&quot;: isarray(5),
9181 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
9182 &quot;i&quot;: isarray({&quot;a&quot;:1})
9183};
9184</pre></div></div>
9185</li>
9186<li>
9187
9188<p>The expected result is:</p>
9189
9190<div>
9191<div>
9192<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 }
9193</pre></div></div>
9194</li>
9195</ul>
9196<p>The function has an alias <tt>isarray</tt>.</p></div>
9197<div class="section">
9198<h3><a name="is_multiset"></a>is_multiset</h3>
9199<ul>
9200
9201<li>
9202
9203<p>Syntax:</p>
9204
9205<div>
9206<div>
9207<pre class="source">is_multiset(expr)
9208</pre></div></div>
9209</li>
9210<li>
9211
9212<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
9213</li>
9214<li>Arguments:
9215<ul>
9216
9217<li><tt>expr</tt> : an expression (any type is allowed).</li>
9218</ul>
9219</li>
9220<li>Return Value:
9221<ul>
9222
9223<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
9224<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9225<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9226</ul>
9227</li>
9228<li>
9229
9230<p>Example:</p>
9231
9232<div>
9233<div>
9234<pre class="source">{
9235 &quot;a&quot;: is_multiset(true),
9236 &quot;b&quot;: is_multiset(false),
9237 &quot;c&quot;: is_multiset(null),
9238 &quot;d&quot;: is_multiset(missing),
9239 &quot;e&quot;: is_multiset(&quot;d&quot;),
9240 &quot;f&quot;: ismultiset(4.0),
9241 &quot;g&quot;: ismultiset([&quot;1&quot;, 2]),
9242 &quot;h&quot;: ismultiset({&quot;a&quot;:1}),
9243 &quot;i&quot;: ismultiset({{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}})
9244};
9245</pre></div></div>
9246</li>
9247<li>
9248
9249<p>The expected result is:</p>
9250
9251<div>
9252<div>
9253<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;: false, &quot;i&quot;: true }
9254</pre></div></div>
9255</li>
9256</ul>
9257<p>The function has an alias <tt>ismultiset</tt>.</p></div>
9258<div class="section">
9259<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
9260<ul>
9261
9262<li>
9263
9264<p>Syntax:</p>
9265
9266<div>
9267<div>
9268<pre class="source">is_atomic(expr)
9269</pre></div></div>
9270</li>
9271<li>
9272
9273<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
9274</li>
9275<li>Arguments:
9276<ul>
9277
9278<li><tt>expr</tt> : an expression (any type is allowed).</li>
9279</ul>
9280</li>
9281<li>Return Value:
9282<ul>
9283
9284<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
9285<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9286<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9287</ul>
9288</li>
9289<li>
9290
9291<p>Example:</p>
9292
9293<div>
9294<div>
9295<pre class="source">{
9296 &quot;a&quot;: is_atomic(true),
9297 &quot;b&quot;: is_atomic(false),
9298 &quot;c&quot;: isatomic(null),
9299 &quot;d&quot;: isatomic(missing),
9300 &quot;e&quot;: isatomic(&quot;d&quot;),
9301 &quot;f&quot;: isatom(4.0),
9302 &quot;g&quot;: isatom(5),
9303 &quot;h&quot;: isatom([&quot;1&quot;, 2]),
9304 &quot;i&quot;: isatom({&quot;a&quot;:1})
9305};
9306</pre></div></div>
9307</li>
9308<li>
9309
9310<p>The expected result is:</p>
9311
9312<div>
9313<div>
9314<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 }
9315</pre></div></div>
9316</li>
9317</ul>
9318<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
9319<div class="section">
9320<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
9321<ul>
9322
9323<li>
9324
9325<p>Syntax:</p>
9326
9327<div>
9328<div>
9329<pre class="source">is_boolean(expr)
9330</pre></div></div>
9331</li>
9332<li>
9333
9334<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
9335</li>
9336<li>Arguments:
9337<ul>
9338
9339<li><tt>expr</tt> : an expression (any type is allowed).</li>
9340</ul>
9341</li>
9342<li>Return Value:
9343<ul>
9344
9345<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
9346<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9347<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9348</ul>
9349</li>
9350<li>
9351
9352<p>Example:</p>
9353
9354<div>
9355<div>
9356<pre class="source">{
9357 &quot;a&quot;: isboolean(true),
9358 &quot;b&quot;: isboolean(false),
9359 &quot;c&quot;: is_boolean(null),
9360 &quot;d&quot;: is_boolean(missing),
9361 &quot;e&quot;: isbool(&quot;d&quot;),
9362 &quot;f&quot;: isbool(4.0),
9363 &quot;g&quot;: isbool(5),
9364 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
9365 &quot;i&quot;: isbool({&quot;a&quot;:1})
9366};
9367</pre></div></div>
9368</li>
9369<li>
9370
9371<p>The expected result is:</p>
9372
9373<div>
9374<div>
9375<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 }
9376</pre></div></div>
9377</li>
9378</ul>
9379<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
9380<div class="section">
9381<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
9382<ul>
9383
9384<li>
9385
9386<p>Syntax:</p>
9387
9388<div>
9389<div>
9390<pre class="source">is_number(expr)
9391</pre></div></div>
9392</li>
9393<li>
9394
9395<p>Checks whether the given expression is evaluated to be a numeric value.</p>
9396</li>
9397<li>Arguments:
9398<ul>
9399
9400<li><tt>expr</tt> : an expression (any type is allowed).</li>
9401</ul>
9402</li>
9403<li>Return Value:
9404<ul>
9405
9406<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>
9407<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9408<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9409</ul>
9410</li>
9411<li>
9412
9413<p>Example:</p>
9414
9415<div>
9416<div>
9417<pre class="source">{
9418 &quot;a&quot;: is_number(true),
9419 &quot;b&quot;: is_number(false),
9420 &quot;c&quot;: isnumber(null),
9421 &quot;d&quot;: isnumber(missing),
9422 &quot;e&quot;: isnumber(&quot;d&quot;),
9423 &quot;f&quot;: isnum(4.0),
9424 &quot;g&quot;: isnum(5),
9425 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
9426 &quot;i&quot;: isnum({&quot;a&quot;:1})
9427};
9428</pre></div></div>
9429</li>
9430<li>
9431
9432<p>The expected result is:</p>
9433
9434<div>
9435<div>
9436<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 }
9437</pre></div></div>
9438</li>
9439</ul>
9440<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
9441<div class="section">
9442<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
9443<ul>
9444
9445<li>
9446
9447<p>Syntax:</p>
9448
9449<div>
9450<div>
9451<pre class="source">is_object(expr)
9452</pre></div></div>
9453</li>
9454<li>
9455
9456<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
9457</li>
9458<li>Arguments:
9459<ul>
9460
9461<li><tt>expr</tt> : an expression (any type is allowed).</li>
9462</ul>
9463</li>
9464<li>Return Value:
9465<ul>
9466
9467<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
9468<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9469<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9470</ul>
9471</li>
9472<li>
9473
9474<p>Example:</p>
9475
9476<div>
9477<div>
9478<pre class="source">{
9479 &quot;a&quot;: is_object(true),
9480 &quot;b&quot;: is_object(false),
9481 &quot;c&quot;: isobject(null),
9482 &quot;d&quot;: isobject(missing),
9483 &quot;e&quot;: isobj(&quot;d&quot;),
9484 &quot;f&quot;: isobj(4.0),
9485 &quot;g&quot;: isobj(5),
9486 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
9487 &quot;i&quot;: isobj({&quot;a&quot;:1})
9488};
9489</pre></div></div>
9490</li>
9491<li>
9492
9493<p>The expected result is:</p>
9494<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>
9495</li>
9496</ul>
9497<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
9498<div class="section">
9499<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
9500<ul>
9501
9502<li>
9503
9504<p>Syntax:</p>
9505
9506<div>
9507<div>
9508<pre class="source">is_string(expr)
9509</pre></div></div>
9510</li>
9511<li>
9512
9513<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
9514</li>
9515<li>Arguments:
9516<ul>
9517
9518<li><tt>expr</tt> : an expression (any type is allowed).</li>
9519</ul>
9520</li>
9521<li>Return Value:
9522<ul>
9523
9524<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
9525<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9526<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9527</ul>
9528</li>
9529<li>
9530
9531<p>Example:</p>
9532
9533<div>
9534<div>
9535<pre class="source">{
9536 &quot;a&quot;: is_string(true),
9537 &quot;b&quot;: isstring(false),
9538 &quot;c&quot;: isstring(null),
9539 &quot;d&quot;: isstr(missing),
9540 &quot;e&quot;: isstr(&quot;d&quot;),
9541 &quot;f&quot;: isstr(4.0),
9542 &quot;g&quot;: isstr(5),
9543 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
9544 &quot;i&quot;: isstr({&quot;a&quot;:1})
9545};
9546</pre></div></div>
9547</li>
9548<li>
9549
9550<p>The expected result is:</p>
9551
9552<div>
9553<div>
9554<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 }
9555</pre></div></div>
9556</li>
9557</ul>
9558<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
9559<div class="section">
9560<h3><a name="is_null"></a>is_null</h3>
9561<ul>
9562
9563<li>
9564
9565<p>Syntax:</p>
9566
9567<div>
9568<div>
9569<pre class="source">is_null(expr)
9570</pre></div></div>
9571</li>
9572<li>
9573
9574<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
9575</li>
9576<li>Arguments:
9577<ul>
9578
9579<li><tt>expr</tt> : an expression (any type is allowed).</li>
9580</ul>
9581</li>
9582<li>Return Value:
9583<ul>
9584
9585<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
9586<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
9587</ul>
9588</li>
9589<li>
9590
9591<p>Example:</p>
9592
9593<div>
9594<div>
9595<pre class="source">{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
9596</pre></div></div>
9597</li>
9598<li>
9599
9600<p>The expected result is:</p>
9601
9602<div>
9603<div>
9604<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
9605</pre></div></div>
9606</li>
9607</ul>
9608<p>The function has an alias <tt>isnull</tt>.</p></div>
9609<div class="section">
9610<h3><a name="is_missing"></a>is_missing</h3>
9611<ul>
9612
9613<li>
9614
9615<p>Syntax:</p>
9616
9617<div>
9618<div>
9619<pre class="source">is_missing(expr)
9620</pre></div></div>
9621</li>
9622<li>
9623
9624<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
9625</li>
9626<li>Arguments:
9627<ul>
9628
9629<li><tt>expr</tt> : an expression (any type is allowed).</li>
9630</ul>
9631</li>
9632<li>Return Value:
9633<ul>
9634
9635<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
9636</ul>
9637</li>
9638<li>
9639
9640<p>Example:</p>
9641
9642<div>
9643<div>
9644<pre class="source">{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
9645</pre></div></div>
9646</li>
9647<li>
9648
9649<p>The expected result is:</p>
9650
9651<div>
9652<div>
9653<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
9654</pre></div></div>
9655</li>
9656</ul>
9657<p>The function has an alias <tt>ismissing</tt>.</p></div>
9658<div class="section">
9659<h3><a name="is_unknown"></a>is_unknown</h3>
9660<ul>
9661
9662<li>
9663
9664<p>Syntax:</p>
9665
9666<div>
9667<div>
9668<pre class="source">is_unknown(expr)
9669</pre></div></div>
9670</li>
9671<li>
9672
9673<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
9674</li>
9675<li>Arguments:
9676<ul>
9677
9678<li><tt>expr</tt> : an expression (any type is allowed).</li>
9679</ul>
9680</li>
9681<li>Return Value:
9682<ul>
9683
9684<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>
9685</ul>
9686</li>
9687<li>
9688
9689<p>Example:</p>
9690
9691<div>
9692<div>
9693<pre class="source">{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
9694</pre></div></div>
9695</li>
9696<li>
9697
9698<p>The expected result is:</p>
9699
9700<div>
9701<div>
9702<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
9703</pre></div></div>
9704</li>
9705</ul>
9706<p>The function has an alias <tt>isunknown</tt>.</p><!--
9707 ! Licensed to the Apache Software Foundation (ASF) under one
9708 ! or more contributor license agreements. See the NOTICE file
9709 ! distributed with this work for additional information
9710 ! regarding copyright ownership. The ASF licenses this file
9711 ! to you under the Apache License, Version 2.0 (the
9712 ! "License"); you may not use this file except in compliance
9713 ! with the License. You may obtain a copy of the License at
9714 !
9715 ! http://www.apache.org/licenses/LICENSE-2.0
9716 !
9717 ! Unless required by applicable law or agreed to in writing,
9718 ! software distributed under the License is distributed on an
9719 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9720 ! KIND, either express or implied. See the License for the
9721 ! specific language governing permissions and limitations
9722 ! under the License.
9723 !-->
9724</div>
9725<div class="section">
9726<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
9727<ul>
9728
9729<li>
9730
9731<p>Syntax:</p>
9732
9733<div>
9734<div>
9735<pre class="source">is_binary(expr)
9736</pre></div></div>
9737</li>
9738<li>
9739
9740<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
9741</li>
9742<li>Arguments:
9743<ul>
9744
9745<li><tt>expr</tt> : an expression (any type is allowed).</li>
9746</ul>
9747</li>
9748<li>Return Value:
9749<ul>
9750
9751<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
9752<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9753<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9754</ul>
9755</li>
9756<li>
9757
9758<p>Example:</p>
9759
9760<div>
9761<div>
9762<pre class="source">{
9763 &quot;a&quot;: is_binary(true),
9764 &quot;b&quot;: is_binary(false),
9765 &quot;c&quot;: isbinary(null),
9766 &quot;d&quot;: isbinary(missing),
9767 &quot;e&quot;: isbin(point(&quot;1,2&quot;)),
9768 &quot;f&quot;: isbin(hex(&quot;ABCDEF0123456789&quot;)),
9769 &quot;g&quot;: is_bin(sub_binary(hex(&quot;AABBCCDD&quot;), 4)),
9770 &quot;h&quot;: is_bin(2),
9771 &quot;i&quot;: is_bin({&quot;a&quot;:1})
9772};
9773</pre></div></div>
9774</li>
9775<li>
9776
9777<p>The expected result is:</p>
9778
9779<div>
9780<div>
9781<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 }
9782</pre></div></div>
9783</li>
9784</ul>
9785<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
9786<div class="section">
9787<h3><a name="is_uuid"></a>is_uuid</h3>
9788<ul>
9789
9790<li>
9791
9792<p>Syntax:</p>
9793
9794<div>
9795<div>
9796<pre class="source">is_uuid(expr)
9797</pre></div></div>
9798</li>
9799<li>
9800
9801<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
9802</li>
9803<li>Arguments:
9804<ul>
9805
9806<li><tt>expr</tt> : an expression (any type is allowed).</li>
9807</ul>
9808</li>
9809<li>Return Value:
9810<ul>
9811
9812<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
9813<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9814<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9815</ul>
9816</li>
9817<li>
9818
9819<p>Example:</p>
9820
9821<div>
9822<div>
9823<pre class="source"> {
9824 &quot;a&quot;: is_uuid(true),
9825 &quot;b&quot;: is_uuid(false),
9826 &quot;c&quot;: is_uuid(null),
9827 &quot;d&quot;: is_uuid(missing),
9828 &quot;e&quot;: isuuid(4.0),
9829 &quot;f&quot;: isuuid(date(&quot;2013-01-01&quot;)),
9830 &quot;g&quot;: isuuid(uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;))
9831};
9832</pre></div></div>
9833</li>
9834<li>
9835
9836<p>The expected result is:</p>
9837
9838<div>
9839<div>
9840<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;: true }
9841</pre></div></div>
9842</li>
9843</ul>
9844<p>The function has an alias <tt>isuuid</tt>.</p></div>
9845<div class="section">
9846<h3><a name="is_point"></a>is_point</h3>
9847<ul>
9848
9849<li>
9850
9851<p>Syntax:</p>
9852
9853<div>
9854<div>
9855<pre class="source">is_point(expr)
9856</pre></div></div>
9857</li>
9858<li>
9859
9860<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
9861</li>
9862<li>Arguments:
9863<ul>
9864
9865<li><tt>expr</tt> : an expression (any type is allowed).</li>
9866</ul>
9867</li>
9868<li>Return Value:
9869<ul>
9870
9871<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
9872<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9873<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9874</ul>
9875</li>
9876<li>
9877
9878<p>Example:</p>
9879
9880<div>
9881<div>
9882<pre class="source">{
9883 &quot;a&quot;: is_point(true),
9884 &quot;b&quot;: is_point(false),
9885 &quot;c&quot;: is_point(null),
9886 &quot;d&quot;: is_point(missing),
9887 &quot;e&quot;: is_point(point(&quot;1,2&quot;)),
9888 &quot;f&quot;: ispoint(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9889 &quot;g&quot;: ispoint(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9890 &quot;h&quot;: ispoint(circle(&quot;30.0,70.0 5.0&quot;)),
9891 &quot;i&quot;: ispoint(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9892 &quot;j&quot;: ispoint(3)
9893};
9894</pre></div></div>
9895</li>
9896<li>
9897
9898<p>The expected result is:</p>
9899
9900<div>
9901<div>
9902<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, &quot;j&quot;: false }
9903</pre></div></div>
9904</li>
9905</ul>
9906<p>The function has an alias <tt>ispoint</tt>.</p></div>
9907<div class="section">
9908<h3><a name="is_line"></a>is_line</h3>
9909<ul>
9910
9911<li>
9912
9913<p>Syntax:</p>
9914
9915<div>
9916<div>
9917<pre class="source">is_line(expr)
9918</pre></div></div>
9919</li>
9920<li>
9921
9922<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
9923</li>
9924<li>Arguments:
9925<ul>
9926
9927<li><tt>expr</tt> : an expression (any type is allowed).</li>
9928</ul>
9929</li>
9930<li>Return Value:
9931<ul>
9932
9933<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
9934<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9935<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9936</ul>
9937</li>
9938<li>
9939
9940<p>Example:</p>
9941
9942<div>
9943<div>
9944<pre class="source">{
9945 &quot;a&quot;: is_line(true),
9946 &quot;b&quot;: is_line(false),
9947 &quot;c&quot;: is_line(null),
9948 &quot;d&quot;: is_line(missing),
9949 &quot;e&quot;: is_line(point(&quot;1,2&quot;)),
9950 &quot;f&quot;: isline(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9951 &quot;g&quot;: isline(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9952 &quot;h&quot;: isline(circle(&quot;30.0,70.0 5.0&quot;)),
9953 &quot;i&quot;: isline(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9954 &quot;j&quot;: isline(3)
9955};
9956</pre></div></div>
9957</li>
9958<li>
9959
9960<p>The expected result is:</p>
9961
9962<div>
9963<div>
9964<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;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false }
9965</pre></div></div>
9966</li>
9967</ul>
9968<p>The function has an alias <tt>isline</tt>.</p></div>
9969<div class="section">
9970<h3><a name="is_rectangle"></a>is_rectangle</h3>
9971<ul>
9972
9973<li>
9974
9975<p>Syntax:</p>
9976
9977<div>
9978<div>
9979<pre class="source">is_rectangle(expr)
9980</pre></div></div>
9981</li>
9982<li>
9983
9984<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
9985</li>
9986<li>Arguments:
9987<ul>
9988
9989<li><tt>expr</tt> : an expression (any type is allowed).</li>
9990</ul>
9991</li>
9992<li>Return Value:
9993<ul>
9994
9995<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
9996<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9997<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9998</ul>
9999</li>
10000<li>
10001
10002<p>Example:</p>
10003
10004<div>
10005<div>
10006<pre class="source">{
10007 &quot;a&quot;: is_rectangle(true),
10008 &quot;b&quot;: is_rectangle(false),
10009 &quot;c&quot;: is_rectangle(null),
10010 &quot;d&quot;: is_rectangle(missing),
10011 &quot;e&quot;: is_rectangle(point(&quot;1,2&quot;)),
10012 &quot;f&quot;: isrectangle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10013 &quot;g&quot;: isrectangle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10014 &quot;h&quot;: isrectangle(circle(&quot;30.0,70.0 5.0&quot;)),
10015 &quot;i&quot;: isrectangle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10016 &quot;j&quot;: isrectangle(3)
10017};
10018</pre></div></div>
10019</li>
10020<li>
10021
10022<p>The expected result is:</p>
10023
10024<div>
10025<div>
10026<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;: true, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false }
10027</pre></div></div>
10028</li>
10029</ul>
10030<p>The function has an alias <tt>isrectangle</tt>.</p></div>
10031<div class="section">
10032<h3><a name="is_circle"></a>is_circle</h3>
10033<ul>
10034
10035<li>
10036
10037<p>Syntax:</p>
10038
10039<div>
10040<div>
10041<pre class="source">is_circle(expr)
10042</pre></div></div>
10043</li>
10044<li>
10045
10046<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
10047</li>
10048<li>Arguments:
10049<ul>
10050
10051<li><tt>expr</tt> : an expression (any type is allowed).</li>
10052</ul>
10053</li>
10054<li>Return Value:
10055<ul>
10056
10057<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
10058<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10059<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10060</ul>
10061</li>
10062<li>
10063
10064<p>Example:</p>
10065
10066<div>
10067<div>
10068<pre class="source">{
10069 &quot;a&quot;: is_circle(true),
10070 &quot;b&quot;: is_circle(false),
10071 &quot;c&quot;: is_circle(null),
10072 &quot;d&quot;: is_circle(missing),
10073 &quot;e&quot;: is_circle(point(&quot;1,2&quot;)),
10074 &quot;f&quot;: iscircle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10075 &quot;g&quot;: iscircle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10076 &quot;h&quot;: iscircle(circle(&quot;30.0,70.0 5.0&quot;)),
10077 &quot;i&quot;: iscircle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10078 &quot;j&quot;: iscircle(3)
10079};
10080</pre></div></div>
10081</li>
10082<li>
10083
10084<p>The expected result is:</p>
10085
10086<div>
10087<div>
10088<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, &quot;j&quot;: false }
10089</pre></div></div>
10090</li>
10091</ul>
10092<p>The function has an alias <tt>iscircle</tt>.</p></div>
10093<div class="section">
10094<h3><a name="is_polygon"></a>is_polygon</h3>
10095<ul>
10096
10097<li>
10098
10099<p>Syntax:</p>
10100
10101<div>
10102<div>
10103<pre class="source">is_polygon(expr)
10104</pre></div></div>
10105</li>
10106<li>
10107
10108<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
10109</li>
10110<li>Arguments:
10111<ul>
10112
10113<li><tt>expr</tt> : an expression (any type is allowed).</li>
10114</ul>
10115</li>
10116<li>Return Value:
10117<ul>
10118
10119<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
10120<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10121<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10122</ul>
10123</li>
10124<li>
10125
10126<p>Example:</p>
10127
10128<div>
10129<div>
10130<pre class="source">{
10131 &quot;a&quot;: is_polygon(true),
10132 &quot;b&quot;: is_polygon(false),
10133 &quot;c&quot;: is_polygon(null),
10134 &quot;d&quot;: is_polygon(missing),
10135 &quot;e&quot;: is_polygon(point(&quot;1,2&quot;)),
10136 &quot;f&quot;: ispolygon(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10137 &quot;g&quot;: ispolygon(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10138 &quot;h&quot;: ispolygon(circle(&quot;30.0,70.0 5.0&quot;)),
10139 &quot;i&quot;: ispolygon(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10140 &quot;j&quot;: ispolygon(3)
10141};
10142</pre></div></div>
10143</li>
10144<li>
10145
10146<p>The expected result is:</p>
10147
10148<div>
10149<div>
10150<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;: false, &quot;i&quot;: true, &quot;j&quot;: false }
10151</pre></div></div>
10152</li>
10153</ul>
10154<p>The function has an alias <tt>ispolygon</tt>.</p></div>
10155<div class="section">
10156<h3><a name="is_spatial"></a>is_spatial</h3>
10157<ul>
10158
10159<li>
10160
10161<p>Syntax:</p>
10162
10163<div>
10164<div>
10165<pre class="source">is_spatial(expr)
10166</pre></div></div>
10167</li>
10168<li>
10169
10170<p>Checks whether the given expression is evaluated to be a spatial value.</p>
10171</li>
10172<li>Arguments:
10173<ul>
10174
10175<li><tt>expr</tt> : an expression (any type is allowed).</li>
10176</ul>
10177</li>
10178<li>Return Value:
10179<ul>
10180
10181<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt>/<tt>line</tt>/<tt>rectangle</tt>/<tt>circle</tt>/<tt>polygon</tt> value or not,</li>
10182<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10183<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10184</ul>
10185</li>
10186<li>
10187
10188<p>Example:</p>
10189
10190<div>
10191<div>
10192<pre class="source">{
10193 &quot;a&quot;: is_spatial(true),
10194 &quot;b&quot;: is_spatial(false),
10195 &quot;c&quot;: is_spatial(null),
10196 &quot;d&quot;: is_spatial(missing),
10197 &quot;e&quot;: is_spatial(point(&quot;1,2&quot;)),
10198 &quot;f&quot;: isspatial(line(&quot;30.0,70.0 50.0,90.0&quot;)),
10199 &quot;g&quot;: isspatial(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
10200 &quot;h&quot;: isspatial(circle(&quot;30.0,70.0 5.0&quot;)),
10201 &quot;i&quot;: isspatial(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
10202 &quot;j&quot;: isspatial(3)
10203};
10204</pre></div></div>
10205</li>
10206<li>
10207
10208<p>The expected result is:</p>
10209
10210<div>
10211<div>
10212<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: true, &quot;i&quot;: true, &quot;j&quot;: false }
10213</pre></div></div>
10214</li>
10215</ul>
10216<p>The function has an alias <tt>isspatial</tt>.</p></div>
10217<div class="section">
10218<h3><a name="is_date"></a>is_date</h3>
10219<ul>
10220
10221<li>
10222
10223<p>Syntax:</p>
10224
10225<div>
10226<div>
10227<pre class="source">is_date(expr)
10228</pre></div></div>
10229</li>
10230<li>
10231
10232<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
10233</li>
10234<li>Arguments:
10235<ul>
10236
10237<li><tt>expr</tt> : an expression (any type is allowed).</li>
10238</ul>
10239</li>
10240<li>Return Value:
10241<ul>
10242
10243<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
10244<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10245<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10246</ul>
10247</li>
10248<li>
10249
10250<p>Example:</p>
10251
10252<div>
10253<div>
10254<pre class="source">{
10255 &quot;a&quot;: is_date(true),
10256 &quot;b&quot;: is_date(false),
10257 &quot;c&quot;: is_date(null),
10258 &quot;d&quot;: is_date(missing),
10259 &quot;e&quot;: is_date(date(&quot;-19700101&quot;)),
10260 &quot;f&quot;: isdate(date(&quot;2013-01-01&quot;)),
10261 &quot;g&quot;: isdate(time(&quot;12:12:12.039Z&quot;)),
10262 &quot;h&quot;: isdate(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10263 &quot;i&quot;: isdate(duration(&quot;P100Y12MT12M&quot;)),
10264 &quot;j&quot;: isdate(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10265 &quot;k&quot;: isdate(3)
10266};
10267</pre></div></div>
10268</li>
10269<li>
10270
10271<p>The expected result is:</p>
10272
10273<div>
10274<div>
10275<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: false, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10276</pre></div></div>
10277</li>
10278</ul>
10279<p>The function has an alias <tt>isdate</tt>.</p></div>
10280<div class="section">
10281<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
10282<ul>
10283
10284<li>
10285
10286<p>Syntax:</p>
10287
10288<div>
10289<div>
10290<pre class="source">is_datetime(expr)
10291</pre></div></div>
10292</li>
10293<li>
10294
10295<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
10296</li>
10297<li>Arguments:
10298<ul>
10299
10300<li><tt>expr</tt> : an expression (any type is allowed).</li>
10301</ul>
10302</li>
10303<li>Return Value:
10304<ul>
10305
10306<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
10307<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10308<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10309</ul>
10310</li>
10311<li>
10312
10313<p>Example:</p>
10314
10315<div>
10316<div>
10317<pre class="source">{
10318 &quot;a&quot;: is_datetime(true),
10319 &quot;b&quot;: is_datetime(false),
10320 &quot;c&quot;: is_datetime(null),
10321 &quot;d&quot;: is_datetime(missing),
10322 &quot;e&quot;: is_datetime(datetime(&quot;2016-02-02T12:09:22.023Z&quot;)),
10323 &quot;f&quot;: isdatetime(datetime(&quot;2011-03-03T12:10:42.011Z&quot;)),
10324 &quot;g&quot;: isdatetime(time(&quot;12:12:12.039Z&quot;)),
10325 &quot;h&quot;: is_timestamp(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10326 &quot;i&quot;: is_timestamp(duration(&quot;P100Y12MT12M&quot;)),
10327 &quot;j&quot;: istimestamp(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10328 &quot;k&quot;: istimestamp(3)
10329};
10330</pre></div></div>
10331</li>
10332<li>
10333
10334<p>The expected result is:</p>
10335
10336<div>
10337<div>
10338<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: false, &quot;h&quot;: true, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10339</pre></div></div>
10340</li>
10341</ul>
10342<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
10343<div class="section">
10344<h3><a name="is_time"></a>is_time</h3>
10345<ul>
10346
10347<li>
10348
10349<p>Syntax:</p>
10350
10351<div>
10352<div>
10353<pre class="source">is_time(expr)
10354</pre></div></div>
10355</li>
10356<li>
10357
10358<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
10359</li>
10360<li>Arguments:
10361<ul>
10362
10363<li><tt>expr</tt> : an expression (any type is allowed).</li>
10364</ul>
10365</li>
10366<li>Return Value:
10367<ul>
10368
10369<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
10370<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10371<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10372</ul>
10373</li>
10374<li>
10375
10376<p>Example:</p>
10377
10378<div>
10379<div>
10380<pre class="source"> {
10381 &quot;a&quot;: is_time(true),
10382 &quot;b&quot;: is_time(false),
10383 &quot;c&quot;: is_time(null),
10384 &quot;d&quot;: is_time(missing),
10385 &quot;e&quot;: is_time(time(&quot;08:00:00.000Z&quot;)),
10386 &quot;f&quot;: istime(date(&quot;2013-01-01&quot;)),
10387 &quot;g&quot;: istime(time(&quot;12:12:12.039Z&quot;)),
10388 &quot;h&quot;: istime(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10389 &quot;i&quot;: istime(duration(&quot;P100Y12MT12M&quot;)),
10390 &quot;j&quot;: istime(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10391 &quot;k&quot;: istime(3)
10392};
10393</pre></div></div>
10394</li>
10395<li>
10396
10397<p>The expected result is:</p>
10398
10399<div>
10400<div>
10401<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;: true, &quot;h&quot;: false, &quot;i&quot;: false, &quot;j&quot;: false, &quot;k&quot;: false }
10402</pre></div></div>
10403</li>
10404</ul>
10405<p>The function has an alias <tt>istime</tt>.</p></div>
10406<div class="section">
10407<h3><a name="is_duration"></a>is_duration</h3>
10408<ul>
10409
10410<li>
10411
10412<p>Syntax:</p>
10413
10414<div>
10415<div>
10416<pre class="source">is_duration(expr)
10417</pre></div></div>
10418</li>
10419<li>
10420
10421<p>Checks whether the given expression is evaluated to be a duration value.</p>
10422</li>
10423<li>Arguments:
10424<ul>
10425
10426<li><tt>expr</tt> : an expression (any type is allowed).</li>
10427</ul>
10428</li>
10429<li>Return Value:
10430<ul>
10431
10432<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
10433<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10434<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10435</ul>
10436</li>
10437<li>
10438
10439<p>Example:</p>
10440
10441<div>
10442<div>
10443<pre class="source"> {
10444 &quot;a&quot;: is_duration(true),
10445 &quot;b&quot;: is_duration(false),
10446 &quot;c&quot;: is_duration(null),
10447 &quot;d&quot;: is_duration(missing),
10448 &quot;e&quot;: is_duration(duration(&quot;-PT20.943S&quot;)),
10449 &quot;f&quot;: isduration(date(&quot;2013-01-01&quot;)),
10450 &quot;g&quot;: isduration(time(&quot;12:12:12.039Z&quot;)),
10451 &quot;h&quot;: isduration(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10452 &quot;i&quot;: isduration(duration(&quot;P100Y12MT12M&quot;)),
10453 &quot;j&quot;: isduration(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10454 &quot;k&quot;: isduration(3)
10455};
10456</pre></div></div>
10457</li>
10458<li>
10459
10460<p>The expected result is:</p>
10461
10462<div>
10463<div>
10464<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;: true, &quot;j&quot;: false, &quot;k&quot;: false }
10465</pre></div></div>
10466</li>
10467</ul>
10468<p>The function has an alias <tt>isduration</tt>.</p></div>
10469<div class="section">
10470<h3><a name="is_interval"></a>is_interval</h3>
10471<ul>
10472
10473<li>
10474
10475<p>Syntax:</p>
10476
10477<div>
10478<div>
10479<pre class="source">is_interval(expr)
10480</pre></div></div>
10481</li>
10482<li>
10483
10484<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
10485</li>
10486<li>Arguments:
10487<ul>
10488
10489<li><tt>expr</tt> : an expression (any type is allowed).</li>
10490</ul>
10491</li>
10492<li>Return Value:
10493<ul>
10494
10495<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
10496<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10497<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10498</ul>
10499</li>
10500<li>
10501
10502<p>Example:</p>
10503
10504<div>
10505<div>
10506<pre class="source"> {
10507 &quot;a&quot;: is_interval(true),
10508 &quot;b&quot;: is_interval(false),
10509 &quot;c&quot;: is_interval(null),
10510 &quot;d&quot;: is_interval(missing),
10511 &quot;e&quot;: is_interval(interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))),
10512 &quot;f&quot;: isinterval(date(&quot;2013-01-01&quot;)),
10513 &quot;g&quot;: isinterval(time(&quot;12:12:12.039Z&quot;)),
10514 &quot;h&quot;: isinterval(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10515 &quot;i&quot;: isinterval(duration(&quot;P100Y12MT12M&quot;)),
10516 &quot;j&quot;: isinterval(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10517 &quot;k&quot;: isinterval(3)
10518};
10519</pre></div></div>
10520</li>
10521<li>
10522
10523<p>The expected result is:</p>
10524
10525<div>
10526<div>
10527<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, &quot;j&quot;: true, &quot;k&quot;: false }
10528</pre></div></div>
10529</li>
10530</ul>
10531<p>The function has an alias <tt>isinterval</tt>.</p></div>
10532<div class="section">
10533<h3><a name="is_temporal"></a>is_temporal</h3>
10534<ul>
10535
10536<li>
10537
10538<p>Syntax:</p>
10539
10540<div>
10541<div>
10542<pre class="source">is_temporal(expr)
10543</pre></div></div>
10544</li>
10545<li>
10546
10547<p>Checks whether the given expression is evaluated to be a temporal value.</p>
10548</li>
10549<li>Arguments:
10550<ul>
10551
10552<li><tt>expr</tt> : an expression (any type is allowed).</li>
10553</ul>
10554</li>
10555<li>Return Value:
10556<ul>
10557
10558<li>a <tt>boolean</tt> on whether the argument is a <tt>date/datetime/time/duration/year_month_duration/day_time_duration/interval</tt> value or not,</li>
10559<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10560<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10561</ul>
10562</li>
10563<li>
10564
10565<p>Example:</p>
10566
10567<div>
10568<div>
10569<pre class="source"> {
10570 &quot;a&quot;: is_temporal(true),
10571 &quot;b&quot;: is_temporal(false),
10572 &quot;c&quot;: is_temporal(null),
10573 &quot;d&quot;: is_temporal(missing),
10574 &quot;e&quot;: is_temporal(duration(&quot;-PT20.943S&quot;)),
10575 &quot;f&quot;: istemporal(date(&quot;2013-01-01&quot;)),
10576 &quot;g&quot;: istemporal(time(&quot;12:12:12.039Z&quot;)),
10577 &quot;h&quot;: istemporal(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10578 &quot;i&quot;: istemporal(duration(&quot;P100Y12MT12M&quot;)),
10579 &quot;j&quot;: istemporal(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10580 &quot;k&quot;: istemporal(3)
10581};
10582</pre></div></div>
10583</li>
10584<li>
10585
10586<p>The expected result is:</p>
10587
10588<div>
10589<div>
10590<pre class="source">{ &quot;a&quot;: false, &quot;b&quot;: false, &quot;c&quot;: null, &quot;e&quot;: true, &quot;f&quot;: true, &quot;g&quot;: true, &quot;h&quot;: true, &quot;i&quot;: true, &quot;j&quot;: true, &quot;k&quot;: false }
10591</pre></div></div>
10592</li>
10593</ul>
10594<p>The function has an alias <tt>istemporal</tt>.</p></div>
10595<div class="section">
10596<h3><a name="get_type"></a>get_type</h3>
10597<ul>
10598
10599<li>
10600
10601<p>Syntax:</p>
10602
10603<div>
10604<div>
10605<pre class="source">get_type(expr)
10606</pre></div></div>
10607</li>
10608<li>
10609
10610<p>Returns a string describing the type of the given <tt>expr</tt>. This includes incomplete information types (i.e. <tt>missing</tt> and <tt>null</tt>).</p>
10611</li>
10612<li>Arguments:
10613<ul>
10614
10615<li><tt>expr</tt> : an expression (any type is allowed).</li>
10616</ul>
10617</li>
10618<li>
10619
10620<p>Example:</p>
10621
10622<div>
10623<div>
10624<pre class="source">{
10625 &quot;a&quot;: get_type(true),
10626 &quot;b&quot;: get_type(false),
10627 &quot;c&quot;: get_type(null),
10628 &quot;d&quot;: get_type(missing),
10629 &quot;e&quot;: get_type(&quot;d&quot;),
10630 &quot;f&quot;: gettype(4.0),
10631 &quot;g&quot;: gettype(5),
10632 &quot;h&quot;: gettype([&quot;1&quot;, 2]),
10633 &quot;i&quot;: gettype({&quot;a&quot;:1})
10634};
10635</pre></div></div>
10636</li>
10637<li>
10638
10639<p>The expected result is:</p>
10640
10641<div>
10642<div>
10643<pre class="source">{ &quot;a&quot;: &quot;boolean&quot;, &quot;b&quot;: &quot;boolean&quot;, &quot;c&quot;: &quot;null&quot;, &quot;d&quot;: &quot;missing&quot;, &quot;e&quot;: &quot;string&quot;, &quot;f&quot;: &quot;double&quot;, &quot;g&quot;: &quot;bigint&quot;, &quot;h&quot;: &quot;array&quot;, &quot;i&quot;: &quot;object&quot; }
10644</pre></div></div>
10645</li>
10646</ul>
10647<p>The function has an alias <tt>gettype</tt>.</p><!--
10648 ! Licensed to the Apache Software Foundation (ASF) under one
10649 ! or more contributor license agreements. See the NOTICE file
10650 ! distributed with this work for additional information
10651 ! regarding copyright ownership. The ASF licenses this file
10652 ! to you under the Apache License, Version 2.0 (the
10653 ! "License"); you may not use this file except in compliance
10654 ! with the License. You may obtain a copy of the License at
10655 !
10656 ! http://www.apache.org/licenses/LICENSE-2.0
10657 !
10658 ! Unless required by applicable law or agreed to in writing,
10659 ! software distributed under the License is distributed on an
10660 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10661 ! KIND, either express or implied. See the License for the
10662 ! specific language governing permissions and limitations
10663 ! under the License.
10664 !-->
10665</div>
10666<div class="section">
10667<h3><a name="to_array"></a>to_array</h3>
10668<ul>
10669
10670<li>
10671
10672<p>Syntax:</p>
10673
10674<div>
10675<div>
10676<pre class="source">to_array(expr)
10677</pre></div></div>
10678</li>
10679<li>
10680
10681<p>Converts input value to an <tt>array</tt> value</p>
10682</li>
10683<li>Arguments:
10684<ul>
10685
10686<li><tt>expr</tt> : an expression</li>
10687</ul>
10688</li>
10689<li>Return Value:
10690<ul>
10691
10692<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10693<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10694<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
10695<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>
10696<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
10697</ul>
10698</li>
10699<li>
10700
10701<p>Example:</p>
10702
10703<div>
10704<div>
10705<pre class="source">{
10706 &quot;v1&quot;: to_array(&quot;asterix&quot;),
10707 &quot;v2&quot;: to_array([&quot;asterix&quot;]),
10708};
10709</pre></div></div>
10710</li>
10711<li>
10712
10713<p>The expected result is:</p>
10714
10715<div>
10716<div>
10717<pre class="source">{ &quot;v1&quot;: [&quot;asterix&quot;], &quot;v2&quot;: [&quot;asterix&quot;] }
10718</pre></div></div>
10719</li>
10720</ul>
10721<p>The function has an alias <tt>toarray</tt>.</p></div>
10722<div class="section">
10723<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
10724<ul>
10725
10726<li>
10727
10728<p>Syntax:</p>
10729
10730<div>
10731<div>
10732<pre class="source">to_atomic(expr)
10733</pre></div></div>
10734</li>
10735<li>
10736
10737<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
10738</li>
10739<li>Arguments:
10740<ul>
10741
10742<li><tt>expr</tt> : an expression</li>
10743</ul>
10744</li>
10745<li>Return Value:
10746<ul>
10747
10748<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10749<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10750<li>if the argument is of primitive type then it is returned as is</li>
10751<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>
10752<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>
10753<li>otherwise <tt>null</tt> is returned</li>
10754</ul>
10755</li>
10756<li>
10757
10758<p>Example:</p>
10759
10760<div>
10761<div>
10762<pre class="source">{
10763 &quot;v1&quot;: to_atomic(&quot;asterix&quot;),
10764 &quot;v2&quot;: to_atomic([&quot;asterix&quot;]),
10765 &quot;v3&quot;: to_atomic([0, 1]),
10766 &quot;v4&quot;: to_atomic({&quot;value&quot;: &quot;asterix&quot;}),
10767 &quot;v5&quot;: to_number({&quot;x&quot;: 1, &quot;y&quot;: 2})
10768};
10769</pre></div></div>
10770</li>
10771<li>
10772
10773<p>The expected result is:</p>
10774
10775<div>
10776<div>
10777<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 }
10778</pre></div></div>
10779</li>
10780</ul>
10781<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
10782<div class="section">
10783<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
10784<ul>
10785
10786<li>
10787
10788<p>Syntax:</p>
10789
10790<div>
10791<div>
10792<pre class="source">to_boolean(expr)
10793</pre></div></div>
10794</li>
10795<li>
10796
10797<p>Converts input value to a <tt>boolean</tt> value</p>
10798</li>
10799<li>Arguments:
10800<ul>
10801
10802<li><tt>expr</tt> : an expression</li>
10803</ul>
10804</li>
10805<li>Return Value:
10806<ul>
10807
10808<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10809<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10810<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
10811<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>
10812<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>
10813<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>
10814<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>
10815<li>type error is raised for all other input types</li>
10816</ul>
10817</li>
10818<li>
10819
10820<p>Example:</p>
10821
10822<div>
10823<div>
10824<pre class="source">{
10825 &quot;v1&quot;: to_boolean(0),
10826 &quot;v2&quot;: to_boolean(1),
10827 &quot;v3&quot;: to_boolean(&quot;&quot;),
10828 &quot;v4&quot;: to_boolean(&quot;asterix&quot;)
10829};
10830</pre></div></div>
10831</li>
10832<li>
10833
10834<p>The expected result is:</p>
10835
10836<div>
10837<div>
10838<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: false, &quot;v4&quot;: true }
10839</pre></div></div>
10840</li>
10841</ul>
10842<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
10843<div class="section">
10844<h3><a name="to_bigint"></a>to_bigint</h3>
10845<ul>
10846
10847<li>
10848
10849<p>Syntax:</p>
10850
10851<div>
10852<div>
10853<pre class="source">to_bigint(expr)
10854</pre></div></div>
10855</li>
10856<li>
10857
10858<p>Converts input value to an integer value</p>
10859</li>
10860<li>Arguments:
10861<ul>
10862
10863<li><tt>expr</tt> : an expression</li>
10864</ul>
10865</li>
10866<li>Return Value:
10867<ul>
10868
10869<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10870<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10871<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>
10872<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
10873<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
10874<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>
10875<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10876<li>type error is raised for all other input types</li>
10877</ul>
10878</li>
10879<li>
10880
10881<p>Example:</p>
10882
10883<div>
10884<div>
10885<pre class="source">{
10886 &quot;v1&quot;: to_bigint(false),
10887 &quot;v2&quot;: to_bigint(true),
10888 &quot;v3&quot;: to_bigint(10),
10889 &quot;v4&quot;: to_bigint(float(&quot;1e100&quot;)),
10890 &quot;v5&quot;: to_bigint(double(&quot;1e1000&quot;)),
10891 &quot;v6&quot;: to_bigint(&quot;20&quot;)
10892};
10893</pre></div></div>
10894</li>
10895<li>
10896
10897<p>The expected result is:</p>
10898
10899<div>
10900<div>
10901<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 }
10902</pre></div></div>
10903</li>
10904</ul>
10905<p>The function has an alias <tt>tobigint</tt>.</p></div>
10906<div class="section">
10907<h3><a name="to_double"></a>to_double</h3>
10908<ul>
10909
10910<li>
10911
10912<p>Syntax:</p>
10913
10914<div>
10915<div>
10916<pre class="source">to_double(expr)
10917</pre></div></div>
10918</li>
10919<li>
10920
10921<p>Converts input value to a <tt>double</tt> value</p>
10922</li>
10923<li>Arguments:
10924<ul>
10925
10926<li><tt>expr</tt> : an expression</li>
10927</ul>
10928</li>
10929<li>Return Value:
10930<ul>
10931
10932<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10933<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10934<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>
10935<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
10936<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>
10937<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10938<li>type error is raised for all other input types</li>
10939</ul>
10940</li>
10941<li>
10942
10943<p>Example:</p>
10944
10945<div>
10946<div>
10947<pre class="source">{
10948 &quot;v1&quot;: to_double(false),
10949 &quot;v2&quot;: to_double(true),
10950 &quot;v3&quot;: to_double(10),
10951 &quot;v4&quot;: to_double(11.5),
10952 &quot;v5&quot;: to_double(&quot;12.5&quot;)
10953};
10954</pre></div></div>
10955</li>
10956<li>
10957
10958<p>The expected result is:</p>
10959
10960<div>
10961<div>
10962<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 }
10963</pre></div></div>
10964</li>
10965</ul>
10966<p>The function has an alias <tt>todouble</tt>.</p></div>
10967<div class="section">
10968<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
10969<ul>
10970
10971<li>
10972
10973<p>Syntax:</p>
10974
10975<div>
10976<div>
10977<pre class="source">to_number(expr)
10978</pre></div></div>
10979</li>
10980<li>
10981
10982<p>Converts input value to a numeric value</p>
10983</li>
10984<li>Arguments:
10985<ul>
10986
10987<li><tt>expr</tt> : an expression</li>
10988</ul>
10989</li>
10990<li>Return Value:
10991<ul>
10992
10993<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10994<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10995<li>if the argument is of numeric type then it is returned as is</li>
10996<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>
10997<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>
10998<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10999<li>type error is raised for all other input types</li>
11000</ul>
11001</li>
11002<li>
11003
11004<p>Example:</p>
11005
11006<div>
11007<div>
11008<pre class="source">{
11009 &quot;v1&quot;: to_number(false),
11010 &quot;v2&quot;: to_number(true),
11011 &quot;v3&quot;: to_number(10),
11012 &quot;v4&quot;: to_number(11.5),
11013 &quot;v5&quot;: to_number(&quot;12.5&quot;)
11014};
11015</pre></div></div>
11016</li>
11017<li>
11018
11019<p>The expected result is:</p>
11020
11021<div>
11022<div>
11023<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 }
11024</pre></div></div>
11025</li>
11026</ul>
11027<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
11028<div class="section">
11029<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
11030<ul>
11031
11032<li>
11033
11034<p>Syntax:</p>
11035
11036<div>
11037<div>
11038<pre class="source">to_object(expr)
11039</pre></div></div>
11040</li>
11041<li>
11042
11043<p>Converts input value to an <tt>object</tt> value</p>
11044</li>
11045<li>Arguments:
11046<ul>
11047
11048<li><tt>expr</tt> : an expression</li>
11049</ul>
11050</li>
11051<li>Return Value:
11052<ul>
11053
11054<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11055<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11056<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
11057<li>otherwise an empty <tt>object</tt> is returned</li>
11058</ul>
11059</li>
11060<li>
11061
11062<p>Example:</p>
11063
11064<div>
11065<div>
11066<pre class="source">{
11067 &quot;v1&quot;: to_object({&quot;value&quot;: &quot;asterix&quot;}),
11068 &quot;v2&quot;: to_object(&quot;asterix&quot;)
11069};
11070</pre></div></div>
11071</li>
11072<li>
11073
11074<p>The expected result is:</p>
11075
11076<div>
11077<div>
11078<pre class="source">{ &quot;v1&quot;: {&quot;value&quot;: &quot;asterix&quot;}, &quot;v2&quot;: {} }
11079</pre></div></div>
11080</li>
11081</ul>
11082<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
11083<div class="section">
11084<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
11085<ul>
11086
11087<li>
11088
11089<p>Syntax:</p>
11090
11091<div>
11092<div>
11093<pre class="source">to_string(expr)
11094</pre></div></div>
11095</li>
11096<li>
11097
11098<p>Converts input value to a string value</p>
11099</li>
11100<li>Arguments:
11101<ul>
11102
11103<li><tt>expr</tt> : an expression</li>
11104</ul>
11105</li>
11106<li>Return Value:
11107<ul>
11108
11109<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11110<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11111<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>
11112<li>if the argument is of numeric type then its string representation is returned</li>
11113<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
11114<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
11115<li>type error is raised for all other input types</li>
11116</ul>
11117</li>
11118<li>
11119
11120<p>Example:</p>
11121
11122<div>
11123<div>
11124<pre class="source">{
11125 &quot;v1&quot;: to_string(false),
11126 &quot;v2&quot;: to_string(true),
11127 &quot;v3&quot;: to_string(10),
11128 &quot;v4&quot;: to_string(11.5),
11129 &quot;v5&quot;: to_string(&quot;asterix&quot;)
11130};
11131</pre></div></div>
11132</li>
11133<li>
11134
11135<p>The expected result is:</p>
11136
11137<div>
11138<div>
11139<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; }
11140</pre></div></div>
11141</li>
11142</ul>
11143<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
11144 ! Licensed to the Apache Software Foundation (ASF) under one
11145 ! or more contributor license agreements. See the NOTICE file
11146 ! distributed with this work for additional information
11147 ! regarding copyright ownership. The ASF licenses this file
11148 ! to you under the Apache License, Version 2.0 (the
11149 ! "License"); you may not use this file except in compliance
11150 ! with the License. You may obtain a copy of the License at
11151 !
11152 ! http://www.apache.org/licenses/LICENSE-2.0
11153 !
11154 ! Unless required by applicable law or agreed to in writing,
11155 ! software distributed under the License is distributed on an
11156 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11157 ! KIND, either express or implied. See the License for the
11158 ! specific language governing permissions and limitations
11159 ! under the License.
11160 !-->
11161</div></div>
11162<div class="section">
11163<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
11164<div class="section">
11165<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
11166<ul>
11167
11168<li>
11169
11170<p>Syntax:</p>
11171
11172<div>
11173<div>
11174<pre class="source">if_null(expression1, expression2, ... expressionN)
11175</pre></div></div>
11176</li>
11177<li>
11178
11179<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
11180</li>
11181<li>Arguments:
11182<ul>
11183
11184<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11185</ul>
11186</li>
11187<li>Return Value:
11188<ul>
11189
11190<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
11191<li>a value of the first non-<tt>null</tt> argument otherwise</li>
11192</ul>
11193</li>
11194<li>
11195
11196<p>Example:</p>
11197
11198<div>
11199<div>
11200<pre class="source">{
11201 &quot;a&quot;: if_null(),
11202 &quot;b&quot;: if_null(null),
11203 &quot;c&quot;: if_null(null, &quot;asterixdb&quot;),
11204 &quot;d&quot;: is_missing(if_null(missing))
11205};
11206</pre></div></div>
11207</li>
11208<li>
11209
11210<p>The expected result is:</p>
11211
11212<div>
11213<div>
11214<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: true }
11215</pre></div></div>
11216</li>
11217</ul>
11218<p>The function has an alias <tt>ifnull</tt>.</p></div>
11219<div class="section">
11220<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
11221<ul>
11222
11223<li>
11224
11225<p>Syntax:</p>
11226
11227<div>
11228<div>
11229<pre class="source">if_missing(expression1, expression2, ... expressionN)
11230</pre></div></div>
11231</li>
11232<li>
11233
11234<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
11235</li>
11236<li>Arguments:
11237<ul>
11238
11239<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11240</ul>
11241</li>
11242<li>Return Value:
11243<ul>
11244
11245<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
11246<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
11247</ul>
11248</li>
11249<li>
11250
11251<p>Example:</p>
11252
11253<div>
11254<div>
11255<pre class="source">{
11256 &quot;a&quot;: if_missing(),
11257 &quot;b&quot;: if_missing(missing),
11258 &quot;c&quot;: if_missing(missing, &quot;asterixdb&quot;),
11259 &quot;d&quot;: if_missing(null, &quot;asterixdb&quot;)
11260};
11261</pre></div></div>
11262</li>
11263<li>
11264
11265<p>The expected result is:</p>
11266
11267<div>
11268<div>
11269<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: null }
11270</pre></div></div>
11271</li>
11272</ul>
11273<p>The function has an alias <tt>ifmissing</tt>.</p></div>
11274<div class="section">
11275<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
11276<ul>
11277
11278<li>
11279
11280<p>Syntax:</p>
11281
11282<div>
11283<div>
11284<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
11285</pre></div></div>
11286</li>
11287<li>
11288
11289<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
11290</li>
11291<li>Arguments:
11292<ul>
11293
11294<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11295</ul>
11296</li>
11297<li>Return Value:
11298<ul>
11299
11300<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
11301<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
11302</ul>
11303</li>
11304<li>
11305
11306<p>Example:</p>
11307
11308<div>
11309<div>
11310<pre class="source">{
11311 &quot;a&quot;: if_missing_or_null(),
11312 &quot;b&quot;: if_missing_or_null(null, missing),
11313 &quot;c&quot;: if_missing_or_null(null, missing, &quot;asterixdb&quot;)
11314};
11315</pre></div></div>
11316</li>
11317<li>
11318
11319<p>The expected result is:</p>
11320
11321<div>
11322<div>
11323<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot; }
11324</pre></div></div>
11325</li>
11326</ul>
11327<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
11328<div class="section">
11329<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
11330<ul>
11331
11332<li>
11333
11334<p>Syntax:</p>
11335
11336<div>
11337<div>
11338<pre class="source">if_inf(expression1, expression2, ... expressionN)
11339</pre></div></div>
11340</li>
11341<li>
11342
11343<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
11344</li>
11345<li>Arguments:
11346<ul>
11347
11348<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11349</ul>
11350</li>
11351<li>Return Value:
11352<ul>
11353
11354<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
11355<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>
11356<li>the first non-infinite number argument otherwise</li>
11357</ul>
11358</li>
11359<li>
11360
11361<p>Example:</p>
11362
11363<div>
11364<div>
11365<pre class="source">{
11366 &quot;a&quot;: is_null(if_inf(null)),
11367 &quot;b&quot;: is_missing(if_inf(missing)),
11368 &quot;c&quot;: is_null(if_inf(double(&quot;INF&quot;))),
11369 &quot;d&quot;: if_inf(1, null, missing) ],
11370 &quot;e&quot;: is_null(if_inf(null, missing, 1)) ],
11371 &quot;f&quot;: is_missing(if_inf(missing, null, 1)) ],
11372 &quot;g&quot;: if_inf(float(&quot;INF&quot;), 1) ],
11373 &quot;h&quot;: to_string(if_inf(float(&quot;INF&quot;), double(&quot;NaN&quot;), 1)) ]
11374};
11375</pre></div></div>
11376</li>
11377<li>
11378
11379<p>The expected result is:</p>
11380
11381<div>
11382<div>
11383<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; }
11384</pre></div></div>
11385</li>
11386</ul>
11387<p>The function has an alias <tt>ifinf</tt>.</p></div>
11388<div class="section">
11389<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
11390<ul>
11391
11392<li>
11393
11394<p>Syntax:</p>
11395
11396<div>
11397<div>
11398<pre class="source">if_nan(expression1, expression2, ... expressionN)
11399</pre></div></div>
11400</li>
11401<li>
11402
11403<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
11404</li>
11405<li>Arguments:
11406<ul>
11407
11408<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11409</ul>
11410</li>
11411<li>Return Value:
11412<ul>
11413
11414<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11415<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>
11416<li>the first non-<tt>NaN</tt> number argument otherwise</li>
11417</ul>
11418</li>
11419<li>
11420
11421<p>Example:</p>
11422
11423<div>
11424<div>
11425<pre class="source">{
11426 &quot;a&quot;: is_null(if_nan(null)),
11427 &quot;b&quot;: is_missing(if_nan(missing)),
11428 &quot;c&quot;: is_null(if_nan(double(&quot;NaN&quot;))),
11429 &quot;d&quot;: if_nan(1, null, missing) ],
11430 &quot;e&quot;: is_null(if_nan(null, missing, 1)) ],
11431 &quot;f&quot;: is_missing(if_nan(missing, null, 1)) ],
11432 &quot;g&quot;: if_nan(float(&quot;NaN&quot;), 1) ],
11433 &quot;h&quot;: to_string(if_nan(float(&quot;NaN&quot;), double(&quot;INF&quot;), 1)) ]
11434};
11435</pre></div></div>
11436</li>
11437<li>
11438
11439<p>The expected result is:</p>
11440
11441<div>
11442<div>
11443<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; }
11444</pre></div></div>
11445</li>
11446</ul>
11447<p>The function has an alias <tt>ifnan</tt>.</p></div>
11448<div class="section">
11449<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
11450<ul>
11451
11452<li>
11453
11454<p>Syntax:</p>
11455
11456<div>
11457<div>
11458<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
11459</pre></div></div>
11460</li>
11461<li>
11462
11463<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
11464</li>
11465<li>Arguments:
11466<ul>
11467
11468<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11469</ul>
11470</li>
11471<li>Return Value:
11472<ul>
11473
11474<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>
11475<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>
11476<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
11477</ul>
11478</li>
11479<li>
11480
11481<p>Example:</p>
11482
11483<div>
11484<div>
11485<pre class="source">{
11486 &quot;a&quot;: is_null(if_nan_or_inf(null)),
11487 &quot;b&quot;: is_missing(if_nan_or_inf(missing)),
11488 &quot;c&quot;: is_null(if_nan_or_inf(double(&quot;NaN&quot;), double(&quot;INF&quot;))),
11489 &quot;d&quot;: if_nan_or_inf(1, null, missing) ],
11490 &quot;e&quot;: is_null(if_nan_or_inf(null, missing, 1)) ],
11491 &quot;f&quot;: is_missing(if_nan_or_inf(missing, null, 1)) ],
11492 &quot;g&quot;: if_nan_or_inf(float(&quot;NaN&quot;), float(&quot;INF&quot;), 1) ],
11493};
11494</pre></div></div>
11495</li>
11496<li>
11497
11498<p>The expected result is:</p>
11499
11500<div>
11501<div>
11502<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 }
11503</pre></div></div>
11504</li>
11505</ul>
11506<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
11507<div class="section">
11508<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
11509<ul>
11510
11511<li>
11512
11513<p>Syntax:</p>
11514
11515<div>
11516<div>
11517<pre class="source">null_if(expression1, expression2)
11518</pre></div></div>
11519</li>
11520<li>
11521
11522<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
11523</li>
11524<li>Arguments:
11525<ul>
11526
11527<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11528</ul>
11529</li>
11530<li>Return Value:
11531<ul>
11532
11533<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11534<li><tt>null</tt> if
11535<ul>
11536
11537<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
11538<li><tt>argument1</tt> = <tt>argument2</tt></li>
11539</ul>
11540</li>
11541<li>a value of the first argument otherwise</li>
11542</ul>
11543</li>
11544<li>
11545
11546<p>Example:</p>
11547
11548<div>
11549<div>
11550<pre class="source">{
11551 &quot;a&quot;: null_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;),
11552 &quot;b&quot;: null_if(1, 2)
11553};
11554</pre></div></div>
11555</li>
11556<li>
11557
11558<p>The expected result is:</p>
11559
11560<div>
11561<div>
11562<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: 1 }
11563</pre></div></div>
11564</li>
11565</ul>
11566<p>The function has an alias <tt>nullif</tt>.</p></div>
11567<div class="section">
11568<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
11569<ul>
11570
11571<li>
11572
11573<p>Syntax:</p>
11574
11575<div>
11576<div>
11577<pre class="source">missing_if(expression1, expression2)
11578</pre></div></div>
11579</li>
11580<li>
11581
11582<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
11583</li>
11584<li>Arguments:
11585<ul>
11586
11587<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11588</ul>
11589</li>
11590<li>Return Value:
11591<ul>
11592
11593<li><tt>missing</tt> if
11594<ul>
11595
11596<li>any argument is a <tt>missing</tt> value, or</li>
11597<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
11598</ul>
11599</li>
11600<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11601<li>a value of the first argument otherwise</li>
11602</ul>
11603</li>
11604<li>
11605
11606<p>Example:</p>
11607
11608<div>
11609<div>
11610<pre class="source">{
11611 &quot;a&quot;: missing_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)
11612 &quot;b&quot;: missing_if(1, 2),
11613};
11614</pre></div></div>
11615</li>
11616<li>
11617
11618<p>The expected result is:</p>
11619
11620<div>
11621<div>
11622<pre class="source">{ &quot;b&quot;: 1 }
11623</pre></div></div>
11624</li>
11625</ul>
11626<p>The function has an alias <tt>missingif</tt>.</p></div>
11627<div class="section">
11628<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
11629<ul>
11630
11631<li>
11632
11633<p>Syntax:</p>
11634
11635<div>
11636<div>
11637<pre class="source">nan_if(expression1, expression2)
11638</pre></div></div>
11639</li>
11640<li>
11641
11642<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
11643</li>
11644<li>Arguments:
11645<ul>
11646
11647<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11648</ul>
11649</li>
11650<li>Return Value:
11651<ul>
11652
11653<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11654<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11655<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11656<li>a value of the first argument otherwise</li>
11657</ul>
11658</li>
11659<li>
11660
11661<p>Example:</p>
11662
11663<div>
11664<div>
11665<pre class="source">{
11666 &quot;a&quot;: to_string(nan_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11667 &quot;b&quot;: nan_if(1, 2)
11668};
11669</pre></div></div>
11670</li>
11671<li>
11672
11673<p>The expected result is:</p>
11674
11675<div>
11676<div>
11677<pre class="source">{ &quot;a&quot;: &quot;NaN&quot;, &quot;b&quot;: 1 }
11678</pre></div></div>
11679</li>
11680</ul>
11681<p>The function has an alias <tt>nanif</tt>.</p></div>
11682<div class="section">
11683<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
11684<ul>
11685
11686<li>
11687
11688<p>Syntax:</p>
11689
11690<div>
11691<div>
11692<pre class="source">posinf_if(expression1, expression2)
11693</pre></div></div>
11694</li>
11695<li>
11696
11697<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
11698</li>
11699<li>Arguments:
11700<ul>
11701
11702<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11703</ul>
11704</li>
11705<li>Return Value:
11706<ul>
11707
11708<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11709<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11710<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11711<li>a value of the first argument otherwise</li>
11712</ul>
11713</li>
11714<li>
11715
11716<p>Example:</p>
11717
11718<div>
11719<div>
11720<pre class="source">{
11721 &quot;a&quot;: to_string(posinf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11722 &quot;b&quot;: posinf_if(1, 2)
11723};
11724</pre></div></div>
11725</li>
11726<li>
11727
11728<p>The expected result is:</p>
11729
11730<div>
11731<div>
11732<pre class="source">{ &quot;a&quot;: &quot;+INF&quot;, &quot;b&quot;: 1 }
11733</pre></div></div>
11734</li>
11735</ul>
11736<p>The function has an alias <tt>posinfif</tt>.</p></div>
11737<div class="section">
11738<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
11739<ul>
11740
11741<li>
11742
11743<p>Syntax:</p>
11744
11745<div>
11746<div>
11747<pre class="source">neginf_if(expression1, expression2)
11748</pre></div></div>
11749</li>
11750<li>
11751
11752<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
11753</li>
11754<li>Arguments:
11755<ul>
11756
11757<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11758</ul>
11759</li>
11760<li>Return Value:
11761<ul>
11762
11763<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11764<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11765<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11766<li>a value of the first argument otherwise</li>
11767</ul>
11768</li>
11769<li>
11770
11771<p>Example:</p>
11772
11773<div>
11774<div>
11775<pre class="source">{
11776 &quot;a&quot;: to_string(neginf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11777 &quot;b&quot;: neginf_if(1, 2)
11778};
11779</pre></div></div>
11780</li>
11781<li>
11782
11783<p>The expected result is:</p>
11784
11785<div>
11786<div>
11787<pre class="source">{ &quot;a&quot;: &quot;-INF&quot;, &quot;b&quot;: 1 }
11788</pre></div></div>
11789</li>
11790</ul>
11791<p>The function has an alias <tt>neginfif</tt>.</p><!--
11792 ! Licensed to the Apache Software Foundation (ASF) under one
11793 ! or more contributor license agreements. See the NOTICE file
11794 ! distributed with this work for additional information
11795 ! regarding copyright ownership. The ASF licenses this file
11796 ! to you under the Apache License, Version 2.0 (the
11797 ! "License"); you may not use this file except in compliance
11798 ! with the License. You may obtain a copy of the License at
11799 !
11800 ! http://www.apache.org/licenses/LICENSE-2.0
11801 !
11802 ! Unless required by applicable law or agreed to in writing,
11803 ! software distributed under the License is distributed on an
11804 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11805 ! KIND, either express or implied. See the License for the
11806 ! specific language governing permissions and limitations
11807 ! under the License.
11808 !-->
11809</div></div>
11810<div class="section">
11811<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
11812<div class="section">
11813<h3><a name="uuid"></a>uuid</h3>
11814<ul>
11815
11816<li>
11817
11818<p>Syntax:</p>
11819
11820<div>
11821<div>
11822<pre class="source">uuid()
11823</pre></div></div>
11824</li>
11825<li>
11826
11827<p>Generates a <tt>uuid</tt>.</p>
11828</li>
11829<li>Arguments:
11830<ul>
11831
11832<li>none</li>
11833</ul>
11834</li>
11835<li>Return Value:
11836<ul>
11837
11838<li>a generated, random <tt>uuid</tt>.</li>
11839</ul>
11840</li>
11841</ul></div>
11842<div class="section">
11843<h3><a name="len"></a>len</h3>
11844<ul>
11845
11846<li>
11847
11848<p>Syntax:</p>
11849<p>len(array)</p>
11850</li>
11851<li>
11852
11853<p>Returns the length of the array array.</p>
11854</li>
11855<li>Arguments:
11856<ul>
11857
11858<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>
11859</ul>
11860</li>
11861<li>Return Value:
11862<ul>
11863
11864<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
11865<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11866<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11867</ul>
11868</li>
11869<li>
11870
11871<p>Example:</p>
11872
11873<div>
11874<div>
11875<pre class="source">len([&quot;Hello&quot;, &quot;World&quot;])
11876</pre></div></div>
11877</li>
11878<li>
11879
11880<p>The expected result is:</p>
11881
11882<div>
11883<div>
11884<pre class="source">2
11885</pre></div></div>
11886</li>
11887</ul></div>
11888<div class="section">
11889<h3><a name="not"></a>not</h3>
11890<ul>
11891
11892<li>
11893
11894<p>Syntax:</p>
11895
11896<div>
11897<div>
11898<pre class="source">not(expr)
11899</pre></div></div>
11900</li>
11901<li>
11902
11903<p>Inverts a <tt>boolean</tt> value</p>
11904</li>
11905<li>Arguments:
11906<ul>
11907
11908<li><tt>expr</tt> : an expression</li>
11909</ul>
11910</li>
11911<li>Return Value:
11912<ul>
11913
11914<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
11915<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11916<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
11917<li>other non-boolean argument value will cause a type error.</li>
11918</ul>
11919</li>
11920<li>Example:
11921
11922<div>
11923<div>
11924<pre class="source">{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
11925</pre></div></div>
11926</li>
11927<li>
11928
11929<p>The expected result is:</p>
11930
11931<div>
11932<div>
11933<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
11934</pre></div></div>
11935</li>
11936</ul></div>
11937<div class="section">
11938<h3><a name="random"></a>random</h3>
11939<ul>
11940
11941<li>
11942
11943<p>Syntax:</p>
11944
11945<div>
11946<div>
11947<pre class="source">random( [seed_value] )
11948</pre></div></div>
11949</li>
11950<li>
11951
11952<p>Returns a random number, accepting an optional seed value</p>
11953</li>
11954<li>Arguments:
11955<ul>
11956
11957<li><tt>seed_value</tt>: an optional <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value representing the seed number.</li>
11958</ul>
11959</li>
11960<li>Return Value:
11961<ul>
11962
11963<li>A random number of type <tt>double</tt> between 0 and 1,</li>
11964<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
11965<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
11966</ul>
11967</li>
11968<li>
11969
11970<p>Example:</p>
11971
11972<div>
11973<div>
11974<pre class="source">{
11975 &quot;v1&quot;: random(),
11976 &quot;v2&quot;: random(unix_time_from_datetime_in_ms(current_datetime()))
11977};
11978</pre></div></div>
11979</li>
11980</ul></div>
11981<div class="section">
11982<h3><a name="range"></a>range</h3>
11983<ul>
11984
11985<li>
11986
11987<p>Syntax:</p>
11988
11989<div>
11990<div>
11991<pre class="source">range(start_numeric_value, end_numeric_value)
11992</pre></div></div>
11993</li>
11994<li>
11995
11996<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>
11997</li>
11998<li>Arguments:</li>
11999<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>
12000<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>
12001<li>Return Value:
12002<ul>
12003
12004<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>
12005</ul>
12006</li>
12007<li>Example:
12008
12009<div>
12010<div>
12011<pre class="source">range(0, 3);
12012</pre></div></div>
12013</li>
12014<li>
12015
12016<p>The expected result is:</p>
12017
12018<div>
12019<div>
12020<pre class="source">[ 0, 1, 2, 3 ]
12021</pre></div></div>
12022</li>
12023</ul></div>
12024<div class="section">
12025<h3><a name="switch_case"></a>switch_case</h3>
12026<ul>
12027
12028<li>
12029
12030<p>Syntax:</p>
12031
12032<div>
12033<div>
12034<pre class="source">switch_case(
12035 condition,
12036 case1, case1_result,
12037 case2, case2_result,
12038 ...,
12039 default, default_result
12040)
12041</pre></div></div>
12042</li>
12043<li>
12044
12045<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>
12046</li>
12047<li>Arguments:
12048<ul>
12049
12050<li><tt>condition</tt>: a variable (any type is allowed).</li>
12051<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
12052<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
12053</ul>
12054</li>
12055<li>Return Value:
12056<ul>
12057
12058<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
12059</ul>
12060</li>
12061<li>Example 1:
12062
12063<div>
12064<div>
12065<pre class="source">switch_case(
12066 &quot;a&quot;,
12067 &quot;a&quot;, 0,
12068 &quot;x&quot;, 1,
12069 &quot;y&quot;, 2,
12070 &quot;z&quot;, 3
12071);
12072</pre></div></div>
12073</li>
12074<li>
12075
12076<p>The expected result is:</p>
12077
12078<div>
12079<div>
12080<pre class="source">0
12081</pre></div></div>
12082</li>
12083<li>
12084
12085<p>Example 2:</p>
12086
12087<div>
12088<div>
12089<pre class="source">switch_case(
12090 &quot;a&quot;,
12091 &quot;x&quot;, 1,
12092 &quot;y&quot;, 2,
12093 &quot;z&quot;, 3
12094);
12095</pre></div></div>
12096</li>
12097<li>
12098
12099<p>The expected result is:</p>
12100
12101<div>
12102<div>
12103<pre class="source">3
12104</pre></div></div>
12105</li>
12106</ul></div>
12107<div class="section">
12108<h3><a name="deep_equal"></a>deep_equal</h3>
12109<ul>
12110
12111<li>
12112
12113<p>Syntax:</p>
12114
12115<div>
12116<div>
12117<pre class="source">deep_equal(expr1, expr2)
12118</pre></div></div>
12119</li>
12120<li>
12121
12122<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>
12123</li>
12124<li>Arguments:
12125<ul>
12126
12127<li><tt>expr1</tt> : an expression,</li>
12128<li><tt>expr2</tt> : an expression.</li>
12129</ul>
12130</li>
12131<li>Return Value:
12132<ul>
12133
12134<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
12135<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
12136<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
12137</ul>
12138</li>
12139<li>
12140
12141<p>Example:</p>
12142
12143<div>
12144<div>
12145<pre class="source">deep_equal(
12146 {
12147 &quot;id&quot;:1,
12148 &quot;project&quot;:&quot;AsterixDB&quot;,
12149 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
12150 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12151 },
12152 {
12153 &quot;id&quot;:1,
12154 &quot;project&quot;:&quot;AsterixDB&quot;,
12155 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
12156 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12157 }
12158);
12159</pre></div></div>
12160</li>
12161<li>
12162
12163<p>The expected result is:</p>
12164
12165<div>
12166<div>
12167<pre class="source">false
12168</pre></div></div>
12169</li>
12170</ul></div></div>
12171 </div>
12172 </div>
12173 </div>
12174 <hr/>
12175 <footer>
12176 <div class="container-fluid">
12177 <div class="row-fluid">
12178<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
12179 feather logo, and the Apache AsterixDB project logo are either
12180 registered trademarks or trademarks of The Apache Software
12181 Foundation in the United States and other countries.
12182 All other marks mentioned may be trademarks or registered
12183 trademarks of their respective owners.
12184 </div>
12185 </div>
12186 </div>
12187 </footer>
12188 </body>
12189</html>