blob: 50312ab3b6deca2909187105e0c40d4128d6cecb [file] [log] [blame]
Ian Maxona1cc51b2020-08-07 13:11:35 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/aql/builtins.md at 2020-08-07
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="20200807" />
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: 2020-08-07</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.5</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/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
49 <li class="nav-header">API/SDK</li>
50 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
51 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
52 <li class="nav-header">Advanced Features</li>
53 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
54 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
55 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
56 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
57 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
58 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
59 <li class="nav-header">Deprecated</li>
60 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
61 <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>
62 <li class="active"><a href="#"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
63</ul>
64 <hr />
65 <div id="poweredBy">
66 <div class="clear"></div>
67 <div class="clear"></div>
68 <div class="clear"></div>
69 <div class="clear"></div>
70<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
71 </div>
72 </div>
73 </div>
74 <div id="bodyColumn" class="span10" >
75<!--
76 ! Licensed to the Apache Software Foundation (ASF) under one
77 ! or more contributor license agreements. See the NOTICE file
78 ! distributed with this work for additional information
79 ! regarding copyright ownership. The ASF licenses this file
80 ! to you under the Apache License, Version 2.0 (the
81 ! "License"); you may not use this file except in compliance
82 ! with the License. You may obtain a copy of the License at
83 !
84 ! http://www.apache.org/licenses/LICENSE-2.0
85 !
86 ! Unless required by applicable law or agreed to in writing,
87 ! software distributed under the License is distributed on an
88 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
89 ! KIND, either express or implied. See the License for the
90 ! specific language governing permissions and limitations
91 ! under the License.
92 !-->
93<h1>Builtin Functions</h1><!--
94 ! Licensed to the Apache Software Foundation (ASF) under one
95 ! or more contributor license agreements. See the NOTICE file
96 ! distributed with this work for additional information
97 ! regarding copyright ownership. The ASF licenses this file
98 ! to you under the Apache License, Version 2.0 (the
99 ! "License"); you may not use this file except in compliance
100 ! with the License. You may obtain a copy of the License at
101 !
102 ! http://www.apache.org/licenses/LICENSE-2.0
103 !
104 ! Unless required by applicable law or agreed to in writing,
105 ! software distributed under the License is distributed on an
106 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
107 ! KIND, either express or implied. See the License for the
108 ! specific language governing permissions and limitations
109 ! under the License.
110 !-->
111
112<div class="section">
113<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
114<ul>
115
116<li><a href="#NumericFunctions">Numeric Functions</a></li>
117<li><a href="#StringFunctions">String Functions</a></li>
118<li><a href="#BinaryFunctions">Binary Functions</a></li>
119<li><a href="#SpatialFunctions">Spatial Functions</a></li>
120<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
121<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
122<li><a href="#TemporalFunctions">Temporal Functions</a></li>
123<li><a href="#ObjectFunctions">Object Functions</a></li>
124<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
125<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
126<li><a href="#TypeFunctions">Type Functions</a></li>
127<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
128<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
129</ul><!--
130 ! Licensed to the Apache Software Foundation (ASF) under one
131 ! or more contributor license agreements. See the NOTICE file
132 ! distributed with this work for additional information
133 ! regarding copyright ownership. The ASF licenses this file
134 ! to you under the Apache License, Version 2.0 (the
135 ! "License"); you may not use this file except in compliance
136 ! with the License. You may obtain a copy of the License at
137 !
138 ! http://www.apache.org/licenses/LICENSE-2.0
139 !
140 ! Unless required by applicable law or agreed to in writing,
141 ! software distributed under the License is distributed on an
142 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
143 ! KIND, either express or implied. See the License for the
144 ! specific language governing permissions and limitations
145 ! under the License.
146 !-->
147
148<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><!--
149 ! Licensed to the Apache Software Foundation (ASF) under one
150 ! or more contributor license agreements. See the NOTICE file
151 ! distributed with this work for additional information
152 ! regarding copyright ownership. The ASF licenses this file
153 ! to you under the Apache License, Version 2.0 (the
154 ! "License"); you may not use this file except in compliance
155 ! with the License. You may obtain a copy of the License at
156 !
157 ! http://www.apache.org/licenses/LICENSE-2.0
158 !
159 ! Unless required by applicable law or agreed to in writing,
160 ! software distributed under the License is distributed on an
161 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162 ! KIND, either express or implied. See the License for the
163 ! specific language governing permissions and limitations
164 ! under the License.
165 !-->
166</div>
167<div class="section">
168<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
169<div class="section">
170<h3><a name="abs"></a>abs</h3>
171<ul>
172
173<li>
174
175<p>Syntax:</p>
176
177<div>
178<div>
179<pre class="source">abs(numeric_value)
180</pre></div></div>
181</li>
182<li>
183
184<p>Computes the absolute value of the argument.</p>
185</li>
186<li>Arguments:
187<ul>
188
189<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>
190</ul>
191</li>
192<li>Return Value:
193<ul>
194
195<li>The absolute value of the argument with the same type as the input argument,</li>
196<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
197<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
198<li>any other non-numeric input value will cause a type error.</li>
199</ul>
200</li>
201<li>
202
203<p>Example:</p>
204
205<div>
206<div>
207<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;)) };
208</pre></div></div>
209</li>
210<li>
211
212<p>The expected result is:</p>
213
214<div>
215<div>
216<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 }
217</pre></div></div>
218</li>
219</ul></div>
220<div class="section">
221<h3><a name="acos"></a>acos</h3>
222<ul>
223
224<li>
225
226<p>Syntax:</p>
227
228<div>
229<div>
230<pre class="source">acos(numeric_value)
231</pre></div></div>
232</li>
233<li>
234
235<p>Computes the arc cosine value of the argument.</p>
236</li>
237<li>Arguments:
238<ul>
239
240<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>
241</ul>
242</li>
243<li>Return Value:
244<ul>
245
246<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>
247<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
248<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
249<li>any other non-numeric input value will cause a type error,</li>
250<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
251</ul>
252</li>
253<li>
254
255<p>Example:</p>
256
257<div>
258<div>
259<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;)) };
260</pre></div></div>
261</li>
262<li>
263
264<p>The expected result is:</p>
265
266<div>
267<div>
268<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 }
269</pre></div></div>
270</li>
271</ul></div>
272<div class="section">
273<h3><a name="asin"></a>asin</h3>
274<ul>
275
276<li>
277
278<p>Syntax:</p>
279
280<div>
281<div>
282<pre class="source">asin(numeric_value)
283</pre></div></div>
284</li>
285<li>
286
287<p>Computes the arc sine value of the argument.</p>
288</li>
289<li>Arguments:
290<ul>
291
292<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>
293</ul>
294</li>
295<li>Return Value:
296<ul>
297
298<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>
299<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
300<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
301<li>any other non-numeric input value will cause a type error,</li>
302<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
303</ul>
304</li>
305<li>
306
307<p>Example:</p>
308
309<div>
310<div>
311<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;)) };
312</pre></div></div>
313</li>
314<li>
315
316<p>The expected result is:</p>
317
318<div>
319<div>
320<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 }
321</pre></div></div>
322</li>
323</ul></div>
324<div class="section">
325<h3><a name="atan"></a>atan</h3>
326<ul>
327
328<li>
329
330<p>Syntax:</p>
331
332<div>
333<div>
334<pre class="source">atan(numeric_value)
335</pre></div></div>
336</li>
337<li>
338
339<p>Computes the arc tangent value of the argument.</p>
340</li>
341<li>Arguments:
342<ul>
343
344<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>
345</ul>
346</li>
347<li>Return Value:
348<ul>
349
350<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
351<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
352<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
353<li>any other non-numeric input value will cause a type error.</li>
354</ul>
355</li>
356<li>
357
358<p>Example:</p>
359
360<div>
361<div>
362<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;)) };
363</pre></div></div>
364</li>
365<li>
366
367<p>The expected result is:</p>
368
369<div>
370<div>
371<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 }
372</pre></div></div>
373</li>
374</ul></div>
375<div class="section">
376<h3><a name="atan2"></a>atan2</h3>
377<ul>
378
379<li>
380
381<p>Syntax:</p>
382
383<div>
384<div>
385<pre class="source">atan2(numeric_value1, numeric_value2)
386</pre></div></div>
387</li>
388<li>
389
390<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
391</li>
392<li>Arguments:
393<ul>
394
395<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>
396<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>
397</ul>
398</li>
399<li>Return Value:
400<ul>
401
402<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
403<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
404<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
405<li>any other non-numeric input value will cause a type error.</li>
406</ul>
407</li>
408<li>
409
410<p>Example:</p>
411
412<div>
413<div>
414<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;)) };
415</pre></div></div>
416</li>
417<li>
418
419<p>The expected result is:</p>
420
421<div>
422<div>
423<pre class="source">{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
424</pre></div></div>
425</li>
426</ul></div>
427<div class="section">
428<h3><a name="ceil"></a>ceil</h3>
429<ul>
430
431<li>
432
433<p>Syntax:</p>
434
435<div>
436<div>
437<pre class="source">ceil(numeric_value)
438</pre></div></div>
439</li>
440<li>
441
442<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>
443</li>
444<li>Arguments:
445<ul>
446
447<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>
448</ul>
449</li>
450<li>Return Value:
451<ul>
452
453<li>The ceiling value for the given number in the same type as the input argument,</li>
454<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
455<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
456<li>any other non-numeric input value will cause a type error.</li>
457</ul>
458</li>
459<li>
460
461<p>Example:</p>
462
463<div>
464<div>
465<pre class="source">{
466 &quot;v1&quot;: ceil(2013),
467 &quot;v2&quot;: ceil(-4036),
468 &quot;v3&quot;: ceil(0.3),
469 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
470 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
471};
472</pre></div></div>
473</li>
474<li>
475
476<p>The expected result is:</p>
477
478<div>
479<div>
480<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 }
481</pre></div></div>
482</li>
483</ul></div>
484<div class="section">
485<h3><a name="cos"></a>cos</h3>
486<ul>
487
488<li>
489
490<p>Syntax:</p>
491
492<div>
493<div>
494<pre class="source">cos(numeric_value)
495</pre></div></div>
496</li>
497<li>
498
499<p>Computes the cosine value of the argument.</p>
500</li>
501<li>Arguments:
502<ul>
503
504<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>
505</ul>
506</li>
507<li>Return Value:
508<ul>
509
510<li>the <tt>double</tt> cosine value for the argument,</li>
511<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
512<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
513<li>any other non-numeric input value will cause a type error.</li>
514</ul>
515</li>
516<li>
517
518<p>Example:</p>
519
520<div>
521<div>
522<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;)) };
523</pre></div></div>
524</li>
525<li>
526
527<p>The expected result is:</p>
528
529<div>
530<div>
531<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 }
532</pre></div></div>
533</li>
534</ul></div>
535<div class="section">
536<h3><a name="cosh"></a>cosh</h3>
537<ul>
538
539<li>
540
541<p>Syntax:</p>
542
543<div>
544<div>
545<pre class="source">cosh(numeric_value)
546</pre></div></div>
547</li>
548<li>
549
550<p>Computes the hyperbolic cosine value of the argument.</p>
551</li>
552<li>Arguments:
553<ul>
554
555<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>
556</ul>
557</li>
558<li>Return Value:
559<ul>
560
561<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
562<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
563<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
564<li>any other non-numeric input value will cause a type error.</li>
565</ul>
566</li>
567<li>
568
569<p>Example:</p>
570
571<div>
572<div>
573<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;)) };
574</pre></div></div>
575</li>
576<li>
577
578<p>The expected result is:</p>
579
580<div>
581<div>
582<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 }
583</pre></div></div>
584</li>
585</ul></div>
586<div class="section">
587<h3><a name="degrees"></a>degrees</h3>
588<ul>
589
590<li>
591
592<p>Syntax:</p>
593
594<div>
595<div>
596<pre class="source">degrees(numeric_value)
597</pre></div></div>
598</li>
599<li>
600
601<p>Converts radians to degrees</p>
602</li>
603<li>Arguments:
604<ul>
605
606<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>
607</ul>
608</li>
609<li>Return Value:
610<ul>
611
612<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
613<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
614<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
615<li>any other non-numeric input value will cause a type error.</li>
616</ul>
617</li>
618<li>
619
620<p>Example:</p>
621
622<div>
623<div>
624<pre class="source">{ &quot;v1&quot;: degrees(pi()) };
625</pre></div></div>
626</li>
627<li>
628
629<p>The expected result is:</p>
630
631<div>
632<div>
633<pre class="source">{ &quot;v1&quot;: 180.0 }
634</pre></div></div>
635</li>
636</ul></div>
637<div class="section">
638<h3><a name="e"></a>e</h3>
639<ul>
640
641<li>
642
643<p>Syntax:</p>
644
645<div>
646<div>
647<pre class="source">e()
648</pre></div></div>
649</li>
650<li>
651
652<p>Return Value:</p>
653<ul>
654
655<li>e (base of the natural logarithm)</li>
656</ul>
657</li>
658<li>
659
660<p>Example:</p>
661
662<div>
663<div>
664<pre class="source">{ &quot;v1&quot;: e() };
665</pre></div></div>
666</li>
667<li>
668
669<p>The expected result is:</p>
670
671<div>
672<div>
673<pre class="source">{ &quot;v1&quot;: 2.718281828459045 }
674</pre></div></div>
675</li>
676</ul></div>
677<div class="section">
678<h3><a name="exp"></a>exp</h3>
679<ul>
680
681<li>
682
683<p>Syntax:</p>
684
685<div>
686<div>
687<pre class="source">exp(numeric_value)
688</pre></div></div>
689</li>
690<li>
691
692<p>Computes e<sup>numeric_value</sup>.</p>
693</li>
694<li>Arguments:
695<ul>
696
697<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>
698</ul>
699</li>
700<li>Return Value:
701<ul>
702
703<li>e<sup>numeric_value</sup>,</li>
704<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
705<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
706<li>any other non-numeric input value will cause a type error.</li>
707</ul>
708</li>
709<li>
710
711<p>Example:</p>
712
713<div>
714<div>
715<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;)) };
716</pre></div></div>
717</li>
718<li>
719
720<p>The expected result is:</p>
721
722<div>
723<div>
724<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; }
725</pre></div></div>
726</li>
727</ul></div>
728<div class="section">
729<h3><a name="floor"></a>floor</h3>
730<ul>
731
732<li>
733
734<p>Syntax:</p>
735
736<div>
737<div>
738<pre class="source">floor(numeric_value)
739</pre></div></div>
740</li>
741<li>
742
743<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>
744</li>
745<li>Arguments:
746<ul>
747
748<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>
749</ul>
750</li>
751<li>Return Value:
752<ul>
753
754<li>The floor value for the given number in the same type as the input argument,</li>
755<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
756<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
757<li>any other non-numeric input value will cause a type error.</li>
758</ul>
759</li>
760<li>
761
762<p>Example:</p>
763
764<div>
765<div>
766<pre class="source">{
767 &quot;v1&quot;: floor(2013),
768 &quot;v2&quot;: floor(-4036),
769 &quot;v3&quot;: floor(0.8),
770 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
771 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
772};
773</pre></div></div>
774</li>
775<li>
776
777<p>The expected result is:</p>
778
779<div>
780<div>
781<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 }
782</pre></div></div>
783</li>
784</ul></div>
785<div class="section">
786<h3><a name="ln"></a>ln</h3>
787<ul>
788
789<li>
790
791<p>Syntax:</p>
792
793<div>
794<div>
795<pre class="source">ln(numeric_value)
796</pre></div></div>
797</li>
798<li>
799
800<p>Computes log<sub>e</sub>numeric_value.</p>
801</li>
802<li>Arguments:
803<ul>
804
805<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>
806</ul>
807</li>
808<li>Return Value:
809<ul>
810
811<li>log<sub>e</sub>numeric_value,</li>
812<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
813<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
814<li>any other non-numeric input value will cause a type error.</li>
815</ul>
816</li>
817<li>
818
819<p>Example:</p>
820
821<div>
822<div>
823<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;)) };
824</pre></div></div>
825</li>
826<li>
827
828<p>The expected result is:</p>
829
830<div>
831<div>
832<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 }
833</pre></div></div>
834</li>
835</ul></div>
836<div class="section">
837<h3><a name="log"></a>log</h3>
838<ul>
839
840<li>
841
842<p>Syntax:</p>
843
844<div>
845<div>
846<pre class="source">log(numeric_value)
847</pre></div></div>
848</li>
849<li>
850
851<p>Computes log<sub>10</sub>numeric_value.</p>
852</li>
853<li>Arguments:
854<ul>
855
856<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>
857</ul>
858</li>
859<li>Return Value:
860<ul>
861
862<li>log<sub>10</sub>numeric_value,</li>
863<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
864<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
865<li>any other non-numeric input value will cause a type error.</li>
866</ul>
867</li>
868<li>
869
870<p>Example:</p>
871
872<div>
873<div>
874<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;)) };
875</pre></div></div>
876</li>
877<li>
878
879<p>The expected result is:</p>
880
881<div>
882<div>
883<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 }
884</pre></div></div>
885</li>
886</ul></div>
887<div class="section">
888<h3><a name="pi"></a>pi</h3>
889<ul>
890
891<li>
892
893<p>Syntax:</p>
894
895<div>
896<div>
897<pre class="source">pi()
898</pre></div></div>
899</li>
900<li>
901
902<p>Return Value:</p>
903<ul>
904
905<li>Pi</li>
906</ul>
907</li>
908<li>
909
910<p>Example:</p>
911
912<div>
913<div>
914<pre class="source">{ &quot;v1&quot;: pi() };
915</pre></div></div>
916</li>
917<li>
918
919<p>The expected result is:</p>
920
921<div>
922<div>
923<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
924</pre></div></div>
925</li>
926</ul></div>
927<div class="section">
928<h3><a name="power"></a>power</h3>
929<ul>
930
931<li>
932
933<p>Syntax:</p>
934
935<div>
936<div>
937<pre class="source">power(numeric_value1, numeric_value2)
938</pre></div></div>
939</li>
940<li>
941
942<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
943</li>
944<li>Arguments:
945<ul>
946
947<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>
948<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>
949</ul>
950</li>
951<li>Return Value:
952<ul>
953
954<li>numeric_value1<sup>numeric_value2</sup>,</li>
955<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
956<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
957<li>any other non-numeric input value will cause a type error.</li>
958</ul>
959</li>
960<li>
961
962<p>Example:</p>
963
964<div>
965<div>
966<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;)) };
967</pre></div></div>
968</li>
969<li>
970
971<p>The expected result is:</p>
972
973<div>
974<div>
975<pre class="source">{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
976</pre></div></div>
977</li>
978</ul></div>
979<div class="section">
980<h3><a name="radians"></a>radians</h3>
981<ul>
982
983<li>
984
985<p>Syntax:</p>
986
987<div>
988<div>
989<pre class="source">radians(numeric_value)
990</pre></div></div>
991</li>
992<li>
993
994<p>Converts degrees to radians</p>
995</li>
996<li>Arguments:
997<ul>
998
999<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>
1000</ul>
1001</li>
1002<li>Return Value:
1003<ul>
1004
1005<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
1006<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1007<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1008<li>any other non-numeric input value will cause a type error.</li>
1009</ul>
1010</li>
1011<li>
1012
1013<p>Example:</p>
1014
1015<div>
1016<div>
1017<pre class="source">{ &quot;v1&quot;: radians(180) };
1018</pre></div></div>
1019</li>
1020<li>
1021
1022<p>The expected result is:</p>
1023
1024<div>
1025<div>
1026<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
1027</pre></div></div>
1028</li>
1029</ul></div>
1030<div class="section">
1031<h3><a name="round"></a>round</h3>
1032<ul>
1033
1034<li>
1035
1036<p>Syntax:</p>
1037
1038<div>
1039<div>
1040<pre class="source">round(numeric_value[, round_digit])
1041</pre></div></div>
1042</li>
1043<li>
1044
1045<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>
1046</li>
1047<li>
1048
1049<p>Arguments:</p>
1050<ul>
1051
1052<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>
1053<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>
1054</ul>
1055</li>
1056<li>Return Value:
1057<ul>
1058
1059<li>The rounded value for the given number. The returned value has the following type:
1060<ul>
1061
1062<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
1063<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
1064<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
1065</ul>
1066</li>
1067<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
1068<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
1069<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
1070</ul>
1071</li>
1072<li>
1073
1074<p>Example:</p>
1075
1076<div>
1077<div>
1078<pre class="source">{
1079 &quot;v1&quot;: round(2013),
1080 &quot;v2&quot;: round(-4036),
1081 &quot;v3&quot;: round(0.8),
1082 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1083 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1084 &quot;v6&quot;: round(123456, -1),
1085 &quot;v7&quot;: round(456.456, 2),
1086 &quot;v8&quot;: round(456.456, -1),
1087 &quot;v9&quot;: round(-456.456, -2)
1088};
1089</pre></div></div>
1090</li>
1091<li>
1092
1093<p>The expected result is:</p>
1094
1095<div>
1096<div>
1097<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 }
1098</pre></div></div>
1099</li>
1100</ul></div>
1101<div class="section">
1102<h3><a name="sign"></a>sign</h3>
1103<ul>
1104
1105<li>
1106
1107<p>Syntax:</p>
1108
1109<div>
1110<div>
1111<pre class="source">sign(numeric_value)
1112</pre></div></div>
1113</li>
1114<li>
1115
1116<p>Computes the sign of the argument.</p>
1117</li>
1118<li>Arguments:
1119<ul>
1120
1121<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>
1122</ul>
1123</li>
1124<li>Return Value:
1125<ul>
1126
1127<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1128<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1129<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1130<li>any other non-numeric input value will cause a type error.</li>
1131</ul>
1132</li>
1133<li>
1134
1135<p>Example:</p>
1136
1137<div>
1138<div>
1139<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;)) };
1140</pre></div></div>
1141</li>
1142<li>
1143
1144<p>The expected result is:</p>
1145
1146<div>
1147<div>
1148<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1149</pre></div></div>
1150</li>
1151</ul></div>
1152<div class="section">
1153<h3><a name="sin"></a>sin</h3>
1154<ul>
1155
1156<li>
1157
1158<p>Syntax:</p>
1159
1160<div>
1161<div>
1162<pre class="source">sin(numeric_value)
1163</pre></div></div>
1164</li>
1165<li>
1166
1167<p>Computes the sine value of the argument.</p>
1168</li>
1169<li>Arguments:
1170<ul>
1171
1172<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>
1173</ul>
1174</li>
1175<li>Return Value:
1176<ul>
1177
1178<li>the <tt>double</tt> sine value for the argument,</li>
1179<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1180<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1181<li>any other non-numeric input value will cause a type error.</li>
1182</ul>
1183</li>
1184<li>
1185
1186<p>Example:</p>
1187
1188<div>
1189<div>
1190<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;)) };
1191</pre></div></div>
1192</li>
1193<li>
1194
1195<p>The expected result is:</p>
1196
1197<div>
1198<div>
1199<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 }
1200</pre></div></div>
1201</li>
1202</ul></div>
1203<div class="section">
1204<h3><a name="sinh"></a>sinh</h3>
1205<ul>
1206
1207<li>
1208
1209<p>Syntax:</p>
1210
1211<div>
1212<div>
1213<pre class="source">sinh(numeric_value)
1214</pre></div></div>
1215</li>
1216<li>
1217
1218<p>Computes the hyperbolic sine value of the argument.</p>
1219</li>
1220<li>Arguments:
1221<ul>
1222
1223<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1224</ul>
1225</li>
1226<li>Return Value:
1227<ul>
1228
1229<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
1230<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1231<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1232<li>any other non-numeric input value will cause a type error.</li>
1233</ul>
1234</li>
1235<li>
1236
1237<p>Example:</p>
1238
1239<div>
1240<div>
1241<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;)) };
1242</pre></div></div>
1243</li>
1244<li>
1245
1246<p>The expected result is:</p>
1247
1248<div>
1249<div>
1250<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 }
1251</pre></div></div>
1252</li>
1253</ul></div>
1254<div class="section">
1255<h3><a name="sqrt"></a>sqrt</h3>
1256<ul>
1257
1258<li>
1259
1260<p>Syntax:</p>
1261
1262<div>
1263<div>
1264<pre class="source">sqrt(numeric_value)
1265</pre></div></div>
1266</li>
1267<li>
1268
1269<p>Computes the square root of the argument.</p>
1270</li>
1271<li>Arguments:
1272<ul>
1273
1274<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>
1275</ul>
1276</li>
1277<li>Return Value:
1278<ul>
1279
1280<li>the <tt>double</tt> square root value for the argument,</li>
1281<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1282<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1283<li>any other non-numeric input value will cause a type error.</li>
1284</ul>
1285</li>
1286<li>
1287
1288<p>Example:</p>
1289
1290<div>
1291<div>
1292<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;)) };
1293</pre></div></div>
1294</li>
1295<li>
1296
1297<p>The expected result is:</p>
1298
1299<div>
1300<div>
1301<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 }
1302</pre></div></div>
1303</li>
1304</ul></div>
1305<div class="section">
1306<h3><a name="tan"></a>tan</h3>
1307<ul>
1308
1309<li>
1310
1311<p>Syntax:</p>
1312
1313<div>
1314<div>
1315<pre class="source">tan(numeric_value)
1316</pre></div></div>
1317</li>
1318<li>
1319
1320<p>Computes the tangent value of the argument.</p>
1321</li>
1322<li>Arguments:
1323<ul>
1324
1325<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>
1326</ul>
1327</li>
1328<li>Return Value:
1329<ul>
1330
1331<li>the <tt>double</tt> tangent value for the argument,</li>
1332<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1333<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1334<li>any other non-numeric input value will cause a type error.</li>
1335</ul>
1336</li>
1337<li>
1338
1339<p>Example:</p>
1340
1341<div>
1342<div>
1343<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;)) };
1344</pre></div></div>
1345</li>
1346<li>
1347
1348<p>The expected result is:</p>
1349
1350<div>
1351<div>
1352<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 }
1353</pre></div></div>
1354</li>
1355</ul></div>
1356<div class="section">
1357<h3><a name="tanh"></a>tanh</h3>
1358<ul>
1359
1360<li>
1361
1362<p>Syntax:</p>
1363
1364<div>
1365<div>
1366<pre class="source">tanh(numeric_value)
1367</pre></div></div>
1368</li>
1369<li>
1370
1371<p>Computes the hyperbolic tangent value of the argument.</p>
1372</li>
1373<li>Arguments:
1374<ul>
1375
1376<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>
1377</ul>
1378</li>
1379<li>Return Value:
1380<ul>
1381
1382<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
1383<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1384<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1385<li>any other non-numeric input value will cause a type error.</li>
1386</ul>
1387</li>
1388<li>
1389
1390<p>Example:</p>
1391
1392<div>
1393<div>
1394<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;)) };
1395</pre></div></div>
1396</li>
1397<li>
1398
1399<p>The expected result is:</p>
1400
1401<div>
1402<div>
1403<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 }
1404</pre></div></div>
1405</li>
1406</ul></div>
1407<div class="section">
1408<h3><a name="trunc"></a>trunc</h3>
1409<ul>
1410
1411<li>
1412
1413<p>Syntax:</p>
1414
1415<div>
1416<div>
1417<pre class="source">trunc(numeric_value, number_digits)
1418</pre></div></div>
1419</li>
1420<li>
1421
1422<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>
1423</li>
1424<li>Arguments:
1425<ul>
1426
1427<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>
1428<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1429</ul>
1430</li>
1431<li>Return Value:
1432<ul>
1433
1434<li>the <tt>double</tt> tangent value for the argument,</li>
1435<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1436<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1437<li>a type error will be raised if:
1438<ul>
1439
1440<li>the first argument is any other non-numeric value,</li>
1441<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1442</ul>
1443</li>
1444</ul>
1445</li>
1446<li>
1447
1448<p>Example:</p>
1449
1450<div>
1451<div>
1452<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) };
1453</pre></div></div>
1454</li>
1455<li>
1456
1457<p>The expected result is:</p>
1458
1459<div>
1460<div>
1461<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 }
1462</pre></div></div>
1463</li>
1464</ul><!--
1465 ! Licensed to the Apache Software Foundation (ASF) under one
1466 ! or more contributor license agreements. See the NOTICE file
1467 ! distributed with this work for additional information
1468 ! regarding copyright ownership. The ASF licenses this file
1469 ! to you under the Apache License, Version 2.0 (the
1470 ! "License"); you may not use this file except in compliance
1471 ! with the License. You may obtain a copy of the License at
1472 !
1473 ! http://www.apache.org/licenses/LICENSE-2.0
1474 !
1475 ! Unless required by applicable law or agreed to in writing,
1476 ! software distributed under the License is distributed on an
1477 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1478 ! KIND, either express or implied. See the License for the
1479 ! specific language governing permissions and limitations
1480 ! under the License.
1481 !-->
1482</div>
1483<div class="section">
1484<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1485<ul>
1486
1487<li>
1488
1489<p>Syntax:</p>
1490
1491<div>
1492<div>
1493<pre class="source">round_half_to_even(numeric_value, [precision])
1494</pre></div></div>
1495</li>
1496<li>
1497
1498<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>
1499</li>
1500<li>Arguments:
1501<ul>
1502
1503<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>
1504<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>
1505</ul>
1506</li>
1507<li>Return Value:
1508<ul>
1509
1510<li>The rounded value for the given number in the same type as the input argument,</li>
1511<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1512<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1513<li>a type error will be raised if:
1514<ul>
1515
1516<li>the first argument is any other non-numeric value,</li>
1517<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1518</ul>
1519</li>
1520</ul>
1521</li>
1522<li>
1523
1524<p>Example:</p>
1525
1526<div>
1527<div>
1528<pre class="source">{
1529 &quot;v1&quot;: round_half_to_even(2013),
1530 &quot;v2&quot;: round_half_to_even(-4036),
1531 &quot;v3&quot;: round_half_to_even(0.8),
1532 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1533 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1534 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1535 &quot;v7&quot;: round_half_to_even(2013, 4),
1536 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1537};
1538</pre></div></div>
1539</li>
1540<li>
1541
1542<p>The expected result is:</p>
1543
1544<div>
1545<div>
1546<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 }
1547</pre></div></div>
1548</li>
1549</ul><!--
1550 ! Licensed to the Apache Software Foundation (ASF) under one
1551 ! or more contributor license agreements. See the NOTICE file
1552 ! distributed with this work for additional information
1553 ! regarding copyright ownership. The ASF licenses this file
1554 ! to you under the Apache License, Version 2.0 (the
1555 ! "License"); you may not use this file except in compliance
1556 ! with the License. You may obtain a copy of the License at
1557 !
1558 ! http://www.apache.org/licenses/LICENSE-2.0
1559 !
1560 ! Unless required by applicable law or agreed to in writing,
1561 ! software distributed under the License is distributed on an
1562 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1563 ! KIND, either express or implied. See the License for the
1564 ! specific language governing permissions and limitations
1565 ! under the License.
1566 !-->
1567</div></div>
1568<div class="section">
1569<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1570<div class="section">
1571<h3><a name="concat"></a>concat</h3>
1572<ul>
1573
1574<li>
1575
1576<p>Syntax:</p>
1577
1578<div>
1579<div>
1580<pre class="source">concat(string1, string2, ...)
1581</pre></div></div>
1582</li>
1583<li>
1584
1585<p>Returns a concatenated string from arguments.</p>
1586</li>
1587<li>Arguments:
1588<ul>
1589
1590<li><tt>string1</tt>: a string value,</li>
1591<li><tt>string2</tt>: a string value,</li>
1592<li>&#x2026;.</li>
1593</ul>
1594</li>
1595<li>Return Value:
1596<ul>
1597
1598<li>a concatenated string from arguments,</li>
1599<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1600<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1601<li>any other non-string input value will cause a type error.</li>
1602</ul>
1603</li>
1604<li>
1605
1606<p>Example:</p>
1607
1608<div>
1609<div>
1610<pre class="source">concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1611</pre></div></div>
1612</li>
1613<li>
1614
1615<p>The expected result is:</p>
1616
1617<div>
1618<div>
1619<pre class="source">&quot;test driven development&quot;
1620</pre></div></div>
1621</li>
1622</ul></div>
1623<div class="section">
1624<h3><a name="contains"></a>contains</h3>
1625<ul>
1626
1627<li>
1628
1629<p>Syntax:</p>
1630
1631<div>
1632<div>
1633<pre class="source">contains(string, substring_to_contain)
1634</pre></div></div>
1635</li>
1636<li>
1637
1638<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
1639</li>
1640<li>Arguments:
1641<ul>
1642
1643<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1644<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1645</ul>
1646</li>
1647<li>Return Value:
1648<ul>
1649
1650<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1651<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1652<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1653<li>any other non-string input value will cause a type error,</li>
1654<li><tt>false</tt> otherwise.</li>
1655</ul>
1656</li>
1657<li>
1658
1659<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
1660</li>
1661<li>Example:
1662
1663<div>
1664<div>
1665<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;) };
1666</pre></div></div>
1667</li>
1668<li>
1669
1670<p>The expected result is:</p>
1671
1672<div>
1673<div>
1674<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1675</pre></div></div>
1676</li>
1677</ul></div>
1678<div class="section">
1679<h3><a name="ends_with"></a>ends_with</h3>
1680<ul>
1681
1682<li>
1683
1684<p>Syntax:</p>
1685
1686<div>
1687<div>
1688<pre class="source">ends_with(string, substring_to_end_with)
1689</pre></div></div>
1690</li>
1691<li>
1692
1693<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
1694</li>
1695<li>Arguments:
1696<ul>
1697
1698<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1699<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1700</ul>
1701</li>
1702<li>Return Value:
1703<ul>
1704
1705<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1706<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1707<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1708<li>any other non-string input value will cause a type error,</li>
1709<li><tt>false</tt> otherwise.</li>
1710</ul>
1711</li>
1712<li>
1713
1714<p>Example:</p>
1715
1716<div>
1717<div>
1718<pre class="source">{
1719 &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1720 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1721};
1722</pre></div></div>
1723</li>
1724<li>
1725
1726<p>The expected result is:</p>
1727
1728<div>
1729<div>
1730<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1731</pre></div></div>
1732</li>
1733</ul></div>
1734<div class="section">
1735<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
1736<ul>
1737
1738<li>
1739
1740<p>Syntax:</p>
1741
1742<div>
1743<div>
1744<pre class="source">initcap(string)
1745</pre></div></div>
1746</li>
1747<li>
1748
1749<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>
1750</li>
1751<li>Arguments:
1752<ul>
1753
1754<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1755</ul>
1756</li>
1757<li>Return Value:
1758<ul>
1759
1760<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1761<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1762<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1763<li>any other non-string input value will cause a type error.</li>
1764</ul>
1765</li>
1766<li>
1767
1768<p>Example:</p>
1769
1770<div>
1771<div>
1772<pre class="source">{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1773</pre></div></div>
1774</li>
1775<li>
1776
1777<p>The expected result is:</p>
1778
1779<div>
1780<div>
1781<pre class="source">{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1782</pre></div></div>
1783</li>
1784</ul></div>
1785<div class="section">
1786<h3><a name="length"></a>length</h3>
1787<ul>
1788
1789<li>
1790
1791<p>Syntax:</p>
1792
1793<div>
1794<div>
1795<pre class="source">length(string)
1796</pre></div></div>
1797</li>
1798<li>
1799
1800<p>Returns the length of the string <tt>string</tt>.</p>
1801</li>
1802<li>Arguments:
1803<ul>
1804
1805<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1806</ul>
1807</li>
1808<li>Return Value:
1809<ul>
1810
1811<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1812<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1813<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1814<li>any other non-string input value will cause a type error.</li>
1815</ul>
1816</li>
1817<li>
1818
1819<p>Example:</p>
1820
1821<div>
1822<div>
1823<pre class="source">length(&quot;test string&quot;);
1824</pre></div></div>
1825</li>
1826<li>
1827
1828<p>The expected result is:</p>
1829
1830<div>
1831<div>
1832<pre class="source">11
1833</pre></div></div>
1834</li>
1835</ul></div>
1836<div class="section">
1837<h3><a name="lower"></a>lower</h3>
1838<ul>
1839
1840<li>
1841
1842<p>Syntax:</p>
1843
1844<div>
1845<div>
1846<pre class="source">lower(string)
1847</pre></div></div>
1848</li>
1849<li>
1850
1851<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
1852</li>
1853<li>Arguments:
1854<ul>
1855
1856<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1857</ul>
1858</li>
1859<li>Return Value:
1860<ul>
1861
1862<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1863<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1864<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1865<li>any other non-string input value will cause a type error.</li>
1866</ul>
1867</li>
1868<li>
1869
1870<p>Example:</p>
1871
1872<div>
1873<div>
1874<pre class="source">lower(&quot;ASTERIXDB&quot;);
1875</pre></div></div>
1876</li>
1877<li>
1878
1879<p>The expected result is:</p>
1880
1881<div>
1882<div>
1883<pre class="source">&quot;asterixdb&quot;
1884</pre></div></div>
1885</li>
1886</ul></div>
1887<div class="section">
1888<h3><a name="ltrim"></a>ltrim</h3>
1889<ul>
1890
1891<li>
1892
1893<p>Syntax:</p>
1894
1895<div>
1896<div>
1897<pre class="source">ltrim(string[, chars]);
1898</pre></div></div>
1899</li>
1900<li>
1901
1902<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
1903</li>
1904<li>Arguments:
1905<ul>
1906
1907<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1908<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1909</ul>
1910</li>
1911<li>Return Value:
1912<ul>
1913
1914<li>a trimmed, new <tt>string</tt>,</li>
1915<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1916<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1917<li>any other non-string input value will cause a type error.</li>
1918</ul>
1919</li>
1920<li>
1921
1922<p>Example:</p>
1923
1924<div>
1925<div>
1926<pre class="source">ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
1927</pre></div></div>
1928</li>
1929<li>
1930
1931<p>The expected result is:</p>
1932
1933<div>
1934<div>
1935<pre class="source">&quot; like x-phone&quot;
1936</pre></div></div>
1937</li>
1938</ul></div>
1939<div class="section">
1940<h3><a name="position"></a>position</h3>
1941<ul>
1942
1943<li>
1944
1945<p>Syntax:</p>
1946
1947<div>
1948<div>
1949<pre class="source">position(string, string_pattern)
1950</pre></div></div>
1951</li>
1952<li>
1953
1954<p>Returns the first position of <tt>string_pattern</tt> 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>
1955</li>
1956<li>
1957
1958<p>Aliases:</p>
1959<ul>
1960
1961<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
1962<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
1963</ul>
1964</li>
1965<li>
1966
1967<p>Arguments:</p>
1968<ul>
1969
1970<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
1971<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
1972</ul>
1973</li>
1974<li>Return Value:
1975<ul>
1976
1977<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>
1978<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1979<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1980<li>any other non-string input value will return a <tt>null</tt>.</li>
1981</ul>
1982</li>
1983<li>
1984
1985<p>Example:</p>
1986
1987<div>
1988<div>
1989<pre class="source">{
1990 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
1991 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;),
1992 &quot;v3&quot;: position1(&quot;ppphonepp&quot;, &quot;phone&quot;),
1993 &quot;v4&quot;: position1(&quot;hone&quot;, &quot;phone&quot;),
1994};
1995</pre></div></div>
1996</li>
1997<li>
1998
1999<p>The expected result is:</p>
2000
2001<div>
2002<div>
2003<pre class="source">{ &quot;v1&quot;: 2, &quot;v2&quot;: -1, v3&quot;: 3, &quot;v4&quot;: -1 }
2004</pre></div></div>
2005</li>
2006</ul></div>
2007<div class="section">
2008<h3><a name="regexp_contains"></a>regexp_contains</h3>
2009<ul>
2010
2011<li>
2012
2013<p>Syntax:</p>
2014
2015<div>
2016<div>
2017<pre class="source">regexp_contains(string, string_pattern[, string_flags])
2018</pre></div></div>
2019</li>
2020<li>
2021
2022<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2023</li>
2024<li>
2025
2026<p>Aliases:</p>
2027<ul>
2028
2029<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
2030</ul>
2031</li>
2032<li>
2033
2034<p>Arguments:</p>
2035<ul>
2036
2037<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2038<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2039<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2040<ul>
2041
2042<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2043</ul>
2044</li>
2045</ul>
2046</li>
2047<li>Return Value:
2048<ul>
2049
2050<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>
2051<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2052<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2053<li>any other non-string input value will return a <tt>null</tt>.</li>
2054</ul>
2055</li>
2056<li>
2057
2058<p>Example:</p>
2059
2060<div>
2061<div>
2062<pre class="source">{
2063 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2064 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
2065};
2066</pre></div></div>
2067</li>
2068<li>
2069
2070<p>The expected result is:</p>
2071
2072<div>
2073<div>
2074<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2075</pre></div></div>
2076</li>
2077</ul></div>
2078<div class="section">
2079<h3><a name="regexp_like"></a>regexp_like</h3>
2080<ul>
2081
2082<li>
2083
2084<p>Syntax:</p>
2085
2086<div>
2087<div>
2088<pre class="source">regexp_like(string, string_pattern[, string_flags])
2089</pre></div></div>
2090</li>
2091<li>
2092
2093<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2094</li>
2095<li>
2096
2097<p>Aliases:</p>
2098<ul>
2099
2100<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
2101</ul>
2102</li>
2103<li>
2104
2105<p>Arguments:</p>
2106<ul>
2107
2108<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2109<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
2110<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2111<ul>
2112
2113<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2114</ul>
2115</li>
2116</ul>
2117</li>
2118<li>Return Value:
2119<ul>
2120
2121<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>
2122<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2123<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2124<li>any other non-string input value will return a <tt>null</tt>.</li>
2125</ul>
2126</li>
2127<li>
2128
2129<p>Example:</p>
2130
2131<div>
2132<div>
2133<pre class="source">{
2134 &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
2135 &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
2136};
2137</pre></div></div>
2138</li>
2139<li>
2140
2141<p>The expected result is:</p>
2142
2143<div>
2144<div>
2145<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2146</pre></div></div>
2147</li>
2148</ul></div>
2149<div class="section">
2150<h3><a name="regexp_position"></a>regexp_position</h3>
2151<ul>
2152
2153<li>
2154
2155<p>Syntax:</p>
2156
2157<div>
2158<div>
2159<pre class="source">regexp_position(string, string_pattern[, string_flags])
2160</pre></div></div>
2161</li>
2162<li>
2163
2164<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>
2165</li>
2166<li>
2167
2168<p>Aliases:</p>
2169<ul>
2170
2171<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>
2172<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
2173</ul>
2174</li>
2175<li>
2176
2177<p>Arguments:</p>
2178<ul>
2179
2180<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2181<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2182<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2183<ul>
2184
2185<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2186</ul>
2187</li>
2188</ul>
2189</li>
2190<li>Return Value:
2191<ul>
2192
2193<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>
2194<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2195<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2196<li>any other non-string input value will return a <tt>null</tt>.</li>
2197</ul>
2198</li>
2199<li>
2200
2201<p>Example:</p>
2202
2203<div>
2204<div>
2205<pre class="source">{
2206 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2207 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;),
2208 &quot;v3&quot;: regexp_position1(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2209 &quot;v4&quot;: regexp_position1(&quot;hone&quot;, &quot;p+hone&quot;)
2210};
2211</pre></div></div>
2212</li>
2213<li>
2214
2215<p>The expected result is:</p>
2216
2217<div>
2218<div>
2219<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: -1, &quot;v3&quot;: 1, &quot;v4&quot;: -1 }
2220</pre></div></div>
2221</li>
2222</ul></div>
2223<div class="section">
2224<h3><a name="regexp_replace"></a>regexp_replace</h3>
2225<ul>
2226
2227<li>
2228
2229<p>Syntax:</p>
2230
2231<div>
2232<div>
2233<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
2234regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
2235</pre></div></div>
2236</li>
2237<li>
2238
2239<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>
2240</li>
2241<li>
2242
2243<p>Aliases:</p>
2244<ul>
2245
2246<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
2247</ul>
2248</li>
2249<li>
2250
2251<p>Arguments:</p>
2252<ul>
2253
2254<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2255<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2256<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
2257<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2258<ul>
2259
2260<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2261</ul>
2262</li>
2263<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>
2264</ul>
2265</li>
2266<li>Return Value:
2267<ul>
2268
2269<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
2270<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2271<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2272<li>any other non-string input value will return a <tt>null</tt>.</li>
2273</ul>
2274</li>
2275<li>
2276
2277<p>Example:</p>
2278
2279<div>
2280<div>
2281<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;);
2282</pre></div></div>
2283</li>
2284<li>
2285
2286<p>The expected result is:</p>
2287
2288<div>
2289<div>
2290<pre class="source">&quot;like product-a the voicemail_service is awesome&quot;
2291</pre></div></div>
2292</li>
2293</ul></div>
2294<div class="section">
2295<h3><a name="repeat"></a>repeat</h3>
2296<ul>
2297
2298<li>
2299
2300<p>Syntax:</p>
2301
2302<div>
2303<div>
2304<pre class="source">repeat(string, n)
2305</pre></div></div>
2306</li>
2307<li>
2308
2309<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
2310</li>
2311<li>Arguments:
2312<ul>
2313
2314<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2315<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>
2316</ul>
2317</li>
2318<li>Return Value:
2319<ul>
2320
2321<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2322<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2323<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2324<li>a type error will be raised if:
2325<ul>
2326
2327<li>the first argument is any other non-string value,</li>
2328<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2329</ul>
2330</li>
2331</ul>
2332</li>
2333<li>
2334
2335<p>Example:</p>
2336
2337<div>
2338<div>
2339<pre class="source">repeat(&quot;test&quot;, 3);
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;testtesttest&quot;
2349</pre></div></div>
2350</li>
2351</ul></div>
2352<div class="section">
2353<h3><a name="replace"></a>replace</h3>
2354<ul>
2355
2356<li>
2357
2358<p>Syntax:</p>
2359
2360<div>
2361<div>
2362<pre class="source">replace(string, search_string, replacement_string[, limit])
2363</pre></div></div>
2364</li>
2365<li>
2366
2367<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>
2368</li>
2369<li>Arguments:
2370<ul>
2371
2372<li><tt>string</tt> : an input <tt>string</tt>,</li>
2373<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
2374<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
2375<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>
2376</ul>
2377</li>
2378<li>Return Value:
2379<ul>
2380
2381<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2382<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2383<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
2384<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2385</ul>
2386</li>
2387<li>
2388
2389<p>Example:</p>
2390
2391<div>
2392<div>
2393<pre class="source">{
2394 &quot;v1&quot;: replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;),
2395 &quot;v2&quot;: replace(&quot;x-phone and x-phone&quot;, &quot;x-phone&quot;, &quot;product-a&quot;, 1)
2396};
2397</pre></div></div>
2398</li>
2399<li>
2400
2401<p>The expected result is:</p>
2402
2403<div>
2404<div>
2405<pre class="source">{
2406 &quot;v1&quot;: &quot;like product-a the voicemail_service is awesome&quot;,
2407 &quot;v2&quot;: &quot;product-a and x-phone&quot;
2408}
2409</pre></div></div>
2410</li>
2411</ul></div>
2412<div class="section">
2413<h3><a name="reverse"></a>reverse</h3>
2414<ul>
2415
2416<li>
2417
2418<p>Syntax:</p>
2419
2420<div>
2421<div>
2422<pre class="source">reverse(string)
2423</pre></div></div>
2424</li>
2425<li>
2426
2427<p>Returns a string formed by reversing characters in the input <tt>string</tt>.</p>
2428</li>
2429<li>Arguments:
2430<ul>
2431
2432<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
2433</ul>
2434</li>
2435<li>Return Value:
2436<ul>
2437
2438<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
2439<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2440<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2441<li>a type error will be raised if:
2442<ul>
2443
2444<li>the first argument is any other non-string value</li>
2445</ul>
2446</li>
2447</ul>
2448</li>
2449<li>
2450
2451<p>Example:</p>
2452
2453<div>
2454<div>
2455<pre class="source">reverse(&quot;hello&quot;);
2456</pre></div></div>
2457</li>
2458<li>
2459
2460<p>The expected result is:</p>
2461
2462<div>
2463<div>
2464<pre class="source">&quot;olleh&quot;
2465</pre></div></div>
2466</li>
2467</ul></div>
2468<div class="section">
2469<h3><a name="rtrim"></a>rtrim</h3>
2470<ul>
2471
2472<li>
2473
2474<p>Syntax:</p>
2475
2476<div>
2477<div>
2478<pre class="source">rtrim(string[, chars]);
2479</pre></div></div>
2480</li>
2481<li>
2482
2483<p>Returns a new string with all trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
2484</li>
2485<li>Arguments:
2486<ul>
2487
2488<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2489<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2490</ul>
2491</li>
2492<li>Return Value:
2493<ul>
2494
2495<li>a trimmed, new <tt>string</tt>,</li>
2496<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2497<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2498<li>any other non-string input value will cause a type error.</li>
2499</ul>
2500</li>
2501<li>
2502
2503<p>Example:</p>
2504
2505<div>
2506<div>
2507<pre class="source">{
2508 &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
2509 &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
2510};
2511</pre></div></div>
2512</li>
2513<li>
2514
2515<p>The expected result is:</p>
2516
2517<div>
2518<div>
2519<pre class="source">{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like &quot; }
2520</pre></div></div>
2521</li>
2522</ul></div>
2523<div class="section">
2524<h3><a name="split"></a>split</h3>
2525<ul>
2526
2527<li>
2528
2529<p>Syntax:</p>
2530
2531<div>
2532<div>
2533<pre class="source">split(string, sep)
2534</pre></div></div>
2535</li>
2536<li>
2537
2538<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
2539</li>
2540<li>Arguments:
2541<ul>
2542
2543<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2544</ul>
2545</li>
2546<li>Return Value:
2547<ul>
2548
2549<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2550<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2551<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2552<li>any other non-string input value will cause a type error.</li>
2553</ul>
2554</li>
2555<li>
2556
2557<p>Example:</p>
2558
2559<div>
2560<div>
2561<pre class="source">split(&quot;test driven development&quot;, &quot; &quot;);
2562</pre></div></div>
2563</li>
2564<li>
2565
2566<p>The expected result is:</p>
2567
2568<div>
2569<div>
2570<pre class="source">[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2571</pre></div></div>
2572</li>
2573</ul></div>
2574<div class="section">
2575<h3><a name="starts_with"></a>starts_with</h3>
2576<ul>
2577
2578<li>
2579
2580<p>Syntax:</p>
2581
2582<div>
2583<div>
2584<pre class="source">starts_with(string, substring_to_start_with)
2585</pre></div></div>
2586</li>
2587<li>
2588
2589<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
2590</li>
2591<li>Arguments:
2592<ul>
2593
2594<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2595<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2596</ul>
2597</li>
2598<li>Return Value:
2599<ul>
2600
2601<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2602<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2603<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2604<li>any other non-string input value will cause a type error,</li>
2605<li><tt>false</tt> otherwise.</li>
2606</ul>
2607</li>
2608<li>
2609
2610<p>Example:</p>
2611
2612<div>
2613<div>
2614<pre class="source">{
2615 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2616 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2617};
2618</pre></div></div>
2619</li>
2620<li>
2621
2622<p>The expected result is:</p>
2623
2624<div>
2625<div>
2626<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2627</pre></div></div>
2628</li>
2629</ul></div>
2630<div class="section">
2631<h3><a name="substr"></a>substr</h3>
2632<ul>
2633
2634<li>
2635
2636<p>Syntax:</p>
2637
2638<div>
2639<div>
2640<pre class="source">substr(string, offset[, length])
2641</pre></div></div>
2642</li>
2643<li>
2644
2645<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>. 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>
2646</li>
2647<li>
2648
2649<p>Aliases:</p>
2650<ul>
2651
2652<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
2653<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
2654</ul>
2655</li>
2656<li>
2657
2658<p>Arguments:</p>
2659<ul>
2660
2661<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2662<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>
2663<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>
2664</ul>
2665</li>
2666<li>Return Value:
2667<ul>
2668
2669<li>a <tt>string</tt> that represents the substring,</li>
2670<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2671<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>
2672<li>a <tt>null</tt> will be returned if:
2673<ul>
2674
2675<li>the first argument is any other non-string value.</li>
2676<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2677<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>
2678</ul>
2679</li>
2680</ul>
2681</li>
2682<li>
2683
2684<p>Example:</p>
2685
2686<div>
2687<div>
2688<pre class="source">{ &quot;v1&quot;: substr(&quot;test string&quot;, 6, 3), &quot;v2&quot;: substr1(&quot;test string&quot;, 6, 3) };
2689</pre></div></div>
2690</li>
2691<li>
2692
2693<p>The expected result is:</p>
2694
2695<div>
2696<div>
2697<pre class="source">{ &quot;v1&quot;: &quot;tri&quot;, &quot;v2&quot;: &quot;str&quot; }
2698</pre></div></div>
2699</li>
2700</ul>
2701<p>The function has an alias <tt>substring</tt>.</p></div>
2702<div class="section">
2703<h3><a name="trim"></a>trim</h3>
2704<ul>
2705
2706<li>
2707
2708<p>Syntax:</p>
2709
2710<div>
2711<div>
2712<pre class="source">trim(string[, chars]);
2713</pre></div></div>
2714</li>
2715<li>
2716
2717<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim.</p>
2718</li>
2719<li>Arguments:
2720<ul>
2721
2722<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2723<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2724</ul>
2725</li>
2726<li>Return Value:
2727<ul>
2728
2729<li>a trimmed, new <tt>string</tt>,</li>
2730<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2731<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2732<li>any other non-string input value will cause a type error.</li>
2733</ul>
2734</li>
2735<li>
2736
2737<p>Example:</p>
2738
2739<div>
2740<div>
2741<pre class="source">trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
2742</pre></div></div>
2743</li>
2744<li>
2745
2746<p>The expected result is:</p>
2747
2748<div>
2749<div>
2750<pre class="source">&quot; like &quot;
2751</pre></div></div>
2752</li>
2753</ul></div>
2754<div class="section">
2755<h3><a name="upper"></a>upper</h3>
2756<ul>
2757
2758<li>
2759
2760<p>Syntax:</p>
2761
2762<div>
2763<div>
2764<pre class="source">upper(string)
2765</pre></div></div>
2766</li>
2767<li>
2768
2769<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
2770</li>
2771<li>Arguments:
2772<ul>
2773
2774<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2775</ul>
2776</li>
2777<li>Return Value:
2778<ul>
2779
2780<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2781<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2782<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2783<li>any other non-string input value will cause a type error.</li>
2784</ul>
2785</li>
2786<li>
2787
2788<p>Example:</p>
2789
2790<div>
2791<div>
2792<pre class="source">upper(&quot;hello&quot;)
2793</pre></div></div>
2794</li>
2795<li>
2796
2797<p>The expected result is:</p>
2798
2799<div>
2800<div>
2801<pre class="source">&quot;HELLO&quot;
2802</pre></div></div>
2803</li>
2804</ul><!--
2805 ! Licensed to the Apache Software Foundation (ASF) under one
2806 ! or more contributor license agreements. See the NOTICE file
2807 ! distributed with this work for additional information
2808 ! regarding copyright ownership. The ASF licenses this file
2809 ! to you under the Apache License, Version 2.0 (the
2810 ! "License"); you may not use this file except in compliance
2811 ! with the License. You may obtain a copy of the License at
2812 !
2813 ! http://www.apache.org/licenses/LICENSE-2.0
2814 !
2815 ! Unless required by applicable law or agreed to in writing,
2816 ! software distributed under the License is distributed on an
2817 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2818 ! KIND, either express or implied. See the License for the
2819 ! specific language governing permissions and limitations
2820 ! under the License.
2821 !-->
2822</div>
2823<div class="section">
2824<h3><a name="string_concat"></a>string_concat</h3>
2825<ul>
2826
2827<li>
2828
2829<p>Syntax:</p>
2830
2831<div>
2832<div>
2833<pre class="source">string_concat(array)
2834</pre></div></div>
2835</li>
2836<li>
2837
2838<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
2839</li>
2840<li>Arguments:
2841<ul>
2842
2843<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>
2844</ul>
2845</li>
2846<li>Return Value:
2847<ul>
2848
2849<li>the concatenated <tt>string</tt> value,</li>
2850<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2851<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2852<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2853<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>
2854<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2855</ul>
2856</li>
2857<li>
2858
2859<p>Example:</p>
2860
2861<div>
2862<div>
2863<pre class="source">string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2864</pre></div></div>
2865</li>
2866<li>
2867
2868<p>The expected result is:</p>
2869
2870<div>
2871<div>
2872<pre class="source">&quot;ASTERIX ROCKS!&quot;
2873</pre></div></div>
2874</li>
2875</ul></div>
2876<div class="section">
2877<h3><a name="string_join"></a>string_join</h3>
2878<ul>
2879
2880<li>
2881
2882<p>Syntax:</p>
2883
2884<div>
2885<div>
2886<pre class="source">string_join(array, string)
2887</pre></div></div>
2888</li>
2889<li>
2890
2891<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
2892</li>
2893<li>Arguments:
2894<ul>
2895
2896<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
2897<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
2898</ul>
2899</li>
2900<li>Return Value:
2901<ul>
2902
2903<li>the joined <tt>string</tt>,</li>
2904<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2905<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2906<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
2907<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
2908<li>a type error will be raised if:
2909<ul>
2910
2911<li>the first argument is any other non-array value, or contains any other non-string value,</li>
2912<li>or, the second argument is any other non-string value.</li>
2913</ul>
2914</li>
2915</ul>
2916</li>
2917<li>
2918
2919<p>Example:</p>
2920
2921<div>
2922<div>
2923<pre class="source">string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
2924</pre></div></div>
2925</li>
2926<li>
2927
2928<p>The expected result is:</p>
2929
2930<div>
2931<div>
2932<pre class="source">&quot;ASTERIX!! ROCKS~&quot;
2933</pre></div></div>
2934</li>
2935</ul></div>
2936<div class="section">
2937<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
2938<ul>
2939
2940<li>
2941
2942<p>Syntax:</p>
2943
2944<div>
2945<div>
2946<pre class="source">string_to_codepoint(string)
2947</pre></div></div>
2948</li>
2949<li>
2950
2951<p>Converts the string <tt>string</tt> to its code_based representation.</p>
2952</li>
2953<li>Arguments:
2954<ul>
2955
2956<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
2957</ul>
2958</li>
2959<li>Return Value:
2960<ul>
2961
2962<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
2963<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2964<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2965<li>any other non-string input value will cause a type error.</li>
2966</ul>
2967</li>
2968<li>
2969
2970<p>Example:</p>
2971
2972<div>
2973<div>
2974<pre class="source">string_to_codepoint(&quot;Hello ASTERIX!&quot;);
2975</pre></div></div>
2976</li>
2977<li>
2978
2979<p>The expected result is:</p>
2980
2981<div>
2982<div>
2983<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
2984</pre></div></div>
2985</li>
2986</ul></div>
2987<div class="section">
2988<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
2989<ul>
2990
2991<li>
2992
2993<p>Syntax:</p>
2994
2995<div>
2996<div>
2997<pre class="source">codepoint_to_string(array)
2998</pre></div></div>
2999</li>
3000<li>
3001
3002<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
3003</li>
3004<li>Arguments:
3005<ul>
3006
3007<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
3008</ul>
3009</li>
3010<li>Return Value:
3011<ul>
3012
3013<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
3014<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3015<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3016<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3017<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>
3018<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
3019</ul>
3020</li>
3021<li>
3022
3023<p>Example:</p>
3024
3025<div>
3026<div>
3027<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
3028</pre></div></div>
3029</li>
3030<li>
3031
3032<p>The expected result is:</p>
3033
3034<div>
3035<div>
3036<pre class="source">&quot;Hello ASTERIX!&quot;
3037</pre></div></div>
3038</li>
3039</ul></div>
3040<div class="section">
3041<h3><a name="substring_before"></a>substring_before</h3>
3042<ul>
3043
3044<li>
3045
3046<p>Syntax:</p>
3047
3048<div>
3049<div>
3050<pre class="source">substring_before(string, string_pattern)
3051</pre></div></div>
3052</li>
3053<li>
3054
3055<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
3056</li>
3057<li>Arguments:
3058<ul>
3059
3060<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3061<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3062</ul>
3063</li>
3064<li>Return Value:
3065<ul>
3066
3067<li>a <tt>string</tt> that represents the substring,</li>
3068<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3069<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3070<li>any other non-string input value will cause a type error.</li>
3071</ul>
3072</li>
3073<li>
3074
3075<p>Example:</p>
3076
3077<div>
3078<div>
3079<pre class="source">substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
3080</pre></div></div>
3081</li>
3082<li>
3083
3084<p>The expected result is:</p>
3085
3086<div>
3087<div>
3088<pre class="source">&quot; like &quot;
3089</pre></div></div>
3090</li>
3091</ul></div>
3092<div class="section">
3093<h3><a name="substring_after"></a>substring_after</h3>
3094<ul>
3095
3096<li>
3097
3098<p>Syntax:</p>
3099<p>substring_after(string, string_pattern);</p>
3100</li>
3101<li>
3102
3103<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
3104</li>
3105<li>Arguments:
3106<ul>
3107
3108<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3109<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3110</ul>
3111</li>
3112<li>Return Value:
3113<ul>
3114
3115<li>a <tt>string</tt> that represents the substring,</li>
3116<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3117<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3118<li>any other non-string input value will cause a type error.</li>
3119</ul>
3120</li>
3121<li>
3122
3123<p>Example:</p>
3124
3125<div>
3126<div>
3127<pre class="source">substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
3128</pre></div></div>
3129</li>
3130<li>
3131
3132<p>The expected result is:</p>
3133
3134<div>
3135<div>
3136<pre class="source">&quot;one&quot;
3137</pre></div></div>
3138</li>
3139</ul><!--
3140 ! Licensed to the Apache Software Foundation (ASF) under one
3141 ! or more contributor license agreements. See the NOTICE file
3142 ! distributed with this work for additional information
3143 ! regarding copyright ownership. The ASF licenses this file
3144 ! to you under the Apache License, Version 2.0 (the
3145 ! "License"); you may not use this file except in compliance
3146 ! with the License. You may obtain a copy of the License at
3147 !
3148 ! http://www.apache.org/licenses/LICENSE-2.0
3149 !
3150 ! Unless required by applicable law or agreed to in writing,
3151 ! software distributed under the License is distributed on an
3152 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3153 ! KIND, either express or implied. See the License for the
3154 ! specific language governing permissions and limitations
3155 ! under the License.
3156 !-->
3157</div></div>
3158<div class="section">
3159<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
3160<div class="section">
3161<h3><a name="parse_binary"></a>parse_binary</h3>
3162<ul>
3163
3164<li>
3165
3166<p>Syntax:</p>
3167<p>parse_binary(string, encoding)</p>
3168</li>
3169<li>
3170
3171<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
3172</li>
3173<li>Arguments:
3174<ul>
3175
3176<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
3177<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>
3178</ul>
3179</li>
3180<li>Return Value:
3181<ul>
3182
3183<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
3184<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3185<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3186<li>any other non-string input value will cause a type error.</li>
3187</ul>
3188</li>
3189<li>
3190
3191<p>Example:</p>
3192<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>
3193</li>
3194<li>
3195
3196<p>The expected result is:</p>
3197<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p>
3198</li>
3199</ul></div>
3200<div class="section">
3201<h3><a name="print_binary"></a>print_binary</h3>
3202<ul>
3203
3204<li>
3205
3206<p>Syntax:</p>
3207<p>print_binary(binary, encoding)</p>
3208</li>
3209<li>
3210
3211<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
3212</li>
3213<li>Arguments:
3214<ul>
3215
3216<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
3217<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3218</ul>
3219</li>
3220<li>Return Value:
3221<ul>
3222
3223<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
3224<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3225<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3226<li>any other non-string input value will cause a type error.</li>
3227</ul>
3228</li>
3229<li>
3230
3231<p>Example:</p>
3232
3233<div>
3234<div>
3235<pre class="source">[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3236</pre></div></div>
3237</li>
3238<li>
3239
3240<p>The expected result are:</p>
3241
3242<div>
3243<div>
3244<pre class="source">[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3245</pre></div></div>
3246</li>
3247</ul></div>
3248<div class="section">
3249<h3><a name="binary_length"></a>binary_length</h3>
3250<ul>
3251
3252<li>
3253
3254<p>Syntax:</p>
3255<p>binary_length(binary)</p>
3256</li>
3257<li>
3258
3259<p>Returns the number of bytes storing the binary data.</p>
3260</li>
3261<li>Arguments:
3262<ul>
3263
3264<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3265</ul>
3266</li>
3267<li>Return Value:
3268<ul>
3269
3270<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3271<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3272<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3273<li>any other non-binary input value will cause a type error.</li>
3274</ul>
3275</li>
3276<li>
3277
3278<p>Example:</p>
3279
3280<div>
3281<div>
3282<pre class="source">binary_length(hex(&quot;00AA&quot;))
3283</pre></div></div>
3284</li>
3285<li>
3286
3287<p>The expected result is:</p>
3288<p>2</p>
3289</li>
3290</ul></div>
3291<div class="section">
3292<h3><a name="sub_binary"></a>sub_binary</h3>
3293<ul>
3294
3295<li>
3296
3297<p>Syntax:</p>
3298<p>sub_binary(binary, offset[, length])</p>
3299</li>
3300<li>
3301
3302<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
3303</li>
3304<li>Arguments:
3305<ul>
3306
3307<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3308<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>
3309<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>
3310</ul>
3311</li>
3312<li>Return Value:
3313<ul>
3314
3315<li>a <tt>binary</tt> that represents the sub binary,</li>
3316<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3317<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3318<li>a type error will be raised if:
3319<ul>
3320
3321<li>the first argument is any other non-binary value,</li>
3322<li>or, the second argument is any other non-integer value,</li>
3323<li>or, the third argument is any other non-integer value, if it is present.</li>
3324</ul>
3325</li>
3326</ul>
3327</li>
3328<li>
3329
3330<p>Example:</p>
3331
3332<div>
3333<div>
3334<pre class="source">sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3335</pre></div></div>
3336</li>
3337<li>
3338
3339<p>The expected result is</p>
3340
3341<div>
3342<div>
3343<pre class="source">hex(&quot;DD&quot;)
3344</pre></div></div>
3345</li>
3346</ul></div>
3347<div class="section">
3348<h3><a name="binary_concat"></a>binary_concat</h3>
3349<ul>
3350
3351<li>
3352
3353<p>Syntax:</p>
3354<p>binary_concat(array)</p>
3355</li>
3356<li>
3357
3358<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
3359</li>
3360<li>Arguments:
3361<ul>
3362
3363<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>
3364</ul>
3365</li>
3366<li>Return Value :
3367<ul>
3368
3369<li>the concatenated <tt>binary</tt> value,</li>
3370<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3371<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3372<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3373<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>
3374<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3375</ul>
3376</li>
3377<li>
3378
3379<p>Example:</p>
3380<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p>
3381</li>
3382<li>
3383
3384<p>The expected result is</p>
3385<p>hex(&#x201c;4242&#x201d;)</p>
3386</li>
3387</ul><!--
3388 ! Licensed to the Apache Software Foundation (ASF) under one
3389 ! or more contributor license agreements. See the NOTICE file
3390 ! distributed with this work for additional information
3391 ! regarding copyright ownership. The ASF licenses this file
3392 ! to you under the Apache License, Version 2.0 (the
3393 ! "License"); you may not use this file except in compliance
3394 ! with the License. You may obtain a copy of the License at
3395 !
3396 ! http://www.apache.org/licenses/LICENSE-2.0
3397 !
3398 ! Unless required by applicable law or agreed to in writing,
3399 ! software distributed under the License is distributed on an
3400 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3401 ! KIND, either express or implied. See the License for the
3402 ! specific language governing permissions and limitations
3403 ! under the License.
3404 !-->
3405</div></div>
3406<div class="section">
3407<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3408<div class="section">
3409<h3><a name="create_point"></a>create_point</h3>
3410<ul>
3411
3412<li>
3413
3414<p>Syntax:</p>
3415
3416<div>
3417<div>
3418<pre class="source">create_point(x, y)
3419</pre></div></div>
3420</li>
3421<li>
3422
3423<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
3424</li>
3425<li>Arguments:</li>
3426<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3427<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3428<li>Return Value:</li>
3429<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3430<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3431<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3432<li>any other non-double input value will cause a type error.</li>
3433<li>
3434
3435<p>Example:</p>
3436
3437<div>
3438<div>
3439<pre class="source">{ &quot;point&quot;: create_point(30.0,70.0) };
3440</pre></div></div>
3441</li>
3442<li>
3443
3444<p>The expected result is:</p>
3445
3446<div>
3447<div>
3448<pre class="source">{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3449</pre></div></div>
3450</li>
3451</ul></div>
3452<div class="section">
3453<h3><a name="create_line"></a>create_line</h3>
3454<ul>
3455
3456<li>
3457
3458<p>Syntax:</p>
3459
3460<div>
3461<div>
3462<pre class="source">create_line(point1, point2)
3463</pre></div></div>
3464</li>
3465<li>
3466
3467<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3468</li>
3469<li>Arguments:
3470<ul>
3471
3472<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3473<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3474</ul>
3475</li>
3476<li>Return Value:
3477<ul>
3478
3479<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3480<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3481<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3482<li>any other non-point input value will cause a type error.</li>
3483</ul>
3484</li>
3485<li>
3486
3487<p>Example:</p>
3488
3489<div>
3490<div>
3491<pre class="source">{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3492</pre></div></div>
3493</li>
3494<li>
3495
3496<p>The expected result is:</p>
3497
3498<div>
3499<div>
3500<pre class="source">{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3501</pre></div></div>
3502</li>
3503</ul></div>
3504<div class="section">
3505<h3><a name="create_rectangle"></a>create_rectangle</h3>
3506<ul>
3507
3508<li>
3509
3510<p>Syntax:</p>
3511
3512<div>
3513<div>
3514<pre class="source">create_rectangle(point1, point2)
3515</pre></div></div>
3516</li>
3517<li>
3518
3519<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3520</li>
3521<li>Arguments:
3522<ul>
3523
3524<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3525<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3526</ul>
3527</li>
3528<li>Return Value:
3529<ul>
3530
3531<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3532<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3533<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3534<li>any other non-point input value will cause a type error.</li>
3535</ul>
3536</li>
3537<li>
3538
3539<p>Example:</p>
3540
3541<div>
3542<div>
3543<pre class="source">{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3544</pre></div></div>
3545</li>
3546<li>
3547
3548<p>The expected result is:</p>
3549
3550<div>
3551<div>
3552<pre class="source">{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3553</pre></div></div>
3554</li>
3555</ul></div>
3556<div class="section">
3557<h3><a name="create_circle"></a>create_circle</h3>
3558<ul>
3559
3560<li>
3561
3562<p>Syntax:</p>
3563
3564<div>
3565<div>
3566<pre class="source">create_circle(point, radius)
3567</pre></div></div>
3568</li>
3569<li>
3570
3571<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
3572</li>
3573<li>Arguments:
3574<ul>
3575
3576<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3577<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3578</ul>
3579</li>
3580<li>Return Value:
3581<ul>
3582
3583<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3584<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3585<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3586<li>a type error will be raised if:
3587<ul>
3588
3589<li>the first argument is any other non-point value,</li>
3590<li>or, the second argument is any other non-double value.</li>
3591</ul>
3592</li>
3593</ul>
3594</li>
3595<li>
3596
3597<p>Example:</p>
3598
3599<div>
3600<div>
3601<pre class="source">{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3602</pre></div></div>
3603</li>
3604<li>
3605
3606<p>The expected result is:</p>
3607
3608<div>
3609<div>
3610<pre class="source">{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3611</pre></div></div>
3612</li>
3613</ul></div>
3614<div class="section">
3615<h3><a name="create_polygon"></a>create_polygon</h3>
3616<ul>
3617
3618<li>
3619
3620<p>Syntax:</p>
3621
3622<div>
3623<div>
3624<pre class="source">create_polygon(array)
3625</pre></div></div>
3626</li>
3627<li>
3628
3629<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>
3630</li>
3631<li>Arguments:
3632<ul>
3633
3634<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3635</ul>
3636</li>
3637<li>Return Value:
3638<ul>
3639
3640<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3641<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3642<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3643<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3644<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>
3645<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3646</ul>
3647</li>
3648<li>
3649
3650<p>Example:</p>
3651
3652<div>
3653<div>
3654<pre class="source">{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3655</pre></div></div>
3656</li>
3657<li>
3658
3659<p>The expected result is:</p>
3660
3661<div>
3662<div>
3663<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;) }
3664</pre></div></div>
3665</li>
3666</ul></div>
3667<div class="section">
3668<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
3669<ul>
3670
3671<li>
3672
3673<p>Syntax:</p>
3674
3675<div>
3676<div>
3677<pre class="source">get_x(point) or get_y(point)
3678</pre></div></div>
3679</li>
3680<li>
3681
3682<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
3683</li>
3684<li>Arguments:
3685<ul>
3686
3687<li><tt>point</tt> : a <tt>point</tt>.</li>
3688</ul>
3689</li>
3690<li>Return Value:
3691<ul>
3692
3693<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3694<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3695<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3696<li>any other non-point input value will cause a type error.</li>
3697</ul>
3698</li>
3699<li>
3700
3701<p>Example:</p>
3702
3703<div>
3704<div>
3705<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)) };
3706</pre></div></div>
3707</li>
3708<li>
3709
3710<p>The expected result is:</p>
3711
3712<div>
3713<div>
3714<pre class="source">{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3715</pre></div></div>
3716</li>
3717</ul></div>
3718<div class="section">
3719<h3><a name="get_points"></a>get_points</h3>
3720<ul>
3721
3722<li>
3723
3724<p>Syntax:</p>
3725
3726<div>
3727<div>
3728<pre class="source">get_points(spatial_object)
3729</pre></div></div>
3730</li>
3731<li>
3732
3733<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
3734</li>
3735<li>Arguments:
3736<ul>
3737
3738<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3739</ul>
3740</li>
3741<li>Return Value:
3742<ul>
3743
3744<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3745<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3746<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3747<li>any other non-spatial-object input value will cause a type error.</li>
3748</ul>
3749</li>
3750<li>
3751
3752<p>Example:</p>
3753
3754<div>
3755<div>
3756<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3757</pre></div></div>
3758</li>
3759<li>
3760
3761<p>The expected result is:</p>
3762
3763<div>
3764<div>
3765<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;) ]
3766</pre></div></div>
3767</li>
3768</ul></div>
3769<div class="section">
3770<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
3771<ul>
3772
3773<li>
3774
3775<p>Syntax:</p>
3776
3777<div>
3778<div>
3779<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
3780</pre></div></div>
3781</li>
3782<li>
3783
3784<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
3785</li>
3786<li>Arguments:
3787<ul>
3788
3789<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3790</ul>
3791</li>
3792<li>Return Value:
3793<ul>
3794
3795<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3796<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3797<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3798<li>any other non-circle input value will cause a type error.</li>
3799</ul>
3800</li>
3801<li>
3802
3803<p>Example:</p>
3804
3805<div>
3806<div>
3807<pre class="source">{
3808 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3809 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3810};
3811</pre></div></div>
3812</li>
3813<li>
3814
3815<p>The expected result is:</p>
3816
3817<div>
3818<div>
3819<pre class="source">{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3820</pre></div></div>
3821</li>
3822</ul></div>
3823<div class="section">
3824<h3><a name="spatial_distance"></a>spatial_distance</h3>
3825<ul>
3826
3827<li>
3828
3829<p>Syntax:</p>
3830
3831<div>
3832<div>
3833<pre class="source">spatial_distance(point1, point2)
3834</pre></div></div>
3835</li>
3836<li>
3837
3838<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
3839</li>
3840<li>Arguments:
3841<ul>
3842
3843<li><tt>point1</tt> : a <tt>point</tt>.</li>
3844<li><tt>point2</tt> : a <tt>point</tt>.</li>
3845</ul>
3846</li>
3847<li>Return Value:
3848<ul>
3849
3850<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3851<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3852<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3853<li>any other non-point input value will cause a type error.</li>
3854</ul>
3855</li>
3856<li>
3857
3858<p>Example:</p>
3859
3860<div>
3861<div>
3862<pre class="source">spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3863</pre></div></div>
3864</li>
3865<li>
3866
3867<p>The expected result is:</p>
3868
3869<div>
3870<div>
3871<pre class="source">20.434678857275934
3872</pre></div></div>
3873</li>
3874</ul></div>
3875<div class="section">
3876<h3><a name="spatial_area"></a>spatial_area</h3>
3877<ul>
3878
3879<li>
3880
3881<p>Syntax:</p>
3882
3883<div>
3884<div>
3885<pre class="source">spatial_area(spatial_2d_expression)
3886</pre></div></div>
3887</li>
3888<li>
3889
3890<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
3891</li>
3892<li>Arguments:
3893<ul>
3894
3895<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3896</ul>
3897</li>
3898<li>Return Value:
3899<ul>
3900
3901<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
3902<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3903<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3904<li>any other non-2d-spatial-object will cause a type error.</li>
3905</ul>
3906</li>
3907<li>
3908
3909<p>Example:</p>
3910
3911<div>
3912<div>
3913<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
3914</pre></div></div>
3915</li>
3916<li>
3917
3918<p>The expected result is:</p>
3919
3920<div>
3921<div>
3922<pre class="source">78.53981625
3923</pre></div></div>
3924</li>
3925</ul></div>
3926<div class="section">
3927<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
3928<ul>
3929
3930<li>
3931
3932<p>Syntax:</p>
3933
3934<div>
3935<div>
3936<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
3937</pre></div></div>
3938</li>
3939<li>
3940
3941<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
3942</li>
3943<li>Arguments:
3944<ul>
3945
3946<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3947<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3948</ul>
3949</li>
3950<li>Return Value:
3951<ul>
3952
3953<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
3954<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3955<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3956<li>any other non-spatial-object input value will cause a type error.</li>
3957</ul>
3958</li>
3959<li>
3960
3961<p>Example:</p>
3962
3963<div>
3964<div>
3965<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)));
3966</pre></div></div>
3967</li>
3968<li>
3969
3970<p>The expected result is:</p>
3971
3972<div>
3973<div>
3974<pre class="source">true
3975</pre></div></div>
3976</li>
3977</ul></div>
3978<div class="section">
3979<h3><a name="spatial_cell"></a>spatial_cell</h3>
3980<ul>
3981
3982<li>
3983
3984<p>Syntax:</p>
3985
3986<div>
3987<div>
3988<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
3989</pre></div></div>
3990</li>
3991<li>
3992
3993<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
3994</li>
3995<li>Arguments:
3996<ul>
3997
3998<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
3999<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
4000<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
4001<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
4002</ul>
4003</li>
4004<li>Return Value:
4005<ul>
4006
4007<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
4008<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4009<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4010<li>a type error will be raised if:
4011<ul>
4012
4013<li>the first or second argument is any other non-point value,</li>
4014<li>or, the second or third argument is any other non-double value.</li>
4015</ul>
4016</li>
4017</ul>
4018</li>
4019<li>
4020
4021<p>Example:</p>
4022
4023<div>
4024<div>
4025<pre class="source">spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
4026</pre></div></div>
4027</li>
4028<li>
4029
4030<p>The expected result is:</p>
4031
4032<div>
4033<div>
4034<pre class="source">rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
4035</pre></div></div>
4036</li>
4037</ul><!--
4038 ! Licensed to the Apache Software Foundation (ASF) under one
4039 ! or more contributor license agreements. See the NOTICE file
4040 ! distributed with this work for additional information
4041 ! regarding copyright ownership. The ASF licenses this file
4042 ! to you under the Apache License, Version 2.0 (the
4043 ! "License"); you may not use this file except in compliance
4044 ! with the License. You may obtain a copy of the License at
4045 !
4046 ! http://www.apache.org/licenses/LICENSE-2.0
4047 !
4048 ! Unless required by applicable law or agreed to in writing,
4049 ! software distributed under the License is distributed on an
4050 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4051 ! KIND, either express or implied. See the License for the
4052 ! specific language governing permissions and limitations
4053 ! under the License.
4054 !-->
4055</div></div>
4056<div class="section">
4057<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
4058<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>
4059<div class="section">
4060<h3><a name="edit_distance"></a>edit_distance</h3>
4061<ul>
4062
4063<li>
4064
4065<p>Syntax:</p>
4066
4067<div>
4068<div>
4069<pre class="source">edit_distance(expression1, expression2)
4070</pre></div></div>
4071</li>
4072<li>
4073
4074<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
4075</li>
4076<li>Arguments:
4077<ul>
4078
4079<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4080<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4081</ul>
4082</li>
4083<li>Return Value:
4084<ul>
4085
4086<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
4087<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4088<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4089<li>any other non-string input value will cause a type error.</li>
4090</ul>
4091</li>
4092<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4093<li>Example:
4094
4095<div>
4096<div>
4097<pre class="source">edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
4098</pre></div></div>
4099</li>
4100<li>
4101
4102<p>The expected result is:</p>
4103
4104<div>
4105<div>
4106<pre class="source">2
4107</pre></div></div>
4108</li>
4109</ul></div>
4110<div class="section">
4111<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
4112<ul>
4113
4114<li>
4115
4116<p>Syntax:</p>
4117
4118<div>
4119<div>
4120<pre class="source">edit_distance_check(expression1, expression2, threshold)
4121</pre></div></div>
4122</li>
4123<li>
4124
4125<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
4126</li>
4127<li>
4128
4129<p>Arguments:</p>
4130<ul>
4131
4132<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4133<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4134<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4135</ul>
4136</li>
4137<li>Return Value:
4138<ul>
4139
4140<li>an <tt>array</tt> with two items:
4141<ul>
4142
4143<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>
4144<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>
4145<li>If the first item is false, then the second item is set to 2147483647.</li>
4146</ul>
4147</li>
4148<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4149<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4150<li>a type error will be raised if:
4151<ul>
4152
4153<li>the first or second argument is any other non-string value,</li>
4154<li>or, the third argument is any other non-bigint value.</li>
4155</ul>
4156</li>
4157</ul>
4158</li>
4159<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4160<li>Example:
4161
4162<div>
4163<div>
4164<pre class="source">edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
4165</pre></div></div>
4166</li>
4167<li>
4168
4169<p>The expected result is:</p>
4170
4171<div>
4172<div>
4173<pre class="source">[ true, 2 ]
4174</pre></div></div>
4175</li>
4176</ul></div>
4177<div class="section">
4178<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
4179<ul>
4180
4181<li>
4182
4183<p>Syntax:</p>
4184
4185<div>
4186<div>
4187<pre class="source">edit_distance_contains(expression1, expression2, threshold)
4188</pre></div></div>
4189</li>
4190<li>
4191
4192<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>
4193</li>
4194<li>
4195
4196<p>Arguments:</p>
4197<ul>
4198
4199<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4200<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4201<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4202</ul>
4203</li>
4204<li>Return Value:
4205<ul>
4206
4207<li>an <tt>array</tt> with two items:
4208<ul>
4209
4210<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
4211<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>
4212</ul>
4213</li>
4214<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4215<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4216<li>a type error will be raised if:
4217<ul>
4218
4219<li>the first or second argument is any other non-string value,</li>
4220<li>or, the third argument is any other non-bigint value.</li>
4221</ul>
4222</li>
4223</ul>
4224</li>
4225<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4226<li>Example:
4227
4228<div>
4229<div>
4230<pre class="source">edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4231</pre></div></div>
4232</li>
4233<li>
4234
4235<p>The expected result is:</p>
4236
4237<div>
4238<div>
4239<pre class="source">[ true, 1 ]
4240</pre></div></div>
4241</li>
4242</ul></div>
4243<div class="section">
4244<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4245<ul>
4246
4247<li>
4248
4249<p>Syntax:</p>
4250
4251<div>
4252<div>
4253<pre class="source">similarity_jaccard(array1, array2)
4254</pre></div></div>
4255</li>
4256<li>
4257
4258<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>
4259</li>
4260<li>Arguments:
4261<ul>
4262
4263<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4264<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4265</ul>
4266</li>
4267<li>Return Value:
4268<ul>
4269
4270<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4271<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4272<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4273<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4274<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>
4275<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4276</ul>
4277</li>
4278<li>
4279
4280<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4281</li>
4282<li>Example:
4283
4284<div>
4285<div>
4286<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
4287</pre></div></div>
4288</li>
4289<li>
4290
4291<p>The expected result is:</p>
4292
4293<div>
4294<div>
4295<pre class="source">0.6
4296</pre></div></div>
4297</li>
4298</ul></div>
4299<div class="section">
4300<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4301<ul>
4302
4303<li>
4304
4305<p>Syntax:</p>
4306
4307<div>
4308<div>
4309<pre class="source">similarity_jaccard_check(array1, array2, threshold)
4310</pre></div></div>
4311</li>
4312<li>
4313
4314<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>
4315</li>
4316<li>
4317
4318<p>Arguments:</p>
4319<ul>
4320
4321<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4322<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4323<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4324</ul>
4325</li>
4326<li>Return Value:
4327<ul>
4328
4329<li>an <tt>array</tt> with two items:
4330<ul>
4331
4332<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4333<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>
4334</ul>
4335</li>
4336<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4337<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4338<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4339<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>
4340<li>a type error will be raised if:
4341<ul>
4342
4343<li>the first or second argument is any other non-array value,
4344<ul>
4345
4346<li>or, the third argument is any other non-double value.</li>
4347</ul>
4348</li>
4349</ul>
4350</li>
4351</ul>
4352</li>
4353<li>
4354
4355<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4356</li>
4357<li>Example:
4358
4359<div>
4360<div>
4361<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4362</pre></div></div>
4363</li>
4364<li>
4365
4366<p>The expected result is:</p>
4367
4368<div>
4369<div>
4370<pre class="source">[ false, 0.0 ]
4371</pre></div></div>
4372</li>
4373</ul><!--
4374 ! Licensed to the Apache Software Foundation (ASF) under one
4375 ! or more contributor license agreements. See the NOTICE file
4376 ! distributed with this work for additional information
4377 ! regarding copyright ownership. The ASF licenses this file
4378 ! to you under the Apache License, Version 2.0 (the
4379 ! "License"); you may not use this file except in compliance
4380 ! with the License. You may obtain a copy of the License at
4381 !
4382 ! http://www.apache.org/licenses/LICENSE-2.0
4383 !
4384 ! Unless required by applicable law or agreed to in writing,
4385 ! software distributed under the License is distributed on an
4386 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4387 ! KIND, either express or implied. See the License for the
4388 ! specific language governing permissions and limitations
4389 ! under the License.
4390 !-->
4391</div></div>
4392<div class="section">
4393<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4394<div class="section">
4395<h3><a name="word_tokens"></a>word_tokens</h3>
4396<ul>
4397
4398<li>
4399
4400<p>Syntax:</p>
4401
4402<div>
4403<div>
4404<pre class="source">word_tokens(string)
4405</pre></div></div>
4406</li>
4407<li>
4408
4409<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
4410</li>
4411<li>Arguments:
4412<ul>
4413
4414<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4415</ul>
4416</li>
4417<li>Return Value:
4418<ul>
4419
4420<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4421<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4422<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4423<li>any other non-string input value will cause a type error.</li>
4424</ul>
4425</li>
4426<li>
4427
4428<p>Example:</p>
4429
4430<div>
4431<div>
4432<pre class="source">word_tokens(&quot;I like the phone, awesome!&quot;);
4433</pre></div></div>
4434</li>
4435<li>
4436
4437<p>The expected result is:</p>
4438
4439<div>
4440<div>
4441<pre class="source">[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4442</pre></div></div>
4443</li>
4444</ul><!--
4445 ! Licensed to the Apache Software Foundation (ASF) under one
4446 ! or more contributor license agreements. See the NOTICE file
4447 ! distributed with this work for additional information
4448 ! regarding copyright ownership. The ASF licenses this file
4449 ! to you under the Apache License, Version 2.0 (the
4450 ! "License"); you may not use this file except in compliance
4451 ! with the License. You may obtain a copy of the License at
4452 !
4453 ! http://www.apache.org/licenses/LICENSE-2.0
4454 !
4455 ! Unless required by applicable law or agreed to in writing,
4456 ! software distributed under the License is distributed on an
4457 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4458 ! KIND, either express or implied. See the License for the
4459 ! specific language governing permissions and limitations
4460 ! under the License.
4461 !-->
4462</div></div>
4463<div class="section">
4464<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4465<div class="section">
4466<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>
4467<ul>
4468
4469<li>
4470
4471<p>Syntax:</p>
4472
4473<div>
4474<div>
4475<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4476</pre></div></div>
4477</li>
4478<li>
4479
4480<p>Accessors for accessing fields in a temporal value</p>
4481</li>
4482<li>Arguments:
4483<ul>
4484
4485<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>
4486</ul>
4487</li>
4488<li>Return Value:
4489<ul>
4490
4491<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4492<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4493<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4494<li>any other non-interval input value will cause a type error.</li>
4495</ul>
4496</li>
4497<li>
4498
4499<p>Example:</p>
4500
4501<div>
4502<div>
4503<pre class="source">{
4504 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4505 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4506 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4507 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4508 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4509 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4510 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4511};
4512</pre></div></div>
4513</li>
4514<li>
4515
4516<p>The expected result is:</p>
4517
4518<div>
4519<div>
4520<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 }
4521</pre></div></div>
4522</li>
4523</ul></div>
4524<div class="section">
4525<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4526<ul>
4527
4528<li>
4529
4530<p>Syntax:</p>
4531
4532<div>
4533<div>
4534<pre class="source">adjust_datetime_for_timezone(datetime, string)
4535</pre></div></div>
4536</li>
4537<li>
4538
4539<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
4540</li>
4541<li>Arguments:
4542<ul>
4543
4544<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4545<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4546</ul>
4547</li>
4548<li>Return Value:
4549<ul>
4550
4551<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4552<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4553<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4554<li>a type error will be raised if:
4555<ul>
4556
4557<li>the first argument is any other non-datetime value,</li>
4558<li>or, the second argument is any other non-string value.</li>
4559</ul>
4560</li>
4561</ul>
4562</li>
4563<li>
4564
4565<p>Example:</p>
4566
4567<div>
4568<div>
4569<pre class="source">adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4570</pre></div></div>
4571</li>
4572<li>
4573
4574<p>The expected result is:</p>
4575
4576<div>
4577<div>
4578<pre class="source">&quot;2008-04-26T18:10:00.000+08:00&quot;
4579</pre></div></div>
4580</li>
4581</ul></div>
4582<div class="section">
4583<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4584<ul>
4585
4586<li>
4587
4588<p>Syntax:</p>
4589
4590<div>
4591<div>
4592<pre class="source">adjust_time_for_timezone(time, string)
4593</pre></div></div>
4594</li>
4595<li>
4596
4597<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
4598</li>
4599<li>Arguments:
4600<ul>
4601
4602<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4603<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4604</ul>
4605</li>
4606<li>Return Value:
4607<ul>
4608
4609<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4610<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4611<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4612<li>a type error will be raised if:
4613<ul>
4614
4615<li>the first argument is any other non-time value,</li>
4616<li>or, the second argument is any other non-string value.</li>
4617</ul>
4618</li>
4619</ul>
4620</li>
4621<li>
4622
4623<p>Example:</p>
4624
4625<div>
4626<div>
4627<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4628</pre></div></div>
4629</li>
4630<li>
4631
4632<p>The expected result is:</p>
4633
4634<div>
4635<div>
4636<pre class="source">&quot;18:10:00.000+08:00&quot;
4637</pre></div></div>
4638</li>
4639</ul></div>
4640<div class="section">
4641<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4642<ul>
4643
4644<li>
4645
4646<p>Syntax:</p>
4647
4648<div>
4649<div>
4650<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
4651</pre></div></div>
4652</li>
4653<li>
4654
4655<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
4656</li>
4657<li>Arguments:
4658<ul>
4659
4660<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4661<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4662</ul>
4663</li>
4664<li>Return Value:
4665<ul>
4666
4667<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4668<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4669<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4670<li>a type error will be raised if:
4671<ul>
4672
4673<li>the first argument is any other non-datetime value,</li>
4674<li>or, the second argument is any other non-duration input value.</li>
4675</ul>
4676</li>
4677</ul>
4678</li>
4679<li>
4680
4681<p>Example:</p>
4682
4683<div>
4684<div>
4685<pre class="source">calendar_duration_from_datetime(
4686 datetime(&quot;2016-03-26T10:10:00&quot;),
4687 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4688);
4689</pre></div></div>
4690</li>
4691<li>
4692
4693<p>The expected result is:</p>
4694
4695<div>
4696<div>
4697<pre class="source">duration(&quot;P5Y2M24DT10H10M&quot;)
4698</pre></div></div>
4699</li>
4700</ul></div>
4701<div class="section">
4702<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4703<ul>
4704
4705<li>
4706
4707<p>Syntax:</p>
4708
4709<div>
4710<div>
4711<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
4712</pre></div></div>
4713</li>
4714<li>
4715
4716<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
4717</li>
4718<li>Arguments:
4719<ul>
4720
4721<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4722</ul>
4723</li>
4724<li>Return Value:
4725<ul>
4726
4727<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4728<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4729<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4730<li>any other non-duration input value will cause a type error.</li>
4731</ul>
4732</li>
4733<li>
4734
4735<p>Example:</p>
4736
4737<div>
4738<div>
4739<pre class="source">get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4740</pre></div></div>
4741</li>
4742<li>
4743
4744<p>The expected result is:</p>
4745
4746<div>
4747<div>
4748<pre class="source">year_month_duration(&quot;P1Y&quot;)
4749</pre></div></div>
4750</li>
4751</ul></div>
4752<div class="section">
4753<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>
4754<ul>
4755
4756<li>
4757
4758<p>Syntax:</p>
4759
4760<div>
4761<div>
4762<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
4763</pre></div></div>
4764</li>
4765<li>
4766
4767<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
4768</li>
4769<li>Arguments:
4770<ul>
4771
4772<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4773</ul>
4774</li>
4775<li>Return Value:
4776<ul>
4777
4778<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
4779<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4780<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4781<li>any other non-duration input value will cause a type error.</li>
4782</ul>
4783</li>
4784<li>
4785
4786<p>Example:</p>
4787
4788<div>
4789<div>
4790<pre class="source">{
4791 &quot;months&quot;: months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;))),
4792 &quot;milliseconds&quot;: ms_from_day_time_duration(get_day_time_duration(duration(&quot;P5Y7MT50M&quot;)))
4793};
4794</pre></div></div>
4795</li>
4796<li>
4797
4798<p>The expected result is:</p>
4799
4800<div>
4801<div>
4802<pre class="source">{&quot;months&quot;: 67, &quot;milliseconds&quot;: 3000000}
4803</pre></div></div>
4804</li>
4805</ul></div>
4806<div class="section">
4807<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4808<ul>
4809
4810<li>
4811
4812<p>Syntax:</p>
4813
4814<div>
4815<div>
4816<pre class="source">duration_from_months/duration_from_ms(number_value)
4817</pre></div></div>
4818</li>
4819<li>
4820
4821<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
4822</li>
4823<li>Arguments:
4824<ul>
4825
4826<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4827</ul>
4828</li>
4829<li>Return Value:
4830<ul>
4831
4832<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4833<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4834<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4835<li>any other non-duration input value will cause a type error.</li>
4836</ul>
4837</li>
4838<li>
4839
4840<p>Example:</p>
4841
4842<div>
4843<div>
4844<pre class="source">duration_from_months(8);
4845</pre></div></div>
4846</li>
4847<li>
4848
4849<p>The expected result is:</p>
4850
4851<div>
4852<div>
4853<pre class="source">duration(&quot;P8M&quot;)
4854</pre></div></div>
4855</li>
4856</ul></div>
4857<div class="section">
4858<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4859<ul>
4860
4861<li>
4862
4863<p>Syntax:</p>
4864
4865<div>
4866<div>
4867<pre class="source">duration_from_interval(interval_value)
4868</pre></div></div>
4869</li>
4870<li>
4871
4872<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
4873</li>
4874<li>Arguments:
4875<ul>
4876
4877<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
4878</ul>
4879</li>
4880<li>Return Value:
4881<ul>
4882
4883<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
4884<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4885<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4886<li>any other non-duration input value will cause a type error.</li>
4887</ul>
4888</li>
4889<li>
4890
4891<p>Example:</p>
4892
4893<div>
4894<div>
4895<pre class="source">{
4896 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
4897 &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;))),
4898 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
4899 &quot;dr4&quot; : duration_from_interval(null)
4900};
4901</pre></div></div>
4902</li>
4903<li>
4904
4905<p>The expected result is:</p>
4906
4907<div>
4908<div>
4909<pre class="source">{
4910 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
4911 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
4912 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
4913 &quot;dr4&quot;: null
4914}
4915</pre></div></div>
4916</li>
4917</ul></div>
4918<div class="section">
4919<h3><a name="current_date"></a>current_date</h3>
4920<ul>
4921
4922<li>
4923
4924<p>Syntax:</p>
4925
4926<div>
4927<div>
4928<pre class="source">current_date()
4929</pre></div></div>
4930</li>
4931<li>
4932
4933<p>Gets the current date.</p>
4934</li>
4935<li>Arguments: None</li>
4936<li>Return Value:
4937<ul>
4938
4939<li>a <tt>date</tt> value of the date when the function is called.</li>
4940</ul>
4941</li>
4942</ul></div>
4943<div class="section">
4944<h3><a name="current_time"></a>current_time</h3>
4945<ul>
4946
4947<li>
4948
4949<p>Syntax:</p>
4950
4951<div>
4952<div>
4953<pre class="source">current_time()
4954</pre></div></div>
4955</li>
4956<li>
4957
4958<p>Get the current time</p>
4959</li>
4960<li>Arguments: None</li>
4961<li>Return Value:
4962<ul>
4963
4964<li>a <tt>time</tt> value of the time when the function is called.</li>
4965</ul>
4966</li>
4967</ul></div>
4968<div class="section">
4969<h3><a name="current_datetime"></a>current_datetime</h3>
4970<ul>
4971
4972<li>
4973
4974<p>Syntax:</p>
4975
4976<div>
4977<div>
4978<pre class="source">current_datetime()
4979</pre></div></div>
4980</li>
4981<li>
4982
4983<p>Get the current datetime</p>
4984</li>
4985<li>Arguments: None</li>
4986<li>Return Value:
4987<ul>
4988
4989<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
4990</ul>
4991</li>
4992</ul></div>
4993<div class="section">
4994<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
4995<ul>
4996
4997<li>
4998
4999<p>Syntax:</p>
5000
5001<div>
5002<div>
5003<pre class="source">get_date_from_datetime(datetime)
5004</pre></div></div>
5005</li>
5006<li>
5007
5008<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
5009</li>
5010<li>Arguments:
5011<ul>
5012
5013<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5014</ul>
5015</li>
5016<li>Return Value:
5017<ul>
5018
5019<li>a <tt>date</tt> value from the datetime,</li>
5020<li>any other non-datetime input value will cause a type error.</li>
5021</ul>
5022</li>
5023</ul></div>
5024<div class="section">
5025<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
5026<ul>
5027
5028<li>
5029
5030<p>Syntax:</p>
5031
5032<div>
5033<div>
5034<pre class="source">get_time_from_datetime(datetime)
5035</pre></div></div>
5036</li>
5037<li>
5038
5039<p>Get the time value from the given datetime value <tt>datetime</tt></p>
5040</li>
5041<li>Arguments:
5042<ul>
5043
5044<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5045</ul>
5046</li>
5047<li>Return Value:
5048<ul>
5049
5050<li>a <tt>time</tt> value from the datetime.</li>
5051<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5052<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5053<li>any other non-datetime input value will cause a type error.</li>
5054</ul>
5055</li>
5056<li>
5057
5058<p>Example:</p>
5059
5060<div>
5061<div>
5062<pre class="source">get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
5063</pre></div></div>
5064</li>
5065<li>
5066
5067<p>The expected result is:</p>
5068
5069<div>
5070<div>
5071<pre class="source">time(&quot;10:10:00.000Z&quot;)
5072</pre></div></div>
5073</li>
5074</ul></div>
5075<div class="section">
5076<h3><a name="day_of_week"></a>day_of_week</h3>
5077<ul>
5078
5079<li>
5080
5081<p>Syntax:</p>
5082
5083<div>
5084<div>
5085<pre class="source">day_of_week(date)
5086</pre></div></div>
5087</li>
5088<li>
5089
5090<p>Finds the day of the week for a given date (1_7)</p>
5091</li>
5092<li>Arguments:
5093<ul>
5094
5095<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
5096</ul>
5097</li>
5098<li>Return Value:
5099<ul>
5100
5101<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
5102<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5103<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5104<li>any other non-date input value will cause a type error.</li>
5105</ul>
5106</li>
5107<li>
5108
5109<p>Example:</p>
5110
5111<div>
5112<div>
5113<pre class="source">day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
5114</pre></div></div>
5115</li>
5116<li>
5117
5118<p>The expected result is:</p>
5119
5120<div>
5121<div>
5122<pre class="source">7
5123</pre></div></div>
5124</li>
5125</ul></div>
5126<div class="section">
5127<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
5128<ul>
5129
5130<li>
5131
5132<p>Syntax:</p>
5133
5134<div>
5135<div>
5136<pre class="source">date_from_unix_time_in_days(numeric_value)
5137</pre></div></div>
5138</li>
5139<li>
5140
5141<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
5142</li>
5143<li>Arguments:
5144<ul>
5145
5146<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>
5147</ul>
5148</li>
5149<li>Return Value:
5150<ul>
5151
5152<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
5153<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5154<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5155<li>any other non-numeric input value will cause a type error.</li>
5156</ul>
5157</li>
5158</ul></div>
5159<div class="section">
5160<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
5161<ul>
5162
5163<li>
5164
5165<p>Syntax:</p>
5166
5167<div>
5168<div>
5169<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
5170</pre></div></div>
5171</li>
5172<li>
5173
5174<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
5175</li>
5176<li>Arguments:
5177<ul>
5178
5179<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>
5180</ul>
5181</li>
5182<li>Return Value:
5183<ul>
5184
5185<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5186<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5187<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5188<li>any other non-numeric input value will cause a type error.</li>
5189</ul>
5190</li>
5191</ul></div>
5192<div class="section">
5193<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5194<ul>
5195
5196<li>
5197
5198<p>Syntax:</p>
5199
5200<div>
5201<div>
5202<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
5203</pre></div></div>
5204</li>
5205<li>
5206
5207<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
5208</li>
5209<li>Arguments:
5210<ul>
5211
5212<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>
5213</ul>
5214</li>
5215<li>Return Value:
5216<ul>
5217
5218<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5219<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5220<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5221<li>any other non-numeric input value will cause a type error.</li>
5222</ul>
5223</li>
5224</ul></div>
5225<div class="section">
5226<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5227<ul>
5228
5229<li>Syntax:</li>
5230</ul>
5231<p>datetime_from_date_time(date,time)</p>
5232<ul>
5233
5234<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5235<ul>
5236
5237<li>Arguments:</li>
5238<li><tt>date</tt>: a <tt>date</tt> value</li>
5239<li><tt>time</tt> a <tt>time</tt> value</li>
5240</ul>
5241</li>
5242<li>Return Value:
5243<ul>
5244
5245<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5246<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5247<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5248<li>a type error will be raised if
5249<ul>
5250
5251<li>the first argument is any other non-date value,</li>
5252<li>or, the second argument is any other non-time value.</li>
5253</ul>
5254</li>
5255</ul>
5256</li>
5257</ul></div>
5258<div class="section">
5259<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5260<ul>
5261
5262<li>
5263
5264<p>Syntax:</p>
5265
5266<div>
5267<div>
5268<pre class="source">time_from_unix_time_in_ms(numeric_value)
5269</pre></div></div>
5270</li>
5271<li>
5272
5273<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
5274</li>
5275<li>Arguments:
5276<ul>
5277
5278<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>
5279</ul>
5280</li>
5281<li>Return Value:
5282<ul>
5283
5284<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5285<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5286<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5287<li>any other non-numeric input value will cause a type error.</li>
5288</ul>
5289</li>
5290<li>
5291
5292<p>Example:</p>
5293
5294<div>
5295<div>
5296<pre class="source">{
5297 &quot;date&quot;: date_from_unix_time_in_days(15800),
5298 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5299 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5300};
5301</pre></div></div>
5302</li>
5303<li>
5304
5305<p>The expected result is:</p>
5306
5307<div>
5308<div>
5309<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;) }
5310</pre></div></div>
5311</li>
5312</ul></div>
5313<div class="section">
5314<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5315<ul>
5316
5317<li>
5318
5319<p>Syntax:</p>
5320
5321<div>
5322<div>
5323<pre class="source">unix_time_from_date_in_days(date_value)
5324</pre></div></div>
5325</li>
5326<li>
5327
5328<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
5329</li>
5330<li>Arguments:
5331<ul>
5332
5333<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5334</ul>
5335</li>
5336<li>Return Value:
5337<ul>
5338
5339<li>a <tt>bigint</tt> value representing the number of days,</li>
5340<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5341<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5342<li>any other non-date input value will cause a type error.</li>
5343</ul>
5344</li>
5345</ul></div>
5346<div class="section">
5347<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5348<ul>
5349
5350<li>
5351
5352<p>Syntax:</p>
5353
5354<div>
5355<div>
5356<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
5357</pre></div></div>
5358</li>
5359<li>
5360
5361<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5362</li>
5363<li>Arguments:
5364<ul>
5365
5366<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5367</ul>
5368</li>
5369<li>Return Value:
5370<ul>
5371
5372<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5373<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5374<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5375<li>any other non-datetime input value will cause a type error.</li>
5376</ul>
5377</li>
5378</ul></div>
5379<div class="section">
5380<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5381<ul>
5382
5383<li>
5384
5385<p>Syntax:</p>
5386
5387<div>
5388<div>
5389<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
5390</pre></div></div>
5391</li>
5392<li>
5393
5394<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5395</li>
5396<li>Arguments:
5397<ul>
5398
5399<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5400</ul>
5401</li>
5402<li>Return Value:
5403<ul>
5404
5405<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5406<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5407<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5408<li>any other non-datetime input value will cause a type error.</li>
5409</ul>
5410</li>
5411</ul></div>
5412<div class="section">
5413<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5414<ul>
5415
5416<li>
5417
5418<p>Syntax:</p>
5419
5420<div>
5421<div>
5422<pre class="source">unix_time_from_time_in_ms(time_value)
5423</pre></div></div>
5424</li>
5425<li>
5426
5427<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
5428</li>
5429<li>Arguments:
5430<ul>
5431
5432<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5433</ul>
5434</li>
5435<li>Return Value:
5436<ul>
5437
5438<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5439<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5440<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5441<li>any other non-datetime input value will cause a type error.</li>
5442</ul>
5443</li>
5444<li>
5445
5446<p>Example:</p>
5447
5448<div>
5449<div>
5450<pre class="source">{
5451 &quot;date&quot;: date_from_unix_time_in_days(15800),
5452 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5453 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5454}
5455</pre></div></div>
5456</li>
5457<li>
5458
5459<p>The expected result is:</p>
5460
5461<div>
5462<div>
5463<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;) }
5464</pre></div></div>
5465</li>
5466</ul></div>
5467<div class="section">
5468<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5469<ul>
5470
5471<li>Syntax:</li>
5472</ul>
5473<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5474<ul>
5475
5476<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5477<li>Arguments:
5478<ul>
5479
5480<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5481<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>
5482<li><tt>h</tt> hours</li>
5483<li><tt>m</tt> minutes</li>
5484<li><tt>s</tt> seconds</li>
5485<li><tt>n</tt> milliseconds</li>
5486<li><tt>a</tt> am/pm</li>
5487<li><tt>z</tt> timezone</li>
5488<li><tt>Y</tt> year</li>
5489<li><tt>M</tt> month</li>
5490<li><tt>D</tt> day</li>
5491<li><tt>W</tt> weekday</li>
5492<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5493</ul>
5494</li>
5495<li>Return Value:
5496<ul>
5497
5498<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5499<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5500<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5501<li>a type error will be raised if:</li>
5502<li>the first argument is any other non-date value,</li>
5503<li>the second argument is any other non-string value.</li>
5504</ul>
5505</li>
5506<li>
5507
5508<p>Example:</p>
5509
5510<div>
5511<div>
5512<pre class="source">parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5513</pre></div></div>
5514</li>
5515<li>
5516
5517<p>The expected result is:</p>
5518
5519<div>
5520<div>
5521<pre class="source">time(&quot;00:30:30.000Z&quot;)
5522</pre></div></div>
5523</li>
5524</ul></div>
5525<div class="section">
5526<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
5527<ul>
5528
5529<li>
5530
5531<p>Syntax:</p>
5532
5533<div>
5534<div>
5535<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
5536</pre></div></div>
5537</li>
5538<li>
5539
5540<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>
5541</li>
5542<li>Arguments:
5543<ul>
5544
5545<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5546<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>
5547<li><tt>h</tt> hours</li>
5548<li><tt>m</tt> minutes</li>
5549<li><tt>s</tt> seconds</li>
5550<li><tt>n</tt> milliseconds</li>
5551<li><tt>a</tt> am/pm</li>
5552<li><tt>z</tt> timezone</li>
5553<li><tt>Y</tt> year</li>
5554<li><tt>M</tt> month</li>
5555<li><tt>D</tt> day</li>
5556<li><tt>W</tt> weekday</li>
5557<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5558</ul>
5559</li>
5560<li>Return Value:
5561<ul>
5562
5563<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5564<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5565<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5566<li>a type error will be raised if:
5567<ul>
5568
5569<li>the first argument is any other non-date value,</li>
5570<li>the second argument is any other non-string value.</li>
5571</ul>
5572</li>
5573</ul>
5574</li>
5575<li>
5576
5577<p>Example:</p>
5578
5579<div>
5580<div>
5581<pre class="source">print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5582</pre></div></div>
5583</li>
5584<li>
5585
5586<p>The expected result is:</p>
5587
5588<div>
5589<div>
5590<pre class="source">&quot;30:30&quot;
5591</pre></div></div>
5592</li>
5593</ul></div>
5594<div class="section">
5595<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5596<ul>
5597
5598<li>
5599
5600<p>Syntax:</p>
5601
5602<div>
5603<div>
5604<pre class="source">get_interval_start/get_interval_end(interval)
5605</pre></div></div>
5606</li>
5607<li>
5608
5609<p>Gets the start/end of the given interval.</p>
5610</li>
5611<li>Arguments:
5612<ul>
5613
5614<li><tt>interval</tt>: the interval to be accessed.</li>
5615</ul>
5616</li>
5617<li>Return Value:
5618<ul>
5619
5620<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>
5621<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5622<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5623<li>any other non-interval value will cause a type error.</li>
5624</ul>
5625</li>
5626<li>
5627
5628<p>Example:</p>
5629
5630<div>
5631<div>
5632<pre class="source">{
5633 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5634 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5635};
5636</pre></div></div>
5637</li>
5638<li>
5639
5640<p>The expected result is:</p>
5641
5642<div>
5643<div>
5644<pre class="source">{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5645</pre></div></div>
5646</li>
5647</ul></div>
5648<div class="section">
5649<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>
5650<ul>
5651
5652<li>
5653
5654<p>Syntax:</p>
5655
5656<div>
5657<div>
5658<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)
5659</pre></div></div>
5660</li>
5661<li>
5662
5663<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5664</li>
5665<li>Arguments:
5666<ul>
5667
5668<li><tt>interval</tt>: the interval to be accessed.</li>
5669</ul>
5670</li>
5671<li>Return Value:
5672<ul>
5673
5674<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5675<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5676<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5677<li>any other non-interval value will cause a type error.</li>
5678</ul>
5679</li>
5680<li>
5681
5682<p>Example:</p>
5683
5684<div>
5685<div>
5686<pre class="source">{
5687 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5688 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5689 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5690 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5691 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5692 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5693};
5694</pre></div></div>
5695</li>
5696<li>
5697
5698<p>The expected result is:</p>
5699
5700<div>
5701<div>
5702<pre class="source">{
5703 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5704 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5705 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5706 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5707 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5708 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5709}
5710</pre></div></div>
5711</li>
5712</ul></div>
5713<div class="section">
5714<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5715<ul>
5716
5717<li>
5718
5719<p>Syntax:</p>
5720
5721<div>
5722<div>
5723<pre class="source">get_overlapping_interval(interval1, interval2)
5724</pre></div></div>
5725</li>
5726<li>
5727
5728<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5729</li>
5730<li>Arguments:
5731<ul>
5732
5733<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5734<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5735</ul>
5736</li>
5737<li>Return Value:
5738<ul>
5739
5740<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>
5741<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5742<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5743<li>any other non-interval input value will cause a type error.</li>
5744</ul>
5745</li>
5746<li>
5747
5748<p>Example:</p>
5749
5750<div>
5751<div>
5752<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;))),
5753 &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;))),
5754 &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;))),
5755 &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;))),
5756 &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;))),
5757 &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;)))
5758};
5759</pre></div></div>
5760</li>
5761<li>
5762
5763<p>The expected result is:</p>
5764
5765<div>
5766<div>
5767<pre class="source">{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5768 &quot;overlap2&quot;: null,
5769 &quot;overlap3&quot;: null,
5770 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5771 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5772 &quot;overlap6&quot;: null
5773}
5774</pre></div></div>
5775</li>
5776</ul></div>
5777<div class="section">
5778<h3><a name="interval_bin"></a>interval_bin</h3>
5779<ul>
5780
5781<li>
5782
5783<p>Syntax:</p>
5784
5785<div>
5786<div>
5787<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5788</pre></div></div>
5789</li>
5790<li>
5791
5792<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
5793</li>
5794<li>Arguments:
5795<ul>
5796
5797<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5798<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>
5799<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:
5800<ul>
5801
5802<li>datetime +|_ year_month_duration</li>
5803<li>datetime +|_ day_time_duration</li>
5804<li>date +|_ year_month_duration</li>
5805<li>date +|_ day_time_duration</li>
5806<li>time +|_ day_time_duration</li>
5807</ul>
5808</li>
5809</ul>
5810</li>
5811<li>Return Value:
5812<ul>
5813
5814<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>
5815<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5816<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5817<li>a type error will be raised if:
5818<ul>
5819
5820<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5821<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5822</ul>
5823</li>
5824</ul>
5825</li>
5826<li>
5827
5828<p>Example:</p>
5829
5830<div>
5831<div>
5832<pre class="source">{
5833 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5834 &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;)),
5835 &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;)),
5836 &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;))
5837};
5838</pre></div></div>
5839</li>
5840<li>
5841
5842<p>The expected result is:</p>
5843
5844<div>
5845<div>
5846<pre class="source">{
5847 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5848 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5849 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5850 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5851}
5852</pre></div></div>
5853</li>
5854</ul></div>
5855<div class="section">
5856<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
5857<ul>
5858
5859<li>
5860
5861<p>Syntax:</p>
5862
5863<div>
5864<div>
5865<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
5866</pre></div></div>
5867</li>
5868<li>
5869
5870<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>
5871</li>
5872<li>Arguments:
5873<ul>
5874
5875<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>
5876<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>
5877</ul>
5878</li>
5879<li>Return Value:
5880<ul>
5881
5882<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
5883<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5884<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5885<li>a type error will be raised if:
5886<ul>
5887
5888<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5889<li>or, the second argument is any other non-duration value.</li>
5890</ul>
5891</li>
5892</ul>
5893</li>
5894<li>
5895
5896<p>Example:</p>
5897
5898<div>
5899<div>
5900<pre class="source">{
5901 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
5902 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
5903 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
5904};
5905</pre></div></div>
5906</li>
5907<li>
5908
5909<p>The expectecd result is:</p>
5910
5911<div>
5912<div>
5913<pre class="source">{
5914 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
5915 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
5916 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
5917}
5918</pre></div></div>
5919</li>
5920</ul></div>
5921<div class="section">
5922<h3><a name="overlap_bins"></a>overlap_bins</h3>
5923<ul>
5924
5925<li>
5926
5927<p>Return Value:</p>
5928<ul>
5929
5930<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>
5931</ul>
5932</li>
5933<li>
5934
5935<p>Syntax:</p>
5936
5937<div>
5938<div>
5939<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
5940</pre></div></div>
5941</li>
5942<li>
5943
5944<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
5945</li>
5946<li>Arguments:
5947<ul>
5948
5949<li><tt>interval</tt>: an <tt>interval</tt> value</li>
5950<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>
5951<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:
5952<ul>
5953
5954<li>datetime +|_ year_month_duration</li>
5955<li>datetime +|_ day_time_duration</li>
5956<li>date +|_ year_month_duration</li>
5957<li>date +|_ day_time_duration</li>
5958<li>time +|_ day_time_duration</li>
5959</ul>
5960</li>
5961</ul>
5962</li>
5963<li>Return Value:
5964<ul>
5965
5966<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>
5967<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5968<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5969<li>a type error will be raised if:
5970<ul>
5971
5972<li>the first arugment is any other non-interval value,</li>
5973<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
5974<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5975</ul>
5976</li>
5977</ul>
5978</li>
5979<li>
5980
5981<p>Example:</p>
5982
5983<div>
5984<div>
5985<pre class="source">{
5986 &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;)),
5987 &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;)),
5988 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
5989 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
5990};
5991</pre></div></div>
5992</li>
5993<li>
5994
5995<p>The expected result is:</p>
5996
5997<div>
5998<div>
5999<pre class="source">{
6000 &quot;timebins&quot;: [
6001 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
6002 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
6003 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
6004 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
6005 ],
6006 &quot;datebins&quot;: [
6007 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
6008 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
6009 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
6010 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
6011 ],
6012 &quot;datetimebins&quot;: [
6013 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
6014 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
6015 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
6016 ]
6017};
6018</pre></div></div>
6019</li>
6020</ul><!--
6021 ! Licensed to the Apache Software Foundation (ASF) under one
6022 ! or more contributor license agreements. See the NOTICE file
6023 ! distributed with this work for additional information
6024 ! regarding copyright ownership. The ASF licenses this file
6025 ! to you under the Apache License, Version 2.0 (the
6026 ! "License"); you may not use this file except in compliance
6027 ! with the License. You may obtain a copy of the License at
6028 !
6029 ! http://www.apache.org/licenses/LICENSE-2.0
6030 !
6031 ! Unless required by applicable law or agreed to in writing,
6032 ! software distributed under the License is distributed on an
6033 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6034 ! KIND, either express or implied. See the License for the
6035 ! specific language governing permissions and limitations
6036 ! under the License.
6037 !-->
6038</div>
6039<div class="section">
6040<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
6041<ul>
6042
6043<li>
6044
6045<p>Syntax:</p>
6046
6047<div>
6048<div>
6049<pre class="source">interval_before(interval1, interval2)
6050interval_after(interval1, interval2)
6051</pre></div></div>
6052</li>
6053<li>
6054
6055<p>These two functions check whether an interval happens before/after another interval.</p>
6056</li>
6057<li>Arguments:
6058<ul>
6059
6060<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6061</ul>
6062</li>
6063<li>Return Value:
6064<ul>
6065
6066<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>
6067<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6068<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6069<li>any other non-interval input value will cause a type error.</li>
6070</ul>
6071</li>
6072<li>
6073
6074<p>Examples:</p>
6075
6076<div>
6077<div>
6078<pre class="source">{
6079 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6080 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6081 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6082 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6083};
6084</pre></div></div>
6085</li>
6086<li>
6087
6088<p>The expected result is:</p>
6089
6090<div>
6091<div>
6092<pre class="source">{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6093</pre></div></div>
6094</li>
6095</ul></div>
6096<div class="section">
6097<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6098<ul>
6099
6100<li>
6101
6102<p>Syntax:</p>
6103
6104<div>
6105<div>
6106<pre class="source">interval_covers(interval1, interval2)
6107interval_covered_by(interval1, interval2)
6108</pre></div></div>
6109</li>
6110<li>
6111
6112<p>These two functions check whether one interval covers the other interval.</p>
6113</li>
6114<li>Arguments:
6115<ul>
6116
6117<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6118</ul>
6119</li>
6120<li>Return Value:
6121<ul>
6122
6123<li>
6124
6125<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
6126<p>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end</p>
6127<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
6128<p>interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end</p>
6129</li>
6130<li>
6131
6132<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6133</li>
6134<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6135<li>any other non-interval input value will cause a type error.</li>
6136</ul>
6137</li>
6138<li>
6139
6140<p>Examples:</p>
6141
6142<div>
6143<div>
6144<pre class="source">{
6145 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6146 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6147 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6148 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6149};
6150</pre></div></div>
6151</li>
6152<li>
6153
6154<p>The expected result is:</p>
6155
6156<div>
6157<div>
6158<pre class="source">{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6159</pre></div></div>
6160</li>
6161</ul></div>
6162<div class="section">
6163<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6164<ul>
6165
6166<li>
6167
6168<p>Syntax:</p>
6169
6170<div>
6171<div>
6172<pre class="source">interval_overlaps(interval1, interval2)
6173interval_overlapped_by(interval1, interval2)
6174</pre></div></div>
6175</li>
6176<li>
6177
6178<p>These functions check whether two intervals overlap with each other.</p>
6179</li>
6180<li>Arguments:
6181<ul>
6182
6183<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6184</ul>
6185</li>
6186<li>Return Value:
6187<ul>
6188
6189<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
6190<p>interval1.start &lt; interval2.start AND interval2.end &gt; interval1.end AND interval1.end &gt; interval2.start</p></li>
6191</ul>
6192<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6193
6194<div>
6195<div>
6196<pre class="source">interval2.start &lt; interval1.start
6197AND interval1.end &gt; interval2.end
6198AND interval2.end &gt; interval1.start
6199</pre></div></div>
6200
6201<ul>
6202
6203<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6204<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6205<li>any other non-interval input value will cause a type error.</li>
6206</ul>
6207<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>
6208</li>
6209<li>
6210
6211<p>Examples:</p>
6212
6213<div>
6214<div>
6215<pre class="source">{
6216 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6217 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6218 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6219 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6220};
6221</pre></div></div>
6222</li>
6223<li>
6224
6225<p>The expected result is:</p>
6226
6227<div>
6228<div>
6229<pre class="source">{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6230</pre></div></div>
6231</li>
6232</ul></div>
6233<div class="section">
6234<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6235<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>
6236<ul>
6237
6238<li>
6239
6240<p>Syntax:</p>
6241
6242<div>
6243<div>
6244<pre class="source">interval_overlapping(interval1, interval2)
6245</pre></div></div>
6246</li>
6247<li>
6248
6249<p>This functions check whether two intervals share any points with each other.</p>
6250</li>
6251<li>Arguments:
6252<ul>
6253
6254<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6255</ul>
6256</li>
6257<li>Return Value:
6258<ul>
6259
6260<li>
6261
6262<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
6263<p>interval1.start &lt; interval2.end AND interval1.end &gt; interval2.start</p>
6264</li>
6265<li>
6266
6267<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6268</li>
6269<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6270<li>any other non-interval input value will cause a type error.</li>
6271</ul>
6272</li>
6273<li>
6274
6275<p>Examples:</p>
6276
6277<div>
6278<div>
6279<pre class="source">{
6280 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6281 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6282 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6283 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6284};
6285</pre></div></div>
6286</li>
6287<li>
6288
6289<p>The expected result is:</p>
6290
6291<div>
6292<div>
6293<pre class="source">{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6294</pre></div></div>
6295</li>
6296</ul></div>
6297<div class="section">
6298<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
6299<ul>
6300
6301<li>
6302
6303<p>Syntax:</p>
6304
6305<div>
6306<div>
6307<pre class="source">interval_meets(interval1, interval2)
6308interval_met_by(interval1, interval2)
6309</pre></div></div>
6310</li>
6311<li>
6312
6313<p>These two functions check whether an interval meets with another interval.</p>
6314</li>
6315<li>Arguments:
6316<ul>
6317
6318<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6319</ul>
6320</li>
6321<li>Return Value:
6322<ul>
6323
6324<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>
6325<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6326<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6327<li>any other non-interval input value will cause a type error.</li>
6328</ul>
6329</li>
6330<li>
6331
6332<p>Examples:</p>
6333
6334<div>
6335<div>
6336<pre class="source">{
6337 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6338 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6339 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6340 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6341};
6342</pre></div></div>
6343</li>
6344<li>
6345
6346<p>The expected result is:</p>
6347
6348<div>
6349<div>
6350<pre class="source">{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6351</pre></div></div>
6352</li>
6353</ul></div>
6354<div class="section">
6355<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
6356<ul>
6357
6358<li>
6359
6360<p>Syntax:</p>
6361
6362<div>
6363<div>
6364<pre class="source">interval_starts(interval1, interval2)
6365interval_started_by(interval1, interval2)
6366</pre></div></div>
6367</li>
6368<li>
6369
6370<p>These two functions check whether one interval starts with the other interval.</p>
6371</li>
6372<li>Arguments:
6373<ul>
6374
6375<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6376</ul>
6377</li>
6378<li>Return Value:
6379<ul>
6380
6381<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
6382<p>interval1.start = interval2.start AND interval1.end &lt;= interval2.end</p></li>
6383</ul>
6384<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6385
6386<div>
6387<div>
6388<pre class="source">interval1.start = interval2.start
6389AND interval2.end &lt;= interval1.end
6390</pre></div></div>
6391
6392<ul>
6393
6394<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6395<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6396<li>any other non-interval input value will cause a type error.</li>
6397</ul>
6398</li>
6399<li>
6400
6401<p>Examples:</p>
6402
6403<div>
6404<div>
6405<pre class="source">{
6406 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6407 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6408 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6409 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6410};
6411</pre></div></div>
6412</li>
6413<li>
6414
6415<p>The expected result is:</p>
6416
6417<div>
6418<div>
6419<pre class="source">{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6420</pre></div></div>
6421</li>
6422</ul></div>
6423<div class="section">
6424<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6425<ul>
6426
6427<li>
6428
6429<p>Syntax:</p>
6430
6431<div>
6432<div>
6433<pre class="source">interval_ends(interval1, interval2)
6434interval_ended_by(interval1, interval2)
6435</pre></div></div>
6436</li>
6437<li>
6438
6439<p>These two functions check whether one interval ends with the other interval.</p>
6440</li>
6441<li>Arguments:
6442<ul>
6443
6444<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6445</ul>
6446</li>
6447<li>Return Value:
6448<ul>
6449
6450<li>
6451
6452<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
6453<p>interval1.end = interval2.end AND interval1.start &gt;= interval2.start</p>
6454<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
6455<p>interval2.end = interval1.end AND interval2.start &gt;= interval1.start</p>
6456</li>
6457<li>
6458
6459<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6460</li>
6461<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6462<li>any other non-interval input value will cause a type error.</li>
6463</ul>
6464</li>
6465<li>
6466
6467<p>Examples:</p>
6468
6469<div>
6470<div>
6471<pre class="source">{
6472 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6473 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6474 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6475 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6476};
6477</pre></div></div>
6478</li>
6479<li>
6480
6481<p>The expected result is:</p>
6482
6483<div>
6484<div>
6485<pre class="source">{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6486</pre></div></div>
6487</li>
6488</ul><!--
6489 ! Licensed to the Apache Software Foundation (ASF) under one
6490 ! or more contributor license agreements. See the NOTICE file
6491 ! distributed with this work for additional information
6492 ! regarding copyright ownership. The ASF licenses this file
6493 ! to you under the Apache License, Version 2.0 (the
6494 ! "License"); you may not use this file except in compliance
6495 ! with the License. You may obtain a copy of the License at
6496 !
6497 ! http://www.apache.org/licenses/LICENSE-2.0
6498 !
6499 ! Unless required by applicable law or agreed to in writing,
6500 ! software distributed under the License is distributed on an
6501 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6502 ! KIND, either express or implied. See the License for the
6503 ! specific language governing permissions and limitations
6504 ! under the License.
6505 !-->
6506</div></div>
6507<div class="section">
6508<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6509<div class="section">
6510<h3><a name="get_object_fields"></a>get_object_fields</h3>
6511<ul>
6512
6513<li>
6514
6515<p>Syntax:</p>
6516
6517<div>
6518<div>
6519<pre class="source">get_object_fields(input_object)
6520</pre></div></div>
6521</li>
6522<li>
6523
6524<p>Access the object field names, type and open status for a given object.</p>
6525</li>
6526<li>Arguments:
6527<ul>
6528
6529<li><tt>input_object</tt> : a object value.</li>
6530</ul>
6531</li>
6532<li>Return Value:
6533<ul>
6534
6535<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>
6536<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6537<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6538<li>any other non-object input value will cause a type error.</li>
6539</ul>
6540</li>
6541<li>
6542
6543<p>Example:</p>
6544
6545<div>
6546<div>
6547<pre class="source">get_object_fields(
6548 {
6549 &quot;id&quot;: 1,
6550 &quot;project&quot;: &quot;AsterixDB&quot;,
6551 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6552 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6553 }
6554 );
6555</pre></div></div>
6556</li>
6557<li>
6558
6559<p>The expected result is:</p>
6560
6561<div>
6562<div>
6563<pre class="source">[
6564 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6565 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6566 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6567 &quot;nested&quot;: [
6568 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6569 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6570 ]
6571 },
6572 { &quot;field-name&quot;:
6573 &quot;related&quot;,
6574 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6575 &quot;is-open&quot;: false,
6576 &quot;list&quot;: [
6577 { &quot;field-type&quot;: &quot;STRING&quot; },
6578 { &quot;field-type&quot;: &quot;STRING&quot; },
6579 { &quot;field-type&quot;: &quot;STRING&quot; }
6580 ]
6581 }
6582]
6583</pre></div></div>
6584</li>
6585</ul>
6586<p>]</p></div>
6587<div class="section">
6588<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6589<ul>
6590
6591<li>
6592
6593<p>Syntax:</p>
6594
6595<div>
6596<div>
6597<pre class="source">get_object_field_value(input_object, string)
6598</pre></div></div>
6599</li>
6600<li>
6601
6602<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
6603</li>
6604<li>Arguments:
6605<ul>
6606
6607<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6608<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6609</ul>
6610</li>
6611<li>Return Value:
6612<ul>
6613
6614<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6615<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6616<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6617<li>a type error will be raised if:
6618<ul>
6619
6620<li>the first argument is any other non-object value,</li>
6621<li>or, the second argument is any other non-string value.</li>
6622</ul>
6623</li>
6624</ul>
6625</li>
6626<li>
6627
6628<p>Example:</p>
6629
6630<div>
6631<div>
6632<pre class="source">get_object_field_value({
6633 &quot;id&quot;: 1,
6634 &quot;project&quot;: &quot;AsterixDB&quot;,
6635 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6636 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6637 },
6638 &quot;project&quot;
6639 );
6640</pre></div></div>
6641</li>
6642<li>
6643
6644<p>The expected result is:</p>
6645
6646<div>
6647<div>
6648<pre class="source">&quot;AsterixDB&quot;
6649</pre></div></div>
6650</li>
6651</ul></div>
6652<div class="section">
6653<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6654<ul>
6655
6656<li>
6657
6658<p>Syntax:</p>
6659
6660<div>
6661<div>
6662<pre class="source">object_remove_fields(input_object, field_names)
6663</pre></div></div>
6664</li>
6665<li>
6666
6667<p>Remove indicated fields from a object given a list of field names.</p>
6668</li>
6669<li>Arguments:
6670<ul>
6671
6672<li><tt>input_object</tt>: a object value.</li>
6673<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6674</ul>
6675</li>
6676<li>
6677
6678<p>Return Value:</p>
6679<ul>
6680
6681<li>a new object value without the fields listed in the second argument,</li>
6682<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6683<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6684<li>a type error will be raised if:
6685<ul>
6686
6687<li>the first argument is any other non-object value,</li>
6688<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6689</ul>
6690</li>
6691</ul>
6692</li>
6693<li>
6694
6695<p>Example:</p>
6696
6697<div>
6698<div>
6699<pre class="source">object_remove_fields(
6700 {
6701 &quot;id&quot;:1,
6702 &quot;project&quot;:&quot;AsterixDB&quot;,
6703 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6704 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6705 },
6706 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6707 );
6708</pre></div></div>
6709</li>
6710<li>
6711
6712<p>The expected result is:</p>
6713
6714<div>
6715<div>
6716<pre class="source">{
6717 &quot;id&quot;:1,
6718 &quot;project&quot;:&quot;AsterixDB&quot;,
6719 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6720}
6721</pre></div></div>
6722</li>
6723</ul></div>
6724<div class="section">
6725<h3><a name="object_add_fields"></a>object_add_fields</h3>
6726<ul>
6727
6728<li>
6729
6730<p>Syntax:</p>
6731
6732<div>
6733<div>
6734<pre class="source">object_add_fields(input_object, fields)
6735</pre></div></div>
6736</li>
6737<li>
6738
6739<p>Add fields to a object given a list of field names.</p>
6740</li>
6741<li>Arguments:
6742<ul>
6743
6744<li><tt>input_object</tt> : a object value.</li>
6745<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6746</ul>
6747</li>
6748<li>Return Value:
6749<ul>
6750
6751<li>a new object value with the new fields included,</li>
6752<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6753<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6754<li>a type error will be raised if:
6755<ul>
6756
6757<li>the first argument is any other non-object value,</li>
6758<li>the second argument is any other non-array value, or contains non-object items.</li>
6759</ul>
6760</li>
6761</ul>
6762</li>
6763<li>
6764
6765<p>Example:</p>
6766
6767<div>
6768<div>
6769<pre class="source">object_add_fields(
6770 {
6771 &quot;id&quot;:1,
6772 &quot;project&quot;:&quot;AsterixDB&quot;,
6773 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6774 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6775 },
6776 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6777 );
6778</pre></div></div>
6779</li>
6780<li>
6781
6782<p>The expected result is:</p>
6783
6784<div>
6785<div>
6786<pre class="source">{
6787 &quot;id&quot;:1,
6788 &quot;project&quot;:&quot;AsterixDB&quot;,
6789 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6790 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6791 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6792 }
6793</pre></div></div>
6794</li>
6795</ul></div>
6796<div class="section">
6797<h3><a name="object_merge"></a>object_merge</h3>
6798<ul>
6799
6800<li>
6801
6802<p>Syntax:</p>
6803
6804<div>
6805<div>
6806<pre class="source">object_merge(object1, object2)
6807</pre></div></div>
6808</li>
6809<li>
6810
6811<p>Merge two different objects into a new object.</p>
6812</li>
6813<li>Arguments:
6814<ul>
6815
6816<li><tt>object1</tt> : a object value.</li>
6817<li><tt>object2</tt> : a object value.</li>
6818</ul>
6819</li>
6820<li>Return Value:
6821<ul>
6822
6823<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>
6824<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6825<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6826<li>any other non-object input value will cause a type error.</li>
6827</ul>
6828</li>
6829<li>
6830
6831<p>Example:</p>
6832
6833<div>
6834<div>
6835<pre class="source">object_merge(
6836 {
6837 &quot;id&quot;:1,
6838 &quot;project&quot;:&quot;AsterixDB&quot;,
6839 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6840 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6841 },
6842 {
6843 &quot;user_id&quot;: 22,
6844 &quot;employer&quot;: &quot;UC Irvine&quot;,
6845 &quot;employment_type&quot;: &quot;visitor&quot;
6846 }
6847 );
6848</pre></div></div>
6849</li>
6850<li>
6851
6852<p>The expected result is:</p>
6853
6854<div>
6855<div>
6856<pre class="source">{
6857 &quot;employment_type&quot;: &quot;visitor&quot;,
6858 &quot;address&quot;: {
6859 &quot;city&quot;: &quot;Irvine&quot;,
6860 &quot;state&quot;: &quot;CA&quot;
6861 },
6862 &quot;related&quot;: [
6863 &quot;Hivestrix&quot;,
6864 &quot;Preglix&quot;,
6865 &quot;Apache VXQuery&quot;
6866 ],
6867 &quot;user_id&quot;: 22,
6868 &quot;project&quot;: &quot;AsterixDB&quot;,
6869 &quot;employer&quot;: &quot;UC Irvine&quot;,
6870 &quot;id&quot;: 1
6871}
6872</pre></div></div>
6873</li>
6874</ul></div>
6875<div class="section">
6876<h3><a name="object_length"></a>object_length</h3>
6877<ul>
6878
6879<li>
6880
6881<p>Syntax:</p>
6882
6883<div>
6884<div>
6885<pre class="source">object_length(input_object)
6886</pre></div></div>
6887</li>
6888<li>
6889
6890<p>Returns number of top-level fields in the given object</p>
6891</li>
6892<li>Arguments:
6893<ul>
6894
6895<li><tt>input_object</tt> : an object value.</li>
6896</ul>
6897</li>
6898<li>Return Value:
6899<ul>
6900
6901<li>an integer that represents the number of top-level fields in the given object,</li>
6902<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6903<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
6904</ul>
6905</li>
6906<li>
6907
6908<p>Example:</p>
6909
6910<div>
6911<div>
6912<pre class="source">object_length(
6913 {
6914 &quot;id&quot;: 1,
6915 &quot;project&quot;: &quot;AsterixDB&quot;,
6916 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6917 }
6918 );
6919</pre></div></div>
6920</li>
6921<li>
6922
6923<p>The expected result is:</p>
6924
6925<div>
6926<div>
6927<pre class="source">3
6928</pre></div></div>
6929</li>
6930</ul></div>
6931<div class="section">
6932<h3><a name="object_names"></a>object_names</h3>
6933<ul>
6934
6935<li>
6936
6937<p>Syntax:</p>
6938
6939<div>
6940<div>
6941<pre class="source">object_names(input_object)
6942</pre></div></div>
6943</li>
6944<li>
6945
6946<p>Returns names of top-level fields in the given object</p>
6947</li>
6948<li>Arguments:
6949<ul>
6950
6951<li><tt>input_object</tt> : an object value.</li>
6952</ul>
6953</li>
6954<li>Return Value:
6955<ul>
6956
6957<li>an array with top-level field names of the given object,</li>
6958<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6959<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
6960</ul>
6961</li>
6962<li>
6963
6964<p>Example:</p>
6965
6966<div>
6967<div>
6968<pre class="source">object_names(
6969 {
6970 &quot;id&quot;: 1,
6971 &quot;project&quot;: &quot;AsterixDB&quot;,
6972 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6973 }
6974 );
6975</pre></div></div>
6976</li>
6977<li>
6978
6979<p>The expected result is:</p>
6980
6981<div>
6982<div>
6983<pre class="source">[ &quot;id&quot;, &quot;project&quot;, &quot;address&quot; ]
6984</pre></div></div>
6985</li>
6986</ul></div>
6987<div class="section">
6988<h3><a name="object_remove"></a>object_remove</h3>
6989<ul>
6990
6991<li>
6992
6993<p>Syntax:</p>
6994
6995<div>
6996<div>
6997<pre class="source">object_remove(input_object, field_name)
6998</pre></div></div>
6999</li>
7000<li>
7001
7002<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
7003</li>
7004<li>Arguments:
7005<ul>
7006
7007<li><tt>input_object</tt> : an object value.</li>
7008<li><tt>field_name</tt> : a string field name.</li>
7009</ul>
7010</li>
7011<li>Return Value:
7012<ul>
7013
7014<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
7015<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
7016<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>
7017</ul>
7018</li>
7019<li>
7020
7021<p>Example:</p>
7022
7023<div>
7024<div>
7025<pre class="source">object_remove(
7026 {
7027 &quot;id&quot;: 1,
7028 &quot;project&quot;: &quot;AsterixDB&quot;,
7029 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7030 }
7031 , &quot;address&quot;
7032 );
7033</pre></div></div>
7034</li>
7035<li>
7036
7037<p>The expected result is:</p>
7038
7039<div>
7040<div>
7041<pre class="source">{
7042 &quot;id&quot;: 1,
7043 &quot;project&quot;: &quot;AsterixDB&quot;,
7044}
7045</pre></div></div>
7046</li>
7047</ul></div>
7048<div class="section">
7049<h3><a name="object_rename"></a>object_rename</h3>
7050<ul>
7051
7052<li>
7053
7054<p>Syntax:</p>
7055
7056<div>
7057<div>
7058<pre class="source">object_rename(input_object, old_field, new_field)
7059</pre></div></div>
7060</li>
7061<li>
7062
7063<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>
7064</li>
7065<li>Arguments:
7066<ul>
7067
7068<li><tt>input_object</tt> : an object value.</li>
7069<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
7070<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>
7071</ul>
7072</li>
7073<li>Return Value:
7074<ul>
7075
7076<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>
7077<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7078<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>
7079</ul>
7080</li>
7081<li>
7082
7083<p>Example:</p>
7084
7085<div>
7086<div>
7087<pre class="source">object_rename(
7088 {
7089 &quot;id&quot;: 1,
7090 &quot;project&quot;: &quot;AsterixDB&quot;,
7091 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7092 }
7093 , &quot;address&quot;
7094 , &quot;location&quot;
7095 );
7096</pre></div></div>
7097</li>
7098<li>
7099
7100<p>The expected result is:</p>
7101
7102<div>
7103<div>
7104<pre class="source">{
7105 &quot;id&quot;: 1,
7106 &quot;project&quot;: &quot;AsterixDB&quot;,
7107 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7108}
7109</pre></div></div>
7110</li>
7111</ul></div>
7112<div class="section">
7113<h3><a name="object_unwrap"></a>object_unwrap</h3>
7114<ul>
7115
7116<li>
7117
7118<p>Syntax:</p>
7119
7120<div>
7121<div>
7122<pre class="source">object_unwrap(input_object)
7123</pre></div></div>
7124</li>
7125<li>
7126
7127<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
7128</li>
7129<li>Arguments:
7130<ul>
7131
7132<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
7133</ul>
7134</li>
7135<li>Return Value:
7136<ul>
7137
7138<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
7139<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7140<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>
7141</ul>
7142</li>
7143<li>
7144
7145<p>Example:</p>
7146
7147<div>
7148<div>
7149<pre class="source">object_unwrap(
7150 {
7151 &quot;id&quot;: 1
7152 }
7153 );
7154</pre></div></div>
7155</li>
7156<li>
7157
7158<p>The expected result is:</p>
7159
7160<div>
7161<div>
7162<pre class="source">{
7163 1
7164}
7165</pre></div></div>
7166</li>
7167</ul></div>
7168<div class="section">
7169<h3><a name="object_replace"></a>object_replace</h3>
7170<ul>
7171
7172<li>
7173
7174<p>Syntax:</p>
7175
7176<div>
7177<div>
7178<pre class="source">object_replace(input_object, old_value, new_value)
7179</pre></div></div>
7180</li>
7181<li>
7182
7183<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>
7184</li>
7185<li>Arguments:
7186<ul>
7187
7188<li><tt>input_object</tt> : an object value.</li>
7189<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
7190<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
7191</ul>
7192</li>
7193<li>Return Value:
7194<ul>
7195
7196<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>
7197<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7198<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
7199<li>a type error will be raised if:
7200<ul>
7201
7202<li><tt>old_value</tt> is not a primitive type value.</li>
7203</ul>
7204</li>
7205</ul>
7206</li>
7207<li>
7208
7209<p>Example:</p>
7210
7211<div>
7212<div>
7213<pre class="source">object_replace(
7214 {
7215 &quot;id&quot;: 1,
7216 &quot;project&quot;: &quot;AsterixDB&quot;,
7217 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7218 }
7219 , &quot;AsterixDB&quot;
7220 , &quot;Apache AsterixDB&quot;
7221 );
7222</pre></div></div>
7223</li>
7224<li>
7225
7226<p>The expected result is:</p>
7227
7228<div>
7229<div>
7230<pre class="source">{
7231 &quot;id&quot;: 1,
7232 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7233 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7234}
7235</pre></div></div>
7236</li>
7237</ul></div>
7238<div class="section">
7239<h3><a name="object_add"></a>object_add</h3>
7240<ul>
7241
7242<li>
7243
7244<p>Syntax:</p>
7245
7246<div>
7247<div>
7248<pre class="source">object_add(input_object, field_name, field_value)
7249</pre></div></div>
7250</li>
7251<li>
7252
7253<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>
7254</li>
7255<li>Arguments:
7256<ul>
7257
7258<li><tt>input_object</tt> : an object value.</li>
7259<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7260<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7261</ul>
7262</li>
7263<li>Return Value:
7264<ul>
7265
7266<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>
7267<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7268<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>
7269<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>
7270</ul>
7271</li>
7272<li>
7273
7274<p>Example:</p>
7275
7276<div>
7277<div>
7278<pre class="source">object_add(
7279 {
7280 &quot;id&quot;: 1,
7281 &quot;project&quot;: &quot;AsterixDB&quot;,
7282 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7283 }
7284 , &quot;company&quot;
7285 , &quot;Apache&quot;
7286 );
7287</pre></div></div>
7288</li>
7289<li>
7290
7291<p>The expected result is:</p>
7292
7293<div>
7294<div>
7295<pre class="source">{
7296 &quot;id&quot;: 1,
7297 &quot;project&quot;: &quot;AsterixDB&quot;,
7298 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7299 &quot;company&quot;: &quot;Apache&quot;
7300}
7301</pre></div></div>
7302</li>
7303</ul></div>
7304<div class="section">
7305<h3><a name="object_put"></a>object_put</h3>
7306<ul>
7307
7308<li>
7309
7310<p>Syntax:</p>
7311
7312<div>
7313<div>
7314<pre class="source">object_put(input_object, field_name, field_value)
7315</pre></div></div>
7316</li>
7317<li>
7318
7319<p>Adds, modifies, or removes a field of an object.</p>
7320</li>
7321<li>Arguments:
7322<ul>
7323
7324<li><tt>input_object</tt> : an object value.</li>
7325<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7326<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7327</ul>
7328</li>
7329<li>Return Value:
7330<ul>
7331
7332<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>
7333<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7334<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>
7335</ul>
7336</li>
7337<li>
7338
7339<p>Example:</p>
7340
7341<div>
7342<div>
7343<pre class="source">object_put(
7344 {
7345 &quot;id&quot;: 1,
7346 &quot;project&quot;: &quot;AsterixDB&quot;,
7347 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7348 }
7349 , &quot;project&quot;
7350 , &quot;Apache AsterixDB&quot;
7351 );
7352</pre></div></div>
7353</li>
7354<li>
7355
7356<p>The expected result is:</p>
7357
7358<div>
7359<div>
7360<pre class="source">{
7361 &quot;id&quot;: 1,
7362 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7363 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7364}
7365</pre></div></div>
7366</li>
7367</ul></div>
7368<div class="section">
7369<h3><a name="object_values"></a>object_values</h3>
7370<ul>
7371
7372<li>
7373
7374<p>Syntax:</p>
7375
7376<div>
7377<div>
7378<pre class="source">object_values(input_object)
7379</pre></div></div>
7380</li>
7381<li>
7382
7383<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
7384</li>
7385<li>Arguments:
7386<ul>
7387
7388<li><tt>input_object</tt> : an object value.</li>
7389</ul>
7390</li>
7391<li>Return Value:
7392<ul>
7393
7394<li>An array of the values of the fields in <tt>input_object</tt>,</li>
7395<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7396<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7397</ul>
7398</li>
7399<li>
7400
7401<p>Example:</p>
7402
7403<div>
7404<div>
7405<pre class="source">object_values(
7406 {
7407 &quot;id&quot;: 1,
7408 &quot;project&quot;: &quot;AsterixDB&quot;,
7409 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7410 }
7411 );
7412</pre></div></div>
7413</li>
7414<li>
7415
7416<p>The expected result is:</p>
7417
7418<div>
7419<div>
7420<pre class="source">[
7421 1,
7422 &quot;AsterixDB&quot;,
7423 {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7424]
7425</pre></div></div>
7426</li>
7427</ul></div>
7428<div class="section">
7429<h3><a name="object_pairs"></a>object_pairs</h3>
7430<ul>
7431
7432<li>
7433
7434<p>Syntax:</p>
7435
7436<div>
7437<div>
7438<pre class="source">object_pairs(input_object)
7439</pre></div></div>
7440</li>
7441<li>
7442
7443<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>
7444</li>
7445<li>
7446
7447<p>Arguments:</p>
7448<ul>
7449
7450<li><tt>input_object</tt> : an object value.</li>
7451</ul>
7452</li>
7453<li>Return Value:
7454<ul>
7455
7456<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
7457<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7458<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7459</ul>
7460</li>
7461<li>
7462
7463<p>Example:</p>
7464
7465<div>
7466<div>
7467<pre class="source">object_pairs(
7468 {
7469 &quot;id&quot;: 1,
7470 &quot;project&quot;: &quot;AsterixDB&quot;,
7471 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7472 }
7473 );
7474</pre></div></div>
7475</li>
7476<li>
7477
7478<p>The expected result is:</p>
7479
7480<div>
7481<div>
7482<pre class="source">[
7483 { &quot;name&quot;: &quot;id&quot;, &quot;value&quot;: 1 },
7484 { &quot;name&quot;: &quot;project&quot;, &quot;value&quot;: &quot;AsterixDB&quot; },
7485 { &quot;name&quot;: &quot;address&quot;, &quot;value&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;} }
7486]
7487</pre></div></div>
7488</li>
7489</ul></div>
7490<div class="section">
7491<h3><a name="pairs"></a>pairs</h3>
7492<ul>
7493
7494<li>
7495
7496<p>Syntax:</p>
7497
7498<div>
7499<div>
7500<pre class="source">pairs(input_object)
7501</pre></div></div>
7502</li>
7503<li>
7504
7505<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>
7506</li>
7507<li>
7508
7509<p>Arguments:</p>
7510<ul>
7511
7512<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
7513</ul>
7514</li>
7515<li>Return Value:
7516<ul>
7517
7518<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>
7519<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7520<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
7521</ul>
7522</li>
7523<li>
7524
7525<p>Example:</p>
7526
7527<div>
7528<div>
7529<pre class="source">pairs(
7530 {
7531 &quot;id&quot;: 1,
7532 &quot;project&quot;: &quot;AsterixDB&quot;,
7533 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7534 }
7535 );
7536</pre></div></div>
7537</li>
7538<li>
7539
7540<p>The expected result is:</p>
7541
7542<div>
7543<div>
7544<pre class="source">[
7545 [ &quot;id&quot;, 1 ],
7546 [ &quot;project&quot;, &quot;AsterixDB&quot; ],
7547 [ &quot;address&quot;, { &quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot; } ],
7548 [ &quot;city&quot;, &quot;Irvine&quot; ],
7549 [ &quot;state&quot;, &quot;CA&quot; ]
7550]
7551</pre></div></div>
7552</li>
7553</ul><!--
7554 ! Licensed to the Apache Software Foundation (ASF) under one
7555 ! or more contributor license agreements. See the NOTICE file
7556 ! distributed with this work for additional information
7557 ! regarding copyright ownership. The ASF licenses this file
7558 ! to you under the Apache License, Version 2.0 (the
7559 ! "License"); you may not use this file except in compliance
7560 ! with the License. You may obtain a copy of the License at
7561 !
7562 ! http://www.apache.org/licenses/LICENSE-2.0
7563 !
7564 ! Unless required by applicable law or agreed to in writing,
7565 ! software distributed under the License is distributed on an
7566 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7567 ! KIND, either express or implied. See the License for the
7568 ! specific language governing permissions and limitations
7569 ! under the License.
7570 !-->
7571</div></div>
7572<div class="section">
7573<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
7574<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
7575<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#SQL-92_aggregation_functions">SQL-92 Aggregation Functions</a> for details.</p>
7576<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#Aggregation_functions">Aggregation Functions</a> for details.</p>
7577<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>
7578<div class="section">
7579<h3><a name="array_count"></a>array_count</h3>
7580<ul>
7581
7582<li>
7583
7584<p>Syntax:</p>
7585
7586<div>
7587<div>
7588<pre class="source">array_count(collection)
7589</pre></div></div>
7590</li>
7591<li>
7592
7593<p>Gets the number of non-null and non-missing items in the given collection.</p>
7594</li>
7595<li>Arguments:
7596<ul>
7597
7598<li><tt>collection</tt> could be:
7599<ul>
7600
7601<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
7602<li>or, a <tt>null</tt> value,</li>
7603<li>or, a <tt>missing</tt> value.</li>
7604</ul>
7605</li>
7606</ul>
7607</li>
7608<li>Return Value:
7609<ul>
7610
7611<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
7612<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7613<li>any other non-array and non-multiset input value will cause an error.</li>
7614</ul>
7615</li>
7616<li>
7617
7618<p>Example:</p>
7619
7620<div>
7621<div>
7622<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
7623</pre></div></div>
7624</li>
7625<li>
7626
7627<p>The expected result is:</p>
7628
7629<div>
7630<div>
7631<pre class="source">5
7632</pre></div></div>
7633</li>
7634</ul></div>
7635<div class="section">
7636<h3><a name="array_avg"></a>array_avg</h3>
7637<ul>
7638
7639<li>
7640
7641<p>Syntax:</p>
7642
7643<div>
7644<div>
7645<pre class="source">array_avg(num_collection)
7646</pre></div></div>
7647</li>
7648<li>
7649
7650<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
7651</li>
7652<li>Arguments:
7653<ul>
7654
7655<li><tt>num_collection</tt> could be:
7656<ul>
7657
7658<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7659<li>or, a <tt>null</tt> value,</li>
7660<li>or, a <tt>missing</tt> value.</li>
7661</ul>
7662</li>
7663</ul>
7664</li>
7665<li>Return Value:
7666<ul>
7667
7668<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
7669<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7670<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7671<li>any other non-array and non-multiset input value will cause a type error,</li>
7672<li>any other non-numeric value in the input collection will cause a type error.</li>
7673</ul>
7674</li>
7675<li>
7676
7677<p>Example:</p>
7678
7679<div>
7680<div>
7681<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
7682</pre></div></div>
7683</li>
7684<li>
7685
7686<p>The expected result is:</p>
7687
7688<div>
7689<div>
7690<pre class="source">1.725
7691</pre></div></div>
7692</li>
7693</ul></div>
7694<div class="section">
7695<h3><a name="array_sum"></a>array_sum</h3>
7696<ul>
7697
7698<li>
7699
7700<p>Syntax:</p>
7701
7702<div>
7703<div>
7704<pre class="source">array_sum(num_collection)
7705</pre></div></div>
7706</li>
7707<li>
7708
7709<p>Gets the sum of non-null and non-missing items in the given collection.</p>
7710</li>
7711<li>Arguments:
7712<ul>
7713
7714<li><tt>num_collection</tt> could be:
7715<ul>
7716
7717<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7718<li>or, a <tt>null</tt> value,</li>
7719<li>or, a <tt>missing</tt> value.</li>
7720</ul>
7721</li>
7722</ul>
7723</li>
7724<li>Return Value:
7725<ul>
7726
7727<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>
7728<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7729<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7730<li>any other non-array and non-multiset input value will cause a type error,</li>
7731<li>any other non-numeric value in the input collection will cause a type error.</li>
7732</ul>
7733</li>
7734<li>
7735
7736<p>Example:</p>
7737
7738<div>
7739<div>
7740<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
7741</pre></div></div>
7742</li>
7743<li>
7744
7745<p>The expected result is:</p>
7746
7747<div>
7748<div>
7749<pre class="source">6.9
7750</pre></div></div>
7751</li>
7752</ul></div>
7753<div class="section">
7754<h3><a name="array_min"></a>array_min</h3>
7755<ul>
7756
7757<li>
7758
7759<p>Syntax:</p>
7760
7761<div>
7762<div>
7763<pre class="source">array_min(num_collection)
7764</pre></div></div>
7765</li>
7766<li>
7767
7768<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
7769</li>
7770<li>Arguments:
7771<ul>
7772
7773<li><tt>num_collection</tt> could be:
7774<ul>
7775
7776<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7777<li>or, a <tt>null</tt> value,</li>
7778<li>or, a <tt>missing</tt> value.</li>
7779</ul>
7780</li>
7781</ul>
7782</li>
7783<li>Return Value:
7784<ul>
7785
7786<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>
7787<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7788<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7789<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7790<li>any other non-array and non-multiset input value will cause a type error.</li>
7791</ul>
7792</li>
7793<li>
7794
7795<p>Example:</p>
7796
7797<div>
7798<div>
7799<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
7800</pre></div></div>
7801</li>
7802<li>
7803
7804<p>The expected result is:</p>
7805
7806<div>
7807<div>
7808<pre class="source">0.0
7809</pre></div></div>
7810</li>
7811</ul></div>
7812<div class="section">
7813<h3><a name="array_max"></a>array_max</h3>
7814<ul>
7815
7816<li>
7817
7818<p>Syntax:</p>
7819
7820<div>
7821<div>
7822<pre class="source">array_max(num_collection)
7823</pre></div></div>
7824</li>
7825<li>
7826
7827<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
7828</li>
7829<li>Arguments:
7830<ul>
7831
7832<li><tt>num_collection</tt> could be:
7833<ul>
7834
7835<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7836<li>or, a <tt>null</tt> value,</li>
7837<li>or, a <tt>missing</tt> value.</li>
7838</ul>
7839</li>
7840</ul>
7841</li>
7842<li>Return Value:
7843<ul>
7844
7845<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>
7846<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7847<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7848<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7849<li>any other non-array and non-multiset input value will cause a type error.</li>
7850</ul>
7851</li>
7852<li>
7853
7854<p>Example:</p>
7855
7856<div>
7857<div>
7858<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
7859</pre></div></div>
7860</li>
7861<li>
7862
7863<p>The expected result is:</p>
7864
7865<div>
7866<div>
7867<pre class="source">3.4
7868</pre></div></div>
7869</li>
7870</ul></div>
7871<div class="section">
7872<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
7873<ul>
7874
7875<li>
7876
7877<p>Syntax:</p>
7878
7879<div>
7880<div>
7881<pre class="source">array_stddev_samp(num_collection)
7882</pre></div></div>
7883</li>
7884<li>
7885
7886<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
7887</li>
7888<li>Arguments:
7889<ul>
7890
7891<li><tt>num_collection</tt> could be:
7892<ul>
7893
7894<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7895<li>or, a <tt>null</tt> value,</li>
7896<li>or, a <tt>missing</tt> value.</li>
7897</ul>
7898</li>
7899</ul>
7900</li>
7901<li>Return Value:
7902<ul>
7903
7904<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
7905<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7906<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7907<li>any other non-array and non-multiset input value will cause a type error,</li>
7908<li>any other non-numeric value in the input collection will cause a type error.</li>
7909</ul>
7910</li>
7911<li>
7912
7913<p>Example:</p>
7914
7915<div>
7916<div>
7917<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
7918</pre></div></div>
7919</li>
7920<li>
7921
7922<p>The expected result is:</p>
7923
7924<div>
7925<div>
7926<pre class="source">1.4591664287073858
7927</pre></div></div>
7928</li>
7929</ul></div>
7930<div class="section">
7931<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
7932<ul>
7933
7934<li>
7935
7936<p>Syntax:</p>
7937
7938<div>
7939<div>
7940<pre class="source">array_stddev_pop(num_collection)
7941</pre></div></div>
7942</li>
7943<li>
7944
7945<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
7946</li>
7947<li>Arguments:
7948<ul>
7949
7950<li><tt>num_collection</tt> could be:
7951<ul>
7952
7953<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7954<li>or, a <tt>null</tt> value,</li>
7955<li>or, a <tt>missing</tt> value.</li>
7956</ul>
7957</li>
7958</ul>
7959</li>
7960<li>Return Value:
7961<ul>
7962
7963<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
7964<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7965<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7966<li>any other non-array and non-multiset input value will cause a type error,</li>
7967<li>any other non-numeric value in the input collection will cause a type error.</li>
7968</ul>
7969</li>
7970<li>
7971
7972<p>Example:</p>
7973
7974<div>
7975<div>
7976<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
7977</pre></div></div>
7978</li>
7979<li>
7980
7981<p>The expected result is:</p>
7982
7983<div>
7984<div>
7985<pre class="source">1.2636751956100112
7986</pre></div></div>
7987</li>
7988</ul></div>
7989<div class="section">
7990<h3><a name="array_var_samp"></a>array_var_samp</h3>
7991<ul>
7992
7993<li>
7994
7995<p>Syntax:</p>
7996
7997<div>
7998<div>
7999<pre class="source">array_var_samp(num_collection)
8000</pre></div></div>
8001</li>
8002<li>
8003
8004<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
8005</li>
8006<li>Arguments:
8007<ul>
8008
8009<li><tt>num_collection</tt> could be:
8010<ul>
8011
8012<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8013<li>or, a <tt>null</tt> value,</li>
8014<li>or, a <tt>missing</tt> value.</li>
8015</ul>
8016</li>
8017</ul>
8018</li>
8019<li>Return Value:
8020<ul>
8021
8022<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
8023<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8024<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8025<li>any other non-array and non-multiset input value will cause a type error,</li>
8026<li>any other non-numeric value in the input collection will cause a type error.</li>
8027</ul>
8028</li>
8029<li>
8030
8031<p>Example:</p>
8032
8033<div>
8034<div>
8035<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
8036</pre></div></div>
8037</li>
8038<li>
8039
8040<p>The expected result is:</p>
8041
8042<div>
8043<div>
8044<pre class="source">2.1291666666666664
8045</pre></div></div>
8046</li>
8047</ul></div>
8048<div class="section">
8049<h3><a name="array_var_pop"></a>array_var_pop</h3>
8050<ul>
8051
8052<li>
8053
8054<p>Syntax:</p>
8055
8056<div>
8057<div>
8058<pre class="source">array_var_pop(num_collection)
8059</pre></div></div>
8060</li>
8061<li>
8062
8063<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
8064</li>
8065<li>Arguments:
8066<ul>
8067
8068<li><tt>num_collection</tt> could be:
8069<ul>
8070
8071<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8072<li>or, a <tt>null</tt> value,</li>
8073<li>or, a <tt>missing</tt> value.</li>
8074</ul>
8075</li>
8076</ul>
8077</li>
8078<li>Return Value:
8079<ul>
8080
8081<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
8082<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8083<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8084<li>any other non-array and non-multiset input value will cause a type error,</li>
8085<li>any other non-numeric value in the input collection will cause a type error.</li>
8086</ul>
8087</li>
8088<li>
8089
8090<p>Example:</p>
8091
8092<div>
8093<div>
8094<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
8095</pre></div></div>
8096</li>
8097<li>
8098
8099<p>The expected result is:</p>
8100
8101<div>
8102<div>
8103<pre class="source">1.5968749999999998
8104</pre></div></div>
8105</li>
8106</ul></div>
8107<div class="section">
8108<h3><a name="array_skewness"></a>array_skewness</h3>
8109<ul>
8110
8111<li>
8112
8113<p>Syntax:</p>
8114
8115<div>
8116<div>
8117<pre class="source">array_skewness(num_collection)
8118</pre></div></div>
8119</li>
8120<li>
8121
8122<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
8123</li>
8124<li>Arguments:
8125<ul>
8126
8127<li><tt>num_collection</tt> could be:
8128<ul>
8129
8130<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8131<li>or, a <tt>null</tt> value,</li>
8132<li>or, a <tt>missing</tt> value.</li>
8133</ul>
8134</li>
8135</ul>
8136</li>
8137<li>Return Value:
8138<ul>
8139
8140<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
8141<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8142<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8143<li>any other non-array and non-multiset input value will cause a type error,</li>
8144<li>any other non-numeric value in the input collection will cause a type error.</li>
8145</ul>
8146</li>
8147<li>
8148
8149<p>Example:</p>
8150
8151<div>
8152<div>
8153<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
8154</pre></div></div>
8155</li>
8156<li>
8157
8158<p>The expected result is:</p>
8159
8160<div>
8161<div>
8162<pre class="source">-0.04808451539164242
8163</pre></div></div>
8164</li>
8165</ul></div>
8166<div class="section">
8167<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
8168<ul>
8169
8170<li>
8171
8172<p>Syntax:</p>
8173
8174<div>
8175<div>
8176<pre class="source">array_kurtosis(num_collection)
8177</pre></div></div>
8178</li>
8179<li>
8180
8181<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
8182</li>
8183<li>Arguments:
8184<ul>
8185
8186<li><tt>num_collection</tt> could be:
8187<ul>
8188
8189<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8190<li>or, a <tt>null</tt> value,</li>
8191<li>or, a <tt>missing</tt> value.</li>
8192</ul>
8193</li>
8194</ul>
8195</li>
8196<li>Return Value:
8197<ul>
8198
8199<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>
8200<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8201<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8202<li>any other non-array and non-multiset input value will cause a type error,</li>
8203<li>any other non-numeric value in the input collection will cause a type error.</li>
8204</ul>
8205</li>
8206<li>
8207
8208<p>Example:</p>
8209
8210<div>
8211<div>
8212<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
8213</pre></div></div>
8214</li>
8215<li>
8216
8217<p>The expected result is:</p>
8218
8219<div>
8220<div>
8221<pre class="source">-1.342049701096427
8222</pre></div></div>
8223</li>
8224</ul></div>
8225<div class="section">
8226<h3><a name="strict_count"></a>strict_count</h3>
8227<ul>
8228
8229<li>
8230
8231<p>Syntax:</p>
8232
8233<div>
8234<div>
8235<pre class="source">strict_count(collection)
8236</pre></div></div>
8237</li>
8238<li>
8239
8240<p>Gets the number of items in the given collection.</p>
8241</li>
8242<li>Arguments:
8243<ul>
8244
8245<li><tt>collection</tt> could be:
8246<ul>
8247
8248<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
8249<li>or a <tt>null</tt> value,</li>
8250<li>or a <tt>missing</tt> value.</li>
8251</ul>
8252</li>
8253</ul>
8254</li>
8255<li>Return Value:
8256<ul>
8257
8258<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
8259<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
8260</ul>
8261</li>
8262<li>
8263
8264<p>Example:</p>
8265
8266<div>
8267<div>
8268<pre class="source">strict_count( [1, 2, null, missing] );
8269</pre></div></div>
8270</li>
8271<li>
8272
8273<p>The expected result is:</p>
8274
8275<div>
8276<div>
8277<pre class="source">4
8278</pre></div></div>
8279</li>
8280</ul></div>
8281<div class="section">
8282<h3><a name="strict_avg"></a>strict_avg</h3>
8283<ul>
8284
8285<li>
8286
8287<p>Syntax:</p>
8288
8289<div>
8290<div>
8291<pre class="source">strict_avg(num_collection)
8292</pre></div></div>
8293</li>
8294<li>
8295
8296<p>Gets the average value of the numeric items in the given collection.</p>
8297</li>
8298<li>Arguments:
8299<ul>
8300
8301<li><tt>num_collection</tt> could be:
8302<ul>
8303
8304<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8305<li>or, a <tt>null</tt> value,</li>
8306<li>or, a <tt>missing</tt> value.</li>
8307</ul>
8308</li>
8309</ul>
8310</li>
8311<li>Return Value:
8312<ul>
8313
8314<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
8315<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8316<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8317<li>any other non-numeric value in the input collection will cause a type error.</li>
8318</ul>
8319</li>
8320<li>
8321
8322<p>Example:</p>
8323
8324<div>
8325<div>
8326<pre class="source">strict_avg( [100, 200, 300] );
8327</pre></div></div>
8328</li>
8329<li>
8330
8331<p>The expected result is:</p>
8332
8333<div>
8334<div>
8335<pre class="source">200.0
8336</pre></div></div>
8337</li>
8338</ul></div>
8339<div class="section">
8340<h3><a name="strict_sum"></a>strict_sum</h3>
8341<ul>
8342
8343<li>
8344
8345<p>Syntax:</p>
8346
8347<div>
8348<div>
8349<pre class="source">strict_sum(num_collection)
8350</pre></div></div>
8351</li>
8352<li>
8353
8354<p>Gets the sum of the items in the given collection.</p>
8355</li>
8356<li>Arguments:
8357<ul>
8358
8359<li><tt>num_collection</tt> could be:
8360<ul>
8361
8362<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8363<li>or, a <tt>null</tt> value,</li>
8364<li>or, a <tt>missing</tt> value.</li>
8365</ul>
8366</li>
8367</ul>
8368</li>
8369<li>Return Value:
8370<ul>
8371
8372<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>
8373<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8374<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8375<li>any other non-numeric value in the input collection will cause a type error.</li>
8376</ul>
8377</li>
8378<li>
8379
8380<p>Example:</p>
8381
8382<div>
8383<div>
8384<pre class="source">strict_sum( [100, 200, 300] );
8385</pre></div></div>
8386</li>
8387<li>
8388
8389<p>The expected result is:</p>
8390
8391<div>
8392<div>
8393<pre class="source">600
8394</pre></div></div>
8395</li>
8396</ul></div>
8397<div class="section">
8398<h3><a name="strict_min"></a>strict_min</h3>
8399<ul>
8400
8401<li>
8402
8403<p>Syntax:</p>
8404
8405<div>
8406<div>
8407<pre class="source">strict_min(num_collection)
8408</pre></div></div>
8409</li>
8410<li>
8411
8412<p>Gets the min value of comparable items in the given collection.</p>
8413</li>
8414<li>Arguments:
8415<ul>
8416
8417<li><tt>num_collection</tt> could be:
8418<ul>
8419
8420<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8421<li>or, a <tt>null</tt> value,</li>
8422<li>or, a <tt>missing</tt> value.</li>
8423</ul>
8424</li>
8425</ul>
8426</li>
8427<li>Return Value:
8428<ul>
8429
8430<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>
8431<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8432<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8433<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8434<li>any other non-array and non-multiset input value will cause a type error.</li>
8435</ul>
8436</li>
8437<li>
8438
8439<p>Example:</p>
8440
8441<div>
8442<div>
8443<pre class="source">strict_min( [10.2, 100, 5] );
8444</pre></div></div>
8445</li>
8446<li>
8447
8448<p>The expected result is:</p>
8449
8450<div>
8451<div>
8452<pre class="source">5.0
8453</pre></div></div>
8454</li>
8455</ul></div>
8456<div class="section">
8457<h3><a name="strict_max"></a>strict_max</h3>
8458<ul>
8459
8460<li>
8461
8462<p>Syntax:</p>
8463
8464<div>
8465<div>
8466<pre class="source">strict_max(num_collection)
8467</pre></div></div>
8468</li>
8469<li>
8470
8471<p>Gets the max value of numeric items in the given collection.</p>
8472</li>
8473<li>Arguments:
8474<ul>
8475
8476<li><tt>num_collection</tt> could be:
8477<ul>
8478
8479<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8480<li>or, a <tt>null</tt> value,</li>
8481<li>or, a <tt>missing</tt> value.</li>
8482</ul>
8483</li>
8484</ul>
8485</li>
8486<li>Return Value:
8487<ul>
8488
8489<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>
8490<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8491<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8492<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8493<li>any other non-array and non-multiset input value will cause a type error.</li>
8494</ul>
8495</li>
8496<li>
8497
8498<p>Example:</p>
8499
8500<div>
8501<div>
8502<pre class="source">strict_max( [10.2, 100, 5] );
8503</pre></div></div>
8504</li>
8505<li>
8506
8507<p>The expected result is:</p>
8508
8509<div>
8510<div>
8511<pre class="source">100.0
8512</pre></div></div>
8513</li>
8514</ul></div>
8515<div class="section">
8516<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
8517<ul>
8518
8519<li>
8520
8521<p>Syntax:</p>
8522
8523<div>
8524<div>
8525<pre class="source">strict_stddev_samp(num_collection)
8526</pre></div></div>
8527</li>
8528<li>
8529
8530<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
8531</li>
8532<li>Arguments:
8533<ul>
8534
8535<li><tt>num_collection</tt> could be:
8536<ul>
8537
8538<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8539<li>or, a <tt>null</tt> value,</li>
8540<li>or, a <tt>missing</tt> value.</li>
8541</ul>
8542</li>
8543</ul>
8544</li>
8545<li>Return Value:
8546<ul>
8547
8548<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
8549<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8550<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8551<li>any other non-numeric value in the input collection will cause a type error.</li>
8552</ul>
8553</li>
8554<li>
8555
8556<p>Example:</p>
8557
8558<div>
8559<div>
8560<pre class="source">strict_stddev_samp( [100, 200, 300] );
8561</pre></div></div>
8562</li>
8563<li>
8564
8565<p>The expected result is:</p>
8566
8567<div>
8568<div>
8569<pre class="source">100.0
8570</pre></div></div>
8571</li>
8572</ul></div>
8573<div class="section">
8574<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
8575<ul>
8576
8577<li>
8578
8579<p>Syntax:</p>
8580
8581<div>
8582<div>
8583<pre class="source">strict_stddev_pop(num_collection)
8584</pre></div></div>
8585</li>
8586<li>
8587
8588<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
8589</li>
8590<li>Arguments:
8591<ul>
8592
8593<li><tt>num_collection</tt> could be:
8594<ul>
8595
8596<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8597<li>or, a <tt>null</tt> value,</li>
8598<li>or, a <tt>missing</tt> value.</li>
8599</ul>
8600</li>
8601</ul>
8602</li>
8603<li>Return Value:
8604<ul>
8605
8606<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
8607<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8608<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8609<li>any other non-numeric value in the input collection will cause a type error.</li>
8610</ul>
8611</li>
8612<li>
8613
8614<p>Example:</p>
8615
8616<div>
8617<div>
8618<pre class="source">strict_stddev_pop( [100, 200, 300] );
8619</pre></div></div>
8620</li>
8621<li>
8622
8623<p>The expected result is:</p>
8624
8625<div>
8626<div>
8627<pre class="source">81.64965809277261
8628</pre></div></div>
8629</li>
8630</ul></div>
8631<div class="section">
8632<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
8633<ul>
8634
8635<li>
8636
8637<p>Syntax:</p>
8638
8639<div>
8640<div>
8641<pre class="source">strict_var_samp(num_collection)
8642</pre></div></div>
8643</li>
8644<li>
8645
8646<p>Gets the sample variance value of the numeric items in the given collection.</p>
8647</li>
8648<li>Arguments:
8649<ul>
8650
8651<li><tt>num_collection</tt> could be:
8652<ul>
8653
8654<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8655<li>or, a <tt>null</tt> value,</li>
8656<li>or, a <tt>missing</tt> value.</li>
8657</ul>
8658</li>
8659</ul>
8660</li>
8661<li>Return Value:
8662<ul>
8663
8664<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
8665<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8666<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8667<li>any other non-numeric value in the input collection will cause a type error.</li>
8668</ul>
8669</li>
8670<li>
8671
8672<p>Example:</p>
8673
8674<div>
8675<div>
8676<pre class="source">strict_var_samp( [100, 200, 300] );
8677</pre></div></div>
8678</li>
8679<li>
8680
8681<p>The expected result is:</p>
8682
8683<div>
8684<div>
8685<pre class="source">10000.0
8686</pre></div></div>
8687</li>
8688</ul></div>
8689<div class="section">
8690<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
8691<ul>
8692
8693<li>
8694
8695<p>Syntax:</p>
8696
8697<div>
8698<div>
8699<pre class="source">strict_var_pop(num_collection)
8700</pre></div></div>
8701</li>
8702<li>
8703
8704<p>Gets the population variance value of the numeric items in the given collection.</p>
8705</li>
8706<li>Arguments:
8707<ul>
8708
8709<li><tt>num_collection</tt> could be:
8710<ul>
8711
8712<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8713<li>or, a <tt>null</tt> value,</li>
8714<li>or, a <tt>missing</tt> value.</li>
8715</ul>
8716</li>
8717</ul>
8718</li>
8719<li>Return Value:
8720<ul>
8721
8722<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
8723<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8724<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8725<li>any other non-numeric value in the input collection will cause a type error.</li>
8726</ul>
8727</li>
8728<li>
8729
8730<p>Example:</p>
8731
8732<div>
8733<div>
8734<pre class="source">strict_var_pop( [100, 200, 300] );
8735</pre></div></div>
8736</li>
8737<li>
8738
8739<p>The expected result is:</p>
8740
8741<div>
8742<div>
8743<pre class="source">6666.666666666667
8744</pre></div></div>
8745</li>
8746</ul></div>
8747<div class="section">
8748<h3><a name="strict_skewness"></a>strict_skewness</h3>
8749<ul>
8750
8751<li>
8752
8753<p>Syntax:</p>
8754
8755<div>
8756<div>
8757<pre class="source">strict_skewness(num_collection)
8758</pre></div></div>
8759</li>
8760<li>
8761
8762<p>Gets the skewness value of the numeric items in the given collection.</p>
8763</li>
8764<li>Arguments:
8765<ul>
8766
8767<li><tt>num_collection</tt> could be:
8768<ul>
8769
8770<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8771<li>or, a <tt>null</tt> value,</li>
8772<li>or, a <tt>missing</tt> value.</li>
8773</ul>
8774</li>
8775</ul>
8776</li>
8777<li>Return Value:
8778<ul>
8779
8780<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
8781<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8782<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8783<li>any other non-numeric value in the input collection will cause a type error.</li>
8784</ul>
8785</li>
8786<li>
8787
8788<p>Example:</p>
8789
8790<div>
8791<div>
8792<pre class="source">strict_skewness( [100, 200, 300] );
8793</pre></div></div>
8794</li>
8795<li>
8796
8797<p>The expected result is:</p>
8798
8799<div>
8800<div>
8801<pre class="source">0.0
8802</pre></div></div>
8803</li>
8804</ul></div>
8805<div class="section">
8806<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
8807<ul>
8808
8809<li>
8810
8811<p>Syntax:</p>
8812
8813<div>
8814<div>
8815<pre class="source">strict_kurtosis(num_collection)
8816</pre></div></div>
8817</li>
8818<li>
8819
8820<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
8821</li>
8822<li>Arguments:
8823<ul>
8824
8825<li><tt>num_collection</tt> could be:
8826<ul>
8827
8828<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8829<li>or, a <tt>null</tt> value,</li>
8830<li>or, a <tt>missing</tt> value.</li>
8831</ul>
8832</li>
8833</ul>
8834</li>
8835<li>Return Value:
8836<ul>
8837
8838<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
8839<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8840<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8841<li>any other non-numeric value in the input collection will cause a type error.</li>
8842</ul>
8843</li>
8844<li>
8845
8846<p>Example:</p>
8847
8848<div>
8849<div>
8850<pre class="source">strict_kurtosis( [100, 200, 300] );
8851</pre></div></div>
8852</li>
8853<li>
8854
8855<p>The expected result is:</p>
8856
8857<div>
8858<div>
8859<pre class="source">-1.5
8860</pre></div></div>
8861</li>
8862</ul><!--
8863 ! Licensed to the Apache Software Foundation (ASF) under one
8864 ! or more contributor license agreements. See the NOTICE file
8865 ! distributed with this work for additional information
8866 ! regarding copyright ownership. The ASF licenses this file
8867 ! to you under the Apache License, Version 2.0 (the
8868 ! "License"); you may not use this file except in compliance
8869 ! with the License. You may obtain a copy of the License at
8870 !
8871 ! http://www.apache.org/licenses/LICENSE-2.0
8872 !
8873 ! Unless required by applicable law or agreed to in writing,
8874 ! software distributed under the License is distributed on an
8875 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8876 ! KIND, either express or implied. See the License for the
8877 ! specific language governing permissions and limitations
8878 ! under the License.
8879 !-->
8880</div></div>
8881<div class="section">
8882<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
8883<div class="section">
8884<h3><a name="greatest"></a>greatest</h3>
8885<ul>
8886
8887<li>
8888
8889<p>Syntax:</p>
8890
8891<div>
8892<div>
8893<pre class="source">greatest(numeric_value1, numeric_value2, ...)
8894</pre></div></div>
8895</li>
8896<li>
8897
8898<p>Computes the greatest value among arguments.</p>
8899</li>
8900<li>Arguments:
8901<ul>
8902
8903<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>
8904<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>
8905<li>&#x2026;.</li>
8906</ul>
8907</li>
8908<li>Return Value:
8909<ul>
8910
8911<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>
8912<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
8913<li>any other non-numeric input value will cause a type error.</li>
8914</ul>
8915</li>
8916<li>
8917
8918<p>Example:</p>
8919
8920<div>
8921<div>
8922<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) };
8923</pre></div></div>
8924</li>
8925<li>
8926
8927<p>The expected result is:</p>
8928
8929<div>
8930<div>
8931<pre class="source">{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
8932</pre></div></div>
8933</li>
8934</ul></div>
8935<div class="section">
8936<h3><a name="least"></a>least</h3>
8937<ul>
8938
8939<li>
8940
8941<p>Syntax:</p>
8942
8943<div>
8944<div>
8945<pre class="source">least(numeric_value1, numeric_value2, ...)
8946</pre></div></div>
8947</li>
8948<li>
8949
8950<p>Computes the least value among arguments.</p>
8951</li>
8952<li>Arguments:
8953<ul>
8954
8955<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>
8956<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>
8957<li>&#x2026;.</li>
8958</ul>
8959</li>
8960<li>Return Value:
8961<ul>
8962
8963<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>
8964<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
8965<li>any other non-numeric input value will cause a type error.</li>
8966</ul>
8967</li>
8968<li>
8969
8970<p>Example:</p>
8971
8972<div>
8973<div>
8974<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) };
8975</pre></div></div>
8976</li>
8977<li>
8978
8979<p>The expected result is:</p>
8980
8981<div>
8982<div>
8983<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
8984</pre></div></div>
8985</li>
8986</ul><!--
8987 ! Licensed to the Apache Software Foundation (ASF) under one
8988 ! or more contributor license agreements. See the NOTICE file
8989 ! distributed with this work for additional information
8990 ! regarding copyright ownership. The ASF licenses this file
8991 ! to you under the Apache License, Version 2.0 (the
8992 ! "License"); you may not use this file except in compliance
8993 ! with the License. You may obtain a copy of the License at
8994 !
8995 ! http://www.apache.org/licenses/LICENSE-2.0
8996 !
8997 ! Unless required by applicable law or agreed to in writing,
8998 ! software distributed under the License is distributed on an
8999 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9000 ! KIND, either express or implied. See the License for the
9001 ! specific language governing permissions and limitations
9002 ! under the License.
9003 !-->
9004</div></div>
9005<div class="section">
9006<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
9007<div class="section">
9008<h3><a name="get_type"></a>get_type</h3>
9009<ul>
9010
9011<li>
9012
9013<p>Syntax:</p>
9014
9015<div>
9016<div>
9017<pre class="source">get_type(expr)
9018</pre></div></div>
9019</li>
9020<li>
9021
9022<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>
9023</li>
9024<li>Arguments:
9025<ul>
9026
9027<li><tt>expr</tt> : an expression (any type is allowed).</li>
9028</ul>
9029</li>
9030<li>
9031
9032<p>Example:</p>
9033
9034<div>
9035<div>
9036<pre class="source">{
9037 &quot;a&quot;: get_type(true),
9038 &quot;b&quot;: get_type(false),
9039 &quot;c&quot;: get_type(null),
9040 &quot;d&quot;: get_type(missing),
9041 &quot;e&quot;: get_type(&quot;d&quot;),
9042 &quot;f&quot;: gettype(4.0),
9043 &quot;g&quot;: gettype(5),
9044 &quot;h&quot;: gettype([&quot;1&quot;, 2]),
9045 &quot;i&quot;: gettype({&quot;a&quot;:1})
9046};
9047</pre></div></div>
9048</li>
9049<li>
9050
9051<p>The expected result is:</p>
9052
9053<div>
9054<div>
9055<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; }
9056</pre></div></div>
9057</li>
9058</ul>
9059<p>The function has an alias <tt>gettype</tt>.</p></div>
9060<div class="section">
9061<h3><a name="is_array"></a>is_array</h3>
9062<ul>
9063
9064<li>
9065
9066<p>Syntax:</p>
9067
9068<div>
9069<div>
9070<pre class="source">is_array(expr)
9071</pre></div></div>
9072</li>
9073<li>
9074
9075<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
9076</li>
9077<li>Arguments:
9078<ul>
9079
9080<li><tt>expr</tt> : an expression (any type is allowed).</li>
9081</ul>
9082</li>
9083<li>Return Value:
9084<ul>
9085
9086<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
9087<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9088<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9089</ul>
9090</li>
9091<li>
9092
9093<p>Example:</p>
9094
9095<div>
9096<div>
9097<pre class="source">{
9098 &quot;a&quot;: is_array(true),
9099 &quot;b&quot;: is_array(false),
9100 &quot;c&quot;: isarray(null),
9101 &quot;d&quot;: isarray(missing),
9102 &quot;e&quot;: isarray(&quot;d&quot;),
9103 &quot;f&quot;: isarray(4.0),
9104 &quot;g&quot;: isarray(5),
9105 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
9106 &quot;i&quot;: isarray({&quot;a&quot;:1})
9107};
9108</pre></div></div>
9109</li>
9110<li>
9111
9112<p>The expected result is:</p>
9113
9114<div>
9115<div>
9116<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 }
9117</pre></div></div>
9118</li>
9119</ul>
9120<p>The function has an alias <tt>isarray</tt>.</p></div>
9121<div class="section">
9122<h3><a name="is_multiset"></a>is_multiset</h3>
9123<ul>
9124
9125<li>
9126
9127<p>Syntax:</p>
9128
9129<div>
9130<div>
9131<pre class="source">is_multiset(expr)
9132</pre></div></div>
9133</li>
9134<li>
9135
9136<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
9137</li>
9138<li>Arguments:
9139<ul>
9140
9141<li><tt>expr</tt> : an expression (any type is allowed).</li>
9142</ul>
9143</li>
9144<li>Return Value:
9145<ul>
9146
9147<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
9148<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9149<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9150</ul>
9151</li>
9152<li>
9153
9154<p>Example:</p>
9155
9156<div>
9157<div>
9158<pre class="source">{
9159 &quot;a&quot;: is_multiset(true),
9160 &quot;b&quot;: is_multiset(false),
9161 &quot;c&quot;: is_multiset(null),
9162 &quot;d&quot;: is_multiset(missing),
9163 &quot;e&quot;: is_multiset(&quot;d&quot;),
9164 &quot;f&quot;: ismultiset(4.0),
9165 &quot;g&quot;: ismultiset([&quot;1&quot;, 2]),
9166 &quot;h&quot;: ismultiset({&quot;a&quot;:1}),
9167 &quot;i&quot;: ismultiset({{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}})
9168};
9169</pre></div></div>
9170</li>
9171<li>
9172
9173<p>The expected result is:</p>
9174
9175<div>
9176<div>
9177<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 }
9178</pre></div></div>
9179</li>
9180</ul>
9181<p>The function has an alias <tt>ismultiset</tt>.</p></div>
9182<div class="section">
9183<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
9184<ul>
9185
9186<li>
9187
9188<p>Syntax:</p>
9189
9190<div>
9191<div>
9192<pre class="source">is_atomic(expr)
9193</pre></div></div>
9194</li>
9195<li>
9196
9197<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
9198</li>
9199<li>Arguments:
9200<ul>
9201
9202<li><tt>expr</tt> : an expression (any type is allowed).</li>
9203</ul>
9204</li>
9205<li>Return Value:
9206<ul>
9207
9208<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
9209<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9210<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9211</ul>
9212</li>
9213<li>
9214
9215<p>Example:</p>
9216
9217<div>
9218<div>
9219<pre class="source">{
9220 &quot;a&quot;: is_atomic(true),
9221 &quot;b&quot;: is_atomic(false),
9222 &quot;c&quot;: isatomic(null),
9223 &quot;d&quot;: isatomic(missing),
9224 &quot;e&quot;: isatomic(&quot;d&quot;),
9225 &quot;f&quot;: isatom(4.0),
9226 &quot;g&quot;: isatom(5),
9227 &quot;h&quot;: isatom([&quot;1&quot;, 2]),
9228 &quot;i&quot;: isatom({&quot;a&quot;:1})
9229};
9230</pre></div></div>
9231</li>
9232<li>
9233
9234<p>The expected result is:</p>
9235
9236<div>
9237<div>
9238<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 }
9239</pre></div></div>
9240</li>
9241</ul>
9242<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
9243<div class="section">
9244<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
9245<ul>
9246
9247<li>
9248
9249<p>Syntax:</p>
9250
9251<div>
9252<div>
9253<pre class="source">is_boolean(expr)
9254</pre></div></div>
9255</li>
9256<li>
9257
9258<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
9259</li>
9260<li>Arguments:
9261<ul>
9262
9263<li><tt>expr</tt> : an expression (any type is allowed).</li>
9264</ul>
9265</li>
9266<li>Return Value:
9267<ul>
9268
9269<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
9270<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9271<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9272</ul>
9273</li>
9274<li>
9275
9276<p>Example:</p>
9277
9278<div>
9279<div>
9280<pre class="source">{
9281 &quot;a&quot;: isboolean(true),
9282 &quot;b&quot;: isboolean(false),
9283 &quot;c&quot;: is_boolean(null),
9284 &quot;d&quot;: is_boolean(missing),
9285 &quot;e&quot;: isbool(&quot;d&quot;),
9286 &quot;f&quot;: isbool(4.0),
9287 &quot;g&quot;: isbool(5),
9288 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
9289 &quot;i&quot;: isbool({&quot;a&quot;:1})
9290};
9291</pre></div></div>
9292</li>
9293<li>
9294
9295<p>The expected result is:</p>
9296
9297<div>
9298<div>
9299<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 }
9300</pre></div></div>
9301</li>
9302</ul>
9303<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
9304<div class="section">
9305<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
9306<ul>
9307
9308<li>
9309
9310<p>Syntax:</p>
9311
9312<div>
9313<div>
9314<pre class="source">is_binary(expr)
9315</pre></div></div>
9316</li>
9317<li>
9318
9319<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
9320</li>
9321<li>Arguments:
9322<ul>
9323
9324<li><tt>expr</tt> : an expression (any type is allowed).</li>
9325</ul>
9326</li>
9327<li>Return Value:
9328<ul>
9329
9330<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
9331<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9332<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9333</ul>
9334</li>
9335<li>
9336
9337<p>Example:</p>
9338
9339<div>
9340<div>
9341<pre class="source">{
9342 &quot;a&quot;: is_binary(true),
9343 &quot;b&quot;: is_binary(false),
9344 &quot;c&quot;: isbinary(null),
9345 &quot;d&quot;: isbinary(missing),
9346 &quot;e&quot;: isbin(point(&quot;1,2&quot;)),
9347 &quot;f&quot;: isbin(hex(&quot;ABCDEF0123456789&quot;)),
9348 &quot;g&quot;: is_bin(sub_binary(hex(&quot;AABBCCDD&quot;), 4)),
9349 &quot;h&quot;: is_bin(2),
9350 &quot;i&quot;: is_bin({&quot;a&quot;:1})
9351};
9352</pre></div></div>
9353</li>
9354<li>
9355
9356<p>The expected result is:</p>
9357
9358<div>
9359<div>
9360<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 }
9361</pre></div></div>
9362</li>
9363</ul>
9364<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
9365<div class="section">
9366<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
9367<ul>
9368
9369<li>
9370
9371<p>Syntax:</p>
9372
9373<div>
9374<div>
9375<pre class="source">is_number(expr)
9376</pre></div></div>
9377</li>
9378<li>
9379
9380<p>Checks whether the given expression is evaluated to be a numeric value.</p>
9381</li>
9382<li>Arguments:
9383<ul>
9384
9385<li><tt>expr</tt> : an expression (any type is allowed).</li>
9386</ul>
9387</li>
9388<li>Return Value:
9389<ul>
9390
9391<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>
9392<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9393<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9394</ul>
9395</li>
9396<li>
9397
9398<p>Example:</p>
9399
9400<div>
9401<div>
9402<pre class="source">{
9403 &quot;a&quot;: is_number(true),
9404 &quot;b&quot;: is_number(false),
9405 &quot;c&quot;: isnumber(null),
9406 &quot;d&quot;: isnumber(missing),
9407 &quot;e&quot;: isnumber(&quot;d&quot;),
9408 &quot;f&quot;: isnum(4.0),
9409 &quot;g&quot;: isnum(5),
9410 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
9411 &quot;i&quot;: isnum({&quot;a&quot;:1})
9412};
9413</pre></div></div>
9414</li>
9415<li>
9416
9417<p>The expected result is:</p>
9418
9419<div>
9420<div>
9421<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 }
9422</pre></div></div>
9423</li>
9424</ul>
9425<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
9426<div class="section">
9427<h3><a name="is_point"></a>is_point</h3>
9428<ul>
9429
9430<li>
9431
9432<p>Syntax:</p>
9433
9434<div>
9435<div>
9436<pre class="source">is_point(expr)
9437</pre></div></div>
9438</li>
9439<li>
9440
9441<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
9442</li>
9443<li>Arguments:
9444<ul>
9445
9446<li><tt>expr</tt> : an expression (any type is allowed).</li>
9447</ul>
9448</li>
9449<li>Return Value:
9450<ul>
9451
9452<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
9453<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9454<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9455</ul>
9456</li>
9457<li>
9458
9459<p>Example:</p>
9460
9461<div>
9462<div>
9463<pre class="source">{
9464 &quot;a&quot;: is_point(true),
9465 &quot;b&quot;: is_point(false),
9466 &quot;c&quot;: is_point(null),
9467 &quot;d&quot;: is_point(missing),
9468 &quot;e&quot;: is_point(point(&quot;1,2&quot;)),
9469 &quot;f&quot;: ispoint(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9470 &quot;g&quot;: ispoint(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9471 &quot;h&quot;: ispoint(circle(&quot;30.0,70.0 5.0&quot;)),
9472 &quot;i&quot;: ispoint(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9473 &quot;j&quot;: ispoint(3)
9474};
9475</pre></div></div>
9476</li>
9477<li>
9478
9479<p>The expected result is:</p>
9480
9481<div>
9482<div>
9483<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 }
9484</pre></div></div>
9485</li>
9486</ul>
9487<p>The function has an alias <tt>ispoint</tt>.</p></div>
9488<div class="section">
9489<h3><a name="is_line"></a>is_line</h3>
9490<ul>
9491
9492<li>
9493
9494<p>Syntax:</p>
9495
9496<div>
9497<div>
9498<pre class="source">is_line(expr)
9499</pre></div></div>
9500</li>
9501<li>
9502
9503<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
9504</li>
9505<li>Arguments:
9506<ul>
9507
9508<li><tt>expr</tt> : an expression (any type is allowed).</li>
9509</ul>
9510</li>
9511<li>Return Value:
9512<ul>
9513
9514<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
9515<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9516<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9517</ul>
9518</li>
9519<li>
9520
9521<p>Example:</p>
9522
9523<div>
9524<div>
9525<pre class="source">{
9526 &quot;a&quot;: is_line(true),
9527 &quot;b&quot;: is_line(false),
9528 &quot;c&quot;: is_line(null),
9529 &quot;d&quot;: is_line(missing),
9530 &quot;e&quot;: is_line(point(&quot;1,2&quot;)),
9531 &quot;f&quot;: isline(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9532 &quot;g&quot;: isline(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9533 &quot;h&quot;: isline(circle(&quot;30.0,70.0 5.0&quot;)),
9534 &quot;i&quot;: isline(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9535 &quot;j&quot;: isline(3)
9536};
9537</pre></div></div>
9538</li>
9539<li>
9540
9541<p>The expected result is:</p>
9542
9543<div>
9544<div>
9545<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 }
9546</pre></div></div>
9547</li>
9548</ul>
9549<p>The function has an alias <tt>isline</tt>.</p></div>
9550<div class="section">
9551<h3><a name="is_rectangle"></a>is_rectangle</h3>
9552<ul>
9553
9554<li>
9555
9556<p>Syntax:</p>
9557
9558<div>
9559<div>
9560<pre class="source">is_rectangle(expr)
9561</pre></div></div>
9562</li>
9563<li>
9564
9565<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
9566</li>
9567<li>Arguments:
9568<ul>
9569
9570<li><tt>expr</tt> : an expression (any type is allowed).</li>
9571</ul>
9572</li>
9573<li>Return Value:
9574<ul>
9575
9576<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
9577<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9578<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9579</ul>
9580</li>
9581<li>
9582
9583<p>Example:</p>
9584
9585<div>
9586<div>
9587<pre class="source">{
9588 &quot;a&quot;: is_rectangle(true),
9589 &quot;b&quot;: is_rectangle(false),
9590 &quot;c&quot;: is_rectangle(null),
9591 &quot;d&quot;: is_rectangle(missing),
9592 &quot;e&quot;: is_rectangle(point(&quot;1,2&quot;)),
9593 &quot;f&quot;: isrectangle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9594 &quot;g&quot;: isrectangle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9595 &quot;h&quot;: isrectangle(circle(&quot;30.0,70.0 5.0&quot;)),
9596 &quot;i&quot;: isrectangle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9597 &quot;j&quot;: isrectangle(3)
9598};
9599</pre></div></div>
9600</li>
9601<li>
9602
9603<p>The expected result is:</p>
9604
9605<div>
9606<div>
9607<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 }
9608</pre></div></div>
9609</li>
9610</ul>
9611<p>The function has an alias <tt>isrectangle</tt>.</p></div>
9612<div class="section">
9613<h3><a name="is_circle"></a>is_circle</h3>
9614<ul>
9615
9616<li>
9617
9618<p>Syntax:</p>
9619
9620<div>
9621<div>
9622<pre class="source">is_circle(expr)
9623</pre></div></div>
9624</li>
9625<li>
9626
9627<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
9628</li>
9629<li>Arguments:
9630<ul>
9631
9632<li><tt>expr</tt> : an expression (any type is allowed).</li>
9633</ul>
9634</li>
9635<li>Return Value:
9636<ul>
9637
9638<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
9639<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9640<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9641</ul>
9642</li>
9643<li>
9644
9645<p>Example:</p>
9646
9647<div>
9648<div>
9649<pre class="source">{
9650 &quot;a&quot;: is_circle(true),
9651 &quot;b&quot;: is_circle(false),
9652 &quot;c&quot;: is_circle(null),
9653 &quot;d&quot;: is_circle(missing),
9654 &quot;e&quot;: is_circle(point(&quot;1,2&quot;)),
9655 &quot;f&quot;: iscircle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9656 &quot;g&quot;: iscircle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9657 &quot;h&quot;: iscircle(circle(&quot;30.0,70.0 5.0&quot;)),
9658 &quot;i&quot;: iscircle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9659 &quot;j&quot;: iscircle(3)
9660};
9661</pre></div></div>
9662</li>
9663<li>
9664
9665<p>The expected result is:</p>
9666
9667<div>
9668<div>
9669<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 }
9670</pre></div></div>
9671</li>
9672</ul>
9673<p>The function has an alias <tt>iscircle</tt>.</p></div>
9674<div class="section">
9675<h3><a name="is_polygon"></a>is_polygon</h3>
9676<ul>
9677
9678<li>
9679
9680<p>Syntax:</p>
9681
9682<div>
9683<div>
9684<pre class="source">is_polygon(expr)
9685</pre></div></div>
9686</li>
9687<li>
9688
9689<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
9690</li>
9691<li>Arguments:
9692<ul>
9693
9694<li><tt>expr</tt> : an expression (any type is allowed).</li>
9695</ul>
9696</li>
9697<li>Return Value:
9698<ul>
9699
9700<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
9701<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9702<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9703</ul>
9704</li>
9705<li>
9706
9707<p>Example:</p>
9708
9709<div>
9710<div>
9711<pre class="source">{
9712 &quot;a&quot;: is_polygon(true),
9713 &quot;b&quot;: is_polygon(false),
9714 &quot;c&quot;: is_polygon(null),
9715 &quot;d&quot;: is_polygon(missing),
9716 &quot;e&quot;: is_polygon(point(&quot;1,2&quot;)),
9717 &quot;f&quot;: ispolygon(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9718 &quot;g&quot;: ispolygon(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9719 &quot;h&quot;: ispolygon(circle(&quot;30.0,70.0 5.0&quot;)),
9720 &quot;i&quot;: ispolygon(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9721 &quot;j&quot;: ispolygon(3)
9722};
9723</pre></div></div>
9724</li>
9725<li>
9726
9727<p>The expected result is:</p>
9728
9729<div>
9730<div>
9731<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 }
9732</pre></div></div>
9733</li>
9734</ul>
9735<p>The function has an alias <tt>ispolygon</tt>.</p></div>
9736<div class="section">
9737<h3><a name="is_spatial"></a>is_spatial</h3>
9738<ul>
9739
9740<li>
9741
9742<p>Syntax:</p>
9743
9744<div>
9745<div>
9746<pre class="source">is_spatial(expr)
9747</pre></div></div>
9748</li>
9749<li>
9750
9751<p>Checks whether the given expression is evaluated to be a spatial value.</p>
9752</li>
9753<li>Arguments:
9754<ul>
9755
9756<li><tt>expr</tt> : an expression (any type is allowed).</li>
9757</ul>
9758</li>
9759<li>Return Value:
9760<ul>
9761
9762<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>
9763<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9764<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9765</ul>
9766</li>
9767<li>
9768
9769<p>Example:</p>
9770
9771<div>
9772<div>
9773<pre class="source">{
9774 &quot;a&quot;: is_spatial(true),
9775 &quot;b&quot;: is_spatial(false),
9776 &quot;c&quot;: is_spatial(null),
9777 &quot;d&quot;: is_spatial(missing),
9778 &quot;e&quot;: is_spatial(point(&quot;1,2&quot;)),
9779 &quot;f&quot;: isspatial(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9780 &quot;g&quot;: isspatial(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9781 &quot;h&quot;: isspatial(circle(&quot;30.0,70.0 5.0&quot;)),
9782 &quot;i&quot;: isspatial(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9783 &quot;j&quot;: isspatial(3)
9784};
9785</pre></div></div>
9786</li>
9787<li>
9788
9789<p>The expected result is:</p>
9790
9791<div>
9792<div>
9793<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 }
9794</pre></div></div>
9795</li>
9796</ul>
9797<p>The function has an alias <tt>isspatial</tt>.</p></div>
9798<div class="section">
9799<h3><a name="is_date"></a>is_date</h3>
9800<ul>
9801
9802<li>
9803
9804<p>Syntax:</p>
9805
9806<div>
9807<div>
9808<pre class="source">is_date(expr)
9809</pre></div></div>
9810</li>
9811<li>
9812
9813<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
9814</li>
9815<li>Arguments:
9816<ul>
9817
9818<li><tt>expr</tt> : an expression (any type is allowed).</li>
9819</ul>
9820</li>
9821<li>Return Value:
9822<ul>
9823
9824<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
9825<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9826<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9827</ul>
9828</li>
9829<li>
9830
9831<p>Example:</p>
9832
9833<div>
9834<div>
9835<pre class="source">{
9836 &quot;a&quot;: is_date(true),
9837 &quot;b&quot;: is_date(false),
9838 &quot;c&quot;: is_date(null),
9839 &quot;d&quot;: is_date(missing),
9840 &quot;e&quot;: is_date(date(&quot;-19700101&quot;)),
9841 &quot;f&quot;: isdate(date(&quot;2013-01-01&quot;)),
9842 &quot;g&quot;: isdate(time(&quot;12:12:12.039Z&quot;)),
9843 &quot;h&quot;: isdate(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9844 &quot;i&quot;: isdate(duration(&quot;P100Y12MT12M&quot;)),
9845 &quot;j&quot;: isdate(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9846 &quot;k&quot;: isdate(3)
9847};
9848</pre></div></div>
9849</li>
9850<li>
9851
9852<p>The expected result is:</p>
9853
9854<div>
9855<div>
9856<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 }
9857</pre></div></div>
9858</li>
9859</ul>
9860<p>The function has an alias <tt>isdate</tt>.</p></div>
9861<div class="section">
9862<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
9863<ul>
9864
9865<li>
9866
9867<p>Syntax:</p>
9868
9869<div>
9870<div>
9871<pre class="source">is_datetime(expr)
9872</pre></div></div>
9873</li>
9874<li>
9875
9876<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
9877</li>
9878<li>Arguments:
9879<ul>
9880
9881<li><tt>expr</tt> : an expression (any type is allowed).</li>
9882</ul>
9883</li>
9884<li>Return Value:
9885<ul>
9886
9887<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
9888<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9889<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9890</ul>
9891</li>
9892<li>
9893
9894<p>Example:</p>
9895
9896<div>
9897<div>
9898<pre class="source">{
9899 &quot;a&quot;: is_datetime(true),
9900 &quot;b&quot;: is_datetime(false),
9901 &quot;c&quot;: is_datetime(null),
9902 &quot;d&quot;: is_datetime(missing),
9903 &quot;e&quot;: is_datetime(datetime(&quot;2016-02-02T12:09:22.023Z&quot;)),
9904 &quot;f&quot;: isdatetime(datetime(&quot;2011-03-03T12:10:42.011Z&quot;)),
9905 &quot;g&quot;: isdatetime(time(&quot;12:12:12.039Z&quot;)),
9906 &quot;h&quot;: is_timestamp(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9907 &quot;i&quot;: is_timestamp(duration(&quot;P100Y12MT12M&quot;)),
9908 &quot;j&quot;: istimestamp(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9909 &quot;k&quot;: istimestamp(3)
9910};
9911</pre></div></div>
9912</li>
9913<li>
9914
9915<p>The expected result is:</p>
9916
9917<div>
9918<div>
9919<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 }
9920</pre></div></div>
9921</li>
9922</ul>
9923<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
9924<div class="section">
9925<h3><a name="is_time"></a>is_time</h3>
9926<ul>
9927
9928<li>
9929
9930<p>Syntax:</p>
9931
9932<div>
9933<div>
9934<pre class="source">is_time(expr)
9935</pre></div></div>
9936</li>
9937<li>
9938
9939<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
9940</li>
9941<li>Arguments:
9942<ul>
9943
9944<li><tt>expr</tt> : an expression (any type is allowed).</li>
9945</ul>
9946</li>
9947<li>Return Value:
9948<ul>
9949
9950<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
9951<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9952<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9953</ul>
9954</li>
9955<li>
9956
9957<p>Example:</p>
9958
9959<div>
9960<div>
9961<pre class="source"> {
9962 &quot;a&quot;: is_time(true),
9963 &quot;b&quot;: is_time(false),
9964 &quot;c&quot;: is_time(null),
9965 &quot;d&quot;: is_time(missing),
9966 &quot;e&quot;: is_time(time(&quot;08:00:00.000Z&quot;)),
9967 &quot;f&quot;: istime(date(&quot;2013-01-01&quot;)),
9968 &quot;g&quot;: istime(time(&quot;12:12:12.039Z&quot;)),
9969 &quot;h&quot;: istime(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9970 &quot;i&quot;: istime(duration(&quot;P100Y12MT12M&quot;)),
9971 &quot;j&quot;: istime(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9972 &quot;k&quot;: istime(3)
9973};
9974</pre></div></div>
9975</li>
9976<li>
9977
9978<p>The expected result is:</p>
9979
9980<div>
9981<div>
9982<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 }
9983</pre></div></div>
9984</li>
9985</ul>
9986<p>The function has an alias <tt>istime</tt>.</p></div>
9987<div class="section">
9988<h3><a name="is_duration"></a>is_duration</h3>
9989<ul>
9990
9991<li>
9992
9993<p>Syntax:</p>
9994
9995<div>
9996<div>
9997<pre class="source">is_duration(expr)
9998</pre></div></div>
9999</li>
10000<li>
10001
10002<p>Checks whether the given expression is evaluated to be a duration value.</p>
10003</li>
10004<li>Arguments:
10005<ul>
10006
10007<li><tt>expr</tt> : an expression (any type is allowed).</li>
10008</ul>
10009</li>
10010<li>Return Value:
10011<ul>
10012
10013<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
10014<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10015<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10016</ul>
10017</li>
10018<li>
10019
10020<p>Example:</p>
10021
10022<div>
10023<div>
10024<pre class="source"> {
10025 &quot;a&quot;: is_duration(true),
10026 &quot;b&quot;: is_duration(false),
10027 &quot;c&quot;: is_duration(null),
10028 &quot;d&quot;: is_duration(missing),
10029 &quot;e&quot;: is_duration(duration(&quot;-PT20.943S&quot;)),
10030 &quot;f&quot;: isduration(date(&quot;2013-01-01&quot;)),
10031 &quot;g&quot;: isduration(time(&quot;12:12:12.039Z&quot;)),
10032 &quot;h&quot;: isduration(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10033 &quot;i&quot;: isduration(duration(&quot;P100Y12MT12M&quot;)),
10034 &quot;j&quot;: isduration(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10035 &quot;k&quot;: isduration(3)
10036};
10037</pre></div></div>
10038</li>
10039<li>
10040
10041<p>The expected result is:</p>
10042
10043<div>
10044<div>
10045<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 }
10046</pre></div></div>
10047</li>
10048</ul>
10049<p>The function has an alias <tt>isduration</tt>.</p></div>
10050<div class="section">
10051<h3><a name="is_interval"></a>is_interval</h3>
10052<ul>
10053
10054<li>
10055
10056<p>Syntax:</p>
10057
10058<div>
10059<div>
10060<pre class="source">is_interval(expr)
10061</pre></div></div>
10062</li>
10063<li>
10064
10065<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
10066</li>
10067<li>Arguments:
10068<ul>
10069
10070<li><tt>expr</tt> : an expression (any type is allowed).</li>
10071</ul>
10072</li>
10073<li>Return Value:
10074<ul>
10075
10076<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
10077<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10078<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10079</ul>
10080</li>
10081<li>
10082
10083<p>Example:</p>
10084
10085<div>
10086<div>
10087<pre class="source"> {
10088 &quot;a&quot;: is_interval(true),
10089 &quot;b&quot;: is_interval(false),
10090 &quot;c&quot;: is_interval(null),
10091 &quot;d&quot;: is_interval(missing),
10092 &quot;e&quot;: is_interval(interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))),
10093 &quot;f&quot;: isinterval(date(&quot;2013-01-01&quot;)),
10094 &quot;g&quot;: isinterval(time(&quot;12:12:12.039Z&quot;)),
10095 &quot;h&quot;: isinterval(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10096 &quot;i&quot;: isinterval(duration(&quot;P100Y12MT12M&quot;)),
10097 &quot;j&quot;: isinterval(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10098 &quot;k&quot;: isinterval(3)
10099};
10100</pre></div></div>
10101</li>
10102<li>
10103
10104<p>The expected result is:</p>
10105
10106<div>
10107<div>
10108<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 }
10109</pre></div></div>
10110</li>
10111</ul>
10112<p>The function has an alias <tt>isinterval</tt>.</p></div>
10113<div class="section">
10114<h3><a name="is_temporal"></a>is_temporal</h3>
10115<ul>
10116
10117<li>
10118
10119<p>Syntax:</p>
10120
10121<div>
10122<div>
10123<pre class="source">is_temporal(expr)
10124</pre></div></div>
10125</li>
10126<li>
10127
10128<p>Checks whether the given expression is evaluated to be a temporal value.</p>
10129</li>
10130<li>Arguments:
10131<ul>
10132
10133<li><tt>expr</tt> : an expression (any type is allowed).</li>
10134</ul>
10135</li>
10136<li>Return Value:
10137<ul>
10138
10139<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>
10140<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10141<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10142</ul>
10143</li>
10144<li>
10145
10146<p>Example:</p>
10147
10148<div>
10149<div>
10150<pre class="source"> {
10151 &quot;a&quot;: is_temporal(true),
10152 &quot;b&quot;: is_temporal(false),
10153 &quot;c&quot;: is_temporal(null),
10154 &quot;d&quot;: is_temporal(missing),
10155 &quot;e&quot;: is_temporal(duration(&quot;-PT20.943S&quot;)),
10156 &quot;f&quot;: istemporal(date(&quot;2013-01-01&quot;)),
10157 &quot;g&quot;: istemporal(time(&quot;12:12:12.039Z&quot;)),
10158 &quot;h&quot;: istemporal(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10159 &quot;i&quot;: istemporal(duration(&quot;P100Y12MT12M&quot;)),
10160 &quot;j&quot;: istemporal(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10161 &quot;k&quot;: istemporal(3)
10162};
10163</pre></div></div>
10164</li>
10165<li>
10166
10167<p>The expected result is:</p>
10168
10169<div>
10170<div>
10171<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 }
10172</pre></div></div>
10173</li>
10174</ul>
10175<p>The function has an alias <tt>istemporal</tt>.</p></div>
10176<div class="section">
10177<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
10178<ul>
10179
10180<li>
10181
10182<p>Syntax:</p>
10183
10184<div>
10185<div>
10186<pre class="source">is_object(expr)
10187</pre></div></div>
10188</li>
10189<li>
10190
10191<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
10192</li>
10193<li>Arguments:
10194<ul>
10195
10196<li><tt>expr</tt> : an expression (any type is allowed).</li>
10197</ul>
10198</li>
10199<li>Return Value:
10200<ul>
10201
10202<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
10203<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10204<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10205</ul>
10206</li>
10207<li>
10208
10209<p>Example:</p>
10210
10211<div>
10212<div>
10213<pre class="source">{
10214 &quot;a&quot;: is_object(true),
10215 &quot;b&quot;: is_object(false),
10216 &quot;c&quot;: isobject(null),
10217 &quot;d&quot;: isobject(missing),
10218 &quot;e&quot;: isobj(&quot;d&quot;),
10219 &quot;f&quot;: isobj(4.0),
10220 &quot;g&quot;: isobj(5),
10221 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
10222 &quot;i&quot;: isobj({&quot;a&quot;:1})
10223};
10224</pre></div></div>
10225</li>
10226<li>
10227
10228<p>The expected result is:</p>
10229<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>
10230</li>
10231</ul>
10232<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
10233<div class="section">
10234<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
10235<ul>
10236
10237<li>
10238
10239<p>Syntax:</p>
10240
10241<div>
10242<div>
10243<pre class="source">is_string(expr)
10244</pre></div></div>
10245</li>
10246<li>
10247
10248<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
10249</li>
10250<li>Arguments:
10251<ul>
10252
10253<li><tt>expr</tt> : an expression (any type is allowed).</li>
10254</ul>
10255</li>
10256<li>Return Value:
10257<ul>
10258
10259<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
10260<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10261<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10262</ul>
10263</li>
10264<li>
10265
10266<p>Example:</p>
10267
10268<div>
10269<div>
10270<pre class="source">{
10271 &quot;a&quot;: is_string(true),
10272 &quot;b&quot;: isstring(false),
10273 &quot;c&quot;: isstring(null),
10274 &quot;d&quot;: isstr(missing),
10275 &quot;e&quot;: isstr(&quot;d&quot;),
10276 &quot;f&quot;: isstr(4.0),
10277 &quot;g&quot;: isstr(5),
10278 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
10279 &quot;i&quot;: isstr({&quot;a&quot;:1})
10280};
10281</pre></div></div>
10282</li>
10283<li>
10284
10285<p>The expected result is:</p>
10286
10287<div>
10288<div>
10289<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 }
10290</pre></div></div>
10291</li>
10292</ul>
10293<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
10294<div class="section">
10295<h3><a name="is_uuid"></a>is_uuid</h3>
10296<ul>
10297
10298<li>
10299
10300<p>Syntax:</p>
10301
10302<div>
10303<div>
10304<pre class="source">is_uuid(expr)
10305</pre></div></div>
10306</li>
10307<li>
10308
10309<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
10310</li>
10311<li>Arguments:
10312<ul>
10313
10314<li><tt>expr</tt> : an expression (any type is allowed).</li>
10315</ul>
10316</li>
10317<li>Return Value:
10318<ul>
10319
10320<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
10321<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10322<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10323</ul>
10324</li>
10325<li>
10326
10327<p>Example:</p>
10328
10329<div>
10330<div>
10331<pre class="source"> {
10332 &quot;a&quot;: is_uuid(true),
10333 &quot;b&quot;: is_uuid(false),
10334 &quot;c&quot;: is_uuid(null),
10335 &quot;d&quot;: is_uuid(missing),
10336 &quot;e&quot;: isuuid(4.0),
10337 &quot;f&quot;: isuuid(date(&quot;2013-01-01&quot;)),
10338 &quot;g&quot;: isuuid(uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;))
10339};
10340</pre></div></div>
10341</li>
10342<li>
10343
10344<p>The expected result is:</p>
10345
10346<div>
10347<div>
10348<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 }
10349</pre></div></div>
10350</li>
10351</ul>
10352<p>The function has an alias <tt>isuuid</tt>.</p></div>
10353<div class="section">
10354<h3><a name="is_null"></a>is_null</h3>
10355<ul>
10356
10357<li>
10358
10359<p>Syntax:</p>
10360
10361<div>
10362<div>
10363<pre class="source">is_null(expr)
10364</pre></div></div>
10365</li>
10366<li>
10367
10368<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
10369</li>
10370<li>Arguments:
10371<ul>
10372
10373<li><tt>expr</tt> : an expression (any type is allowed).</li>
10374</ul>
10375</li>
10376<li>Return Value:
10377<ul>
10378
10379<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
10380<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
10381</ul>
10382</li>
10383<li>
10384
10385<p>Example:</p>
10386
10387<div>
10388<div>
10389<pre class="source">{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
10390</pre></div></div>
10391</li>
10392<li>
10393
10394<p>The expected result is:</p>
10395
10396<div>
10397<div>
10398<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
10399</pre></div></div>
10400</li>
10401</ul>
10402<p>The function has an alias <tt>isnull</tt>.</p></div>
10403<div class="section">
10404<h3><a name="is_missing"></a>is_missing</h3>
10405<ul>
10406
10407<li>
10408
10409<p>Syntax:</p>
10410
10411<div>
10412<div>
10413<pre class="source">is_missing(expr)
10414</pre></div></div>
10415</li>
10416<li>
10417
10418<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
10419</li>
10420<li>Arguments:
10421<ul>
10422
10423<li><tt>expr</tt> : an expression (any type is allowed).</li>
10424</ul>
10425</li>
10426<li>Return Value:
10427<ul>
10428
10429<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
10430</ul>
10431</li>
10432<li>
10433
10434<p>Example:</p>
10435
10436<div>
10437<div>
10438<pre class="source">{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
10439</pre></div></div>
10440</li>
10441<li>
10442
10443<p>The expected result is:</p>
10444
10445<div>
10446<div>
10447<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
10448</pre></div></div>
10449</li>
10450</ul>
10451<p>The function has an alias <tt>ismissing</tt>.</p></div>
10452<div class="section">
10453<h3><a name="is_unknown"></a>is_unknown</h3>
10454<ul>
10455
10456<li>
10457
10458<p>Syntax:</p>
10459
10460<div>
10461<div>
10462<pre class="source">is_unknown(expr)
10463</pre></div></div>
10464</li>
10465<li>
10466
10467<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
10468</li>
10469<li>Arguments:
10470<ul>
10471
10472<li><tt>expr</tt> : an expression (any type is allowed).</li>
10473</ul>
10474</li>
10475<li>Return Value:
10476<ul>
10477
10478<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>
10479</ul>
10480</li>
10481<li>
10482
10483<p>Example:</p>
10484
10485<div>
10486<div>
10487<pre class="source">{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
10488</pre></div></div>
10489</li>
10490<li>
10491
10492<p>The expected result is:</p>
10493
10494<div>
10495<div>
10496<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
10497</pre></div></div>
10498</li>
10499</ul>
10500<p>The function has an alias <tt>isunknown</tt>.</p></div>
10501<div class="section">
10502<h3><a name="to_array"></a>to_array</h3>
10503<ul>
10504
10505<li>
10506
10507<p>Syntax:</p>
10508
10509<div>
10510<div>
10511<pre class="source">to_array(expr)
10512</pre></div></div>
10513</li>
10514<li>
10515
10516<p>Converts input value to an <tt>array</tt> value</p>
10517</li>
10518<li>Arguments:
10519<ul>
10520
10521<li><tt>expr</tt> : an expression</li>
10522</ul>
10523</li>
10524<li>Return Value:
10525<ul>
10526
10527<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10528<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10529<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
10530<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>
10531<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
10532</ul>
10533</li>
10534<li>
10535
10536<p>Example:</p>
10537
10538<div>
10539<div>
10540<pre class="source">{
10541 &quot;v1&quot;: to_array(&quot;asterix&quot;),
10542 &quot;v2&quot;: to_array([&quot;asterix&quot;]),
10543};
10544</pre></div></div>
10545</li>
10546<li>
10547
10548<p>The expected result is:</p>
10549
10550<div>
10551<div>
10552<pre class="source">{ &quot;v1&quot;: [&quot;asterix&quot;], &quot;v2&quot;: [&quot;asterix&quot;] }
10553</pre></div></div>
10554</li>
10555</ul>
10556<p>The function has an alias <tt>toarray</tt>.</p></div>
10557<div class="section">
10558<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
10559<ul>
10560
10561<li>
10562
10563<p>Syntax:</p>
10564
10565<div>
10566<div>
10567<pre class="source">to_atomic(expr)
10568</pre></div></div>
10569</li>
10570<li>
10571
10572<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
10573</li>
10574<li>Arguments:
10575<ul>
10576
10577<li><tt>expr</tt> : an expression</li>
10578</ul>
10579</li>
10580<li>Return Value:
10581<ul>
10582
10583<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10584<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10585<li>if the argument is of primitive type then it is returned as is</li>
10586<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>
10587<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>
10588<li>otherwise <tt>null</tt> is returned</li>
10589</ul>
10590</li>
10591<li>
10592
10593<p>Example:</p>
10594
10595<div>
10596<div>
10597<pre class="source">{
10598 &quot;v1&quot;: to_atomic(&quot;asterix&quot;),
10599 &quot;v2&quot;: to_atomic([&quot;asterix&quot;]),
10600 &quot;v3&quot;: to_atomic([0, 1]),
10601 &quot;v4&quot;: to_atomic({&quot;value&quot;: &quot;asterix&quot;}),
10602 &quot;v5&quot;: to_number({&quot;x&quot;: 1, &quot;y&quot;: 2})
10603};
10604</pre></div></div>
10605</li>
10606<li>
10607
10608<p>The expected result is:</p>
10609
10610<div>
10611<div>
10612<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 }
10613</pre></div></div>
10614</li>
10615</ul>
10616<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
10617<div class="section">
10618<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
10619<ul>
10620
10621<li>
10622
10623<p>Syntax:</p>
10624
10625<div>
10626<div>
10627<pre class="source">to_boolean(expr)
10628</pre></div></div>
10629</li>
10630<li>
10631
10632<p>Converts input value to a <tt>boolean</tt> value</p>
10633</li>
10634<li>Arguments:
10635<ul>
10636
10637<li><tt>expr</tt> : an expression</li>
10638</ul>
10639</li>
10640<li>Return Value:
10641<ul>
10642
10643<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10644<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10645<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
10646<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>
10647<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>
10648<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>
10649<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>
10650<li>type error is raised for all other input types</li>
10651</ul>
10652</li>
10653<li>
10654
10655<p>Example:</p>
10656
10657<div>
10658<div>
10659<pre class="source">{
10660 &quot;v1&quot;: to_boolean(0),
10661 &quot;v2&quot;: to_boolean(1),
10662 &quot;v3&quot;: to_boolean(&quot;&quot;),
10663 &quot;v4&quot;: to_boolean(&quot;asterix&quot;)
10664};
10665</pre></div></div>
10666</li>
10667<li>
10668
10669<p>The expected result is:</p>
10670
10671<div>
10672<div>
10673<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: false, &quot;v4&quot;: true }
10674</pre></div></div>
10675</li>
10676</ul>
10677<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
10678<div class="section">
10679<h3><a name="to_bigint"></a>to_bigint</h3>
10680<ul>
10681
10682<li>
10683
10684<p>Syntax:</p>
10685
10686<div>
10687<div>
10688<pre class="source">to_bigint(expr)
10689</pre></div></div>
10690</li>
10691<li>
10692
10693<p>Converts input value to an integer value</p>
10694</li>
10695<li>Arguments:
10696<ul>
10697
10698<li><tt>expr</tt> : an expression</li>
10699</ul>
10700</li>
10701<li>Return Value:
10702<ul>
10703
10704<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10705<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10706<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>
10707<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
10708<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
10709<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>
10710<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10711<li>type error is raised for all other input types</li>
10712</ul>
10713</li>
10714<li>
10715
10716<p>Example:</p>
10717
10718<div>
10719<div>
10720<pre class="source">{
10721 &quot;v1&quot;: to_bigint(false),
10722 &quot;v2&quot;: to_bigint(true),
10723 &quot;v3&quot;: to_bigint(10),
10724 &quot;v4&quot;: to_bigint(float(&quot;1e100&quot;)),
10725 &quot;v5&quot;: to_bigint(double(&quot;1e1000&quot;)),
10726 &quot;v6&quot;: to_bigint(&quot;20&quot;)
10727};
10728</pre></div></div>
10729</li>
10730<li>
10731
10732<p>The expected result is:</p>
10733
10734<div>
10735<div>
10736<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 }
10737</pre></div></div>
10738</li>
10739</ul>
10740<p>The function has an alias <tt>tobigint</tt>.</p></div>
10741<div class="section">
10742<h3><a name="to_double"></a>to_double</h3>
10743<ul>
10744
10745<li>
10746
10747<p>Syntax:</p>
10748
10749<div>
10750<div>
10751<pre class="source">to_double(expr)
10752</pre></div></div>
10753</li>
10754<li>
10755
10756<p>Converts input value to a <tt>double</tt> value</p>
10757</li>
10758<li>Arguments:
10759<ul>
10760
10761<li><tt>expr</tt> : an expression</li>
10762</ul>
10763</li>
10764<li>Return Value:
10765<ul>
10766
10767<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10768<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10769<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>
10770<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
10771<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>
10772<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10773<li>type error is raised for all other input types</li>
10774</ul>
10775</li>
10776<li>
10777
10778<p>Example:</p>
10779
10780<div>
10781<div>
10782<pre class="source">{
10783 &quot;v1&quot;: to_double(false),
10784 &quot;v2&quot;: to_double(true),
10785 &quot;v3&quot;: to_double(10),
10786 &quot;v4&quot;: to_double(11.5),
10787 &quot;v5&quot;: to_double(&quot;12.5&quot;)
10788};
10789</pre></div></div>
10790</li>
10791<li>
10792
10793<p>The expected result is:</p>
10794
10795<div>
10796<div>
10797<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 }
10798</pre></div></div>
10799</li>
10800</ul>
10801<p>The function has an alias <tt>todouble</tt>.</p></div>
10802<div class="section">
10803<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
10804<ul>
10805
10806<li>
10807
10808<p>Syntax:</p>
10809
10810<div>
10811<div>
10812<pre class="source">to_number(expr)
10813</pre></div></div>
10814</li>
10815<li>
10816
10817<p>Converts input value to a numeric value</p>
10818</li>
10819<li>Arguments:
10820<ul>
10821
10822<li><tt>expr</tt> : an expression</li>
10823</ul>
10824</li>
10825<li>Return Value:
10826<ul>
10827
10828<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10829<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10830<li>if the argument is of numeric type then it is returned as is</li>
10831<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>
10832<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>
10833<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10834<li>type error is raised for all other input types</li>
10835</ul>
10836</li>
10837<li>
10838
10839<p>Example:</p>
10840
10841<div>
10842<div>
10843<pre class="source">{
10844 &quot;v1&quot;: to_number(false),
10845 &quot;v2&quot;: to_number(true),
10846 &quot;v3&quot;: to_number(10),
10847 &quot;v4&quot;: to_number(11.5),
10848 &quot;v5&quot;: to_number(&quot;12.5&quot;)
10849};
10850</pre></div></div>
10851</li>
10852<li>
10853
10854<p>The expected result is:</p>
10855
10856<div>
10857<div>
10858<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 }
10859</pre></div></div>
10860</li>
10861</ul>
10862<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
10863<div class="section">
10864<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
10865<ul>
10866
10867<li>
10868
10869<p>Syntax:</p>
10870
10871<div>
10872<div>
10873<pre class="source">to_object(expr)
10874</pre></div></div>
10875</li>
10876<li>
10877
10878<p>Converts input value to an <tt>object</tt> value</p>
10879</li>
10880<li>Arguments:
10881<ul>
10882
10883<li><tt>expr</tt> : an expression</li>
10884</ul>
10885</li>
10886<li>Return Value:
10887<ul>
10888
10889<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10890<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10891<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
10892<li>otherwise an empty <tt>object</tt> is returned</li>
10893</ul>
10894</li>
10895<li>
10896
10897<p>Example:</p>
10898
10899<div>
10900<div>
10901<pre class="source">{
10902 &quot;v1&quot;: to_object({&quot;value&quot;: &quot;asterix&quot;}),
10903 &quot;v2&quot;: to_object(&quot;asterix&quot;)
10904};
10905</pre></div></div>
10906</li>
10907<li>
10908
10909<p>The expected result is:</p>
10910
10911<div>
10912<div>
10913<pre class="source">{ &quot;v1&quot;: {&quot;value&quot;: &quot;asterix&quot;}, &quot;v2&quot;: {} }
10914</pre></div></div>
10915</li>
10916</ul>
10917<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
10918<div class="section">
10919<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
10920<ul>
10921
10922<li>
10923
10924<p>Syntax:</p>
10925
10926<div>
10927<div>
10928<pre class="source">to_string(expr)
10929</pre></div></div>
10930</li>
10931<li>
10932
10933<p>Converts input value to a string value</p>
10934</li>
10935<li>Arguments:
10936<ul>
10937
10938<li><tt>expr</tt> : an expression</li>
10939</ul>
10940</li>
10941<li>Return Value:
10942<ul>
10943
10944<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10945<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10946<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>
10947<li>if the argument is of numeric type then its string representation is returned</li>
10948<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
10949<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10950<li>type error is raised for all other input types</li>
10951</ul>
10952</li>
10953<li>
10954
10955<p>Example:</p>
10956
10957<div>
10958<div>
10959<pre class="source">{
10960 &quot;v1&quot;: to_string(false),
10961 &quot;v2&quot;: to_string(true),
10962 &quot;v3&quot;: to_string(10),
10963 &quot;v4&quot;: to_string(11.5),
10964 &quot;v5&quot;: to_string(&quot;asterix&quot;)
10965};
10966</pre></div></div>
10967</li>
10968<li>
10969
10970<p>The expected result is:</p>
10971
10972<div>
10973<div>
10974<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; }
10975</pre></div></div>
10976</li>
10977</ul>
10978<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
10979 ! Licensed to the Apache Software Foundation (ASF) under one
10980 ! or more contributor license agreements. See the NOTICE file
10981 ! distributed with this work for additional information
10982 ! regarding copyright ownership. The ASF licenses this file
10983 ! to you under the Apache License, Version 2.0 (the
10984 ! "License"); you may not use this file except in compliance
10985 ! with the License. You may obtain a copy of the License at
10986 !
10987 ! http://www.apache.org/licenses/LICENSE-2.0
10988 !
10989 ! Unless required by applicable law or agreed to in writing,
10990 ! software distributed under the License is distributed on an
10991 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
10992 ! KIND, either express or implied. See the License for the
10993 ! specific language governing permissions and limitations
10994 ! under the License.
10995 !-->
10996</div></div>
10997<div class="section">
10998<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
10999<div class="section">
11000<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
11001<ul>
11002
11003<li>
11004
11005<p>Syntax:</p>
11006
11007<div>
11008<div>
11009<pre class="source">if_null(expression1, expression2, ... expressionN)
11010</pre></div></div>
11011</li>
11012<li>
11013
11014<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
11015</li>
11016<li>Arguments:
11017<ul>
11018
11019<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11020</ul>
11021</li>
11022<li>Return Value:
11023<ul>
11024
11025<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
11026<li>a value of the first non-<tt>null</tt> argument otherwise</li>
11027</ul>
11028</li>
11029<li>
11030
11031<p>Example:</p>
11032
11033<div>
11034<div>
11035<pre class="source">{
11036 &quot;a&quot;: if_null(),
11037 &quot;b&quot;: if_null(null),
11038 &quot;c&quot;: if_null(null, &quot;asterixdb&quot;),
11039 &quot;d&quot;: is_missing(if_null(missing))
11040};
11041</pre></div></div>
11042</li>
11043<li>
11044
11045<p>The expected result is:</p>
11046
11047<div>
11048<div>
11049<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: true }
11050</pre></div></div>
11051</li>
11052</ul>
11053<p>The function has an alias <tt>ifnull</tt>.</p></div>
11054<div class="section">
11055<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
11056<ul>
11057
11058<li>
11059
11060<p>Syntax:</p>
11061
11062<div>
11063<div>
11064<pre class="source">if_missing(expression1, expression2, ... expressionN)
11065</pre></div></div>
11066</li>
11067<li>
11068
11069<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
11070</li>
11071<li>Arguments:
11072<ul>
11073
11074<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11075</ul>
11076</li>
11077<li>Return Value:
11078<ul>
11079
11080<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
11081<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
11082</ul>
11083</li>
11084<li>
11085
11086<p>Example:</p>
11087
11088<div>
11089<div>
11090<pre class="source">{
11091 &quot;a&quot;: if_missing(),
11092 &quot;b&quot;: if_missing(missing),
11093 &quot;c&quot;: if_missing(missing, &quot;asterixdb&quot;),
11094 &quot;d&quot;: if_missing(null, &quot;asterixdb&quot;)
11095};
11096</pre></div></div>
11097</li>
11098<li>
11099
11100<p>The expected result is:</p>
11101
11102<div>
11103<div>
11104<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: null }
11105</pre></div></div>
11106</li>
11107</ul>
11108<p>The function has an alias <tt>ifmissing</tt>.</p></div>
11109<div class="section">
11110<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
11111<ul>
11112
11113<li>
11114
11115<p>Syntax:</p>
11116
11117<div>
11118<div>
11119<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
11120</pre></div></div>
11121</li>
11122<li>
11123
11124<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
11125</li>
11126<li>Arguments:
11127<ul>
11128
11129<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11130</ul>
11131</li>
11132<li>Return Value:
11133<ul>
11134
11135<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
11136<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
11137</ul>
11138</li>
11139<li>
11140
11141<p>Example:</p>
11142
11143<div>
11144<div>
11145<pre class="source">{
11146 &quot;a&quot;: if_missing_or_null(),
11147 &quot;b&quot;: if_missing_or_null(null, missing),
11148 &quot;c&quot;: if_missing_or_null(null, missing, &quot;asterixdb&quot;)
11149};
11150</pre></div></div>
11151</li>
11152<li>
11153
11154<p>The expected result is:</p>
11155
11156<div>
11157<div>
11158<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot; }
11159</pre></div></div>
11160</li>
11161</ul>
11162<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
11163<div class="section">
11164<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
11165<ul>
11166
11167<li>
11168
11169<p>Syntax:</p>
11170
11171<div>
11172<div>
11173<pre class="source">if_inf(expression1, expression2, ... expressionN)
11174</pre></div></div>
11175</li>
11176<li>
11177
11178<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
11179</li>
11180<li>Arguments:
11181<ul>
11182
11183<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11184</ul>
11185</li>
11186<li>Return Value:
11187<ul>
11188
11189<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
11190<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>
11191<li>the first non-infinite number 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;: is_null(if_inf(null)),
11202 &quot;b&quot;: is_missing(if_inf(missing)),
11203 &quot;c&quot;: is_null(if_inf(double(&quot;INF&quot;))),
11204 &quot;d&quot;: if_inf(1, null, missing) ],
11205 &quot;e&quot;: is_null(if_inf(null, missing, 1)) ],
11206 &quot;f&quot;: is_missing(if_inf(missing, null, 1)) ],
11207 &quot;g&quot;: if_inf(float(&quot;INF&quot;), 1) ],
11208 &quot;h&quot;: to_string(if_inf(float(&quot;INF&quot;), double(&quot;NaN&quot;), 1)) ]
11209};
11210</pre></div></div>
11211</li>
11212<li>
11213
11214<p>The expected result is:</p>
11215
11216<div>
11217<div>
11218<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; }
11219</pre></div></div>
11220</li>
11221</ul>
11222<p>The function has an alias <tt>ifinf</tt>.</p></div>
11223<div class="section">
11224<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
11225<ul>
11226
11227<li>
11228
11229<p>Syntax:</p>
11230
11231<div>
11232<div>
11233<pre class="source">if_nan(expression1, expression2, ... expressionN)
11234</pre></div></div>
11235</li>
11236<li>
11237
11238<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
11239</li>
11240<li>Arguments:
11241<ul>
11242
11243<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11244</ul>
11245</li>
11246<li>Return Value:
11247<ul>
11248
11249<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11250<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>
11251<li>the first non-<tt>NaN</tt> number argument otherwise</li>
11252</ul>
11253</li>
11254<li>
11255
11256<p>Example:</p>
11257
11258<div>
11259<div>
11260<pre class="source">{
11261 &quot;a&quot;: is_null(if_nan(null)),
11262 &quot;b&quot;: is_missing(if_nan(missing)),
11263 &quot;c&quot;: is_null(if_nan(double(&quot;NaN&quot;))),
11264 &quot;d&quot;: if_nan(1, null, missing) ],
11265 &quot;e&quot;: is_null(if_nan(null, missing, 1)) ],
11266 &quot;f&quot;: is_missing(if_nan(missing, null, 1)) ],
11267 &quot;g&quot;: if_nan(float(&quot;NaN&quot;), 1) ],
11268 &quot;h&quot;: to_string(if_nan(float(&quot;NaN&quot;), double(&quot;INF&quot;), 1)) ]
11269};
11270</pre></div></div>
11271</li>
11272<li>
11273
11274<p>The expected result is:</p>
11275
11276<div>
11277<div>
11278<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; }
11279</pre></div></div>
11280</li>
11281</ul>
11282<p>The function has an alias <tt>ifnan</tt>.</p></div>
11283<div class="section">
11284<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
11285<ul>
11286
11287<li>
11288
11289<p>Syntax:</p>
11290
11291<div>
11292<div>
11293<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
11294</pre></div></div>
11295</li>
11296<li>
11297
11298<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
11299</li>
11300<li>Arguments:
11301<ul>
11302
11303<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11304</ul>
11305</li>
11306<li>Return Value:
11307<ul>
11308
11309<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>
11310<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>
11311<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
11312</ul>
11313</li>
11314<li>
11315
11316<p>Example:</p>
11317
11318<div>
11319<div>
11320<pre class="source">{
11321 &quot;a&quot;: is_null(if_nan_or_inf(null)),
11322 &quot;b&quot;: is_missing(if_nan_or_inf(missing)),
11323 &quot;c&quot;: is_null(if_nan_or_inf(double(&quot;NaN&quot;), double(&quot;INF&quot;))),
11324 &quot;d&quot;: if_nan_or_inf(1, null, missing) ],
11325 &quot;e&quot;: is_null(if_nan_or_inf(null, missing, 1)) ],
11326 &quot;f&quot;: is_missing(if_nan_or_inf(missing, null, 1)) ],
11327 &quot;g&quot;: if_nan_or_inf(float(&quot;NaN&quot;), float(&quot;INF&quot;), 1) ],
11328};
11329</pre></div></div>
11330</li>
11331<li>
11332
11333<p>The expected result is:</p>
11334
11335<div>
11336<div>
11337<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 }
11338</pre></div></div>
11339</li>
11340</ul>
11341<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
11342<div class="section">
11343<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
11344<ul>
11345
11346<li>
11347
11348<p>Syntax:</p>
11349
11350<div>
11351<div>
11352<pre class="source">null_if(expression1, expression2)
11353</pre></div></div>
11354</li>
11355<li>
11356
11357<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
11358</li>
11359<li>Arguments:
11360<ul>
11361
11362<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11363</ul>
11364</li>
11365<li>Return Value:
11366<ul>
11367
11368<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11369<li><tt>null</tt> if
11370<ul>
11371
11372<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
11373<li><tt>argument1</tt> = <tt>argument2</tt></li>
11374</ul>
11375</li>
11376<li>a value of the first argument otherwise</li>
11377</ul>
11378</li>
11379<li>
11380
11381<p>Example:</p>
11382
11383<div>
11384<div>
11385<pre class="source">{
11386 &quot;a&quot;: null_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;),
11387 &quot;b&quot;: null_if(1, 2)
11388};
11389</pre></div></div>
11390</li>
11391<li>
11392
11393<p>The expected result is:</p>
11394
11395<div>
11396<div>
11397<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: 1 }
11398</pre></div></div>
11399</li>
11400</ul>
11401<p>The function has an alias <tt>nullif</tt>.</p></div>
11402<div class="section">
11403<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
11404<ul>
11405
11406<li>
11407
11408<p>Syntax:</p>
11409
11410<div>
11411<div>
11412<pre class="source">missing_if(expression1, expression2)
11413</pre></div></div>
11414</li>
11415<li>
11416
11417<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
11418</li>
11419<li>Arguments:
11420<ul>
11421
11422<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11423</ul>
11424</li>
11425<li>Return Value:
11426<ul>
11427
11428<li><tt>missing</tt> if
11429<ul>
11430
11431<li>any argument is a <tt>missing</tt> value, or</li>
11432<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
11433</ul>
11434</li>
11435<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11436<li>a value of the first argument otherwise</li>
11437</ul>
11438</li>
11439<li>
11440
11441<p>Example:</p>
11442
11443<div>
11444<div>
11445<pre class="source">{
11446 &quot;a&quot;: missing_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)
11447 &quot;b&quot;: missing_if(1, 2),
11448};
11449</pre></div></div>
11450</li>
11451<li>
11452
11453<p>The expected result is:</p>
11454
11455<div>
11456<div>
11457<pre class="source">{ &quot;b&quot;: 1 }
11458</pre></div></div>
11459</li>
11460</ul>
11461<p>The function has an alias <tt>missingif</tt>.</p></div>
11462<div class="section">
11463<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
11464<ul>
11465
11466<li>
11467
11468<p>Syntax:</p>
11469
11470<div>
11471<div>
11472<pre class="source">nan_if(expression1, expression2)
11473</pre></div></div>
11474</li>
11475<li>
11476
11477<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
11478</li>
11479<li>Arguments:
11480<ul>
11481
11482<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11483</ul>
11484</li>
11485<li>Return Value:
11486<ul>
11487
11488<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11489<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11490<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11491<li>a value of the first argument otherwise</li>
11492</ul>
11493</li>
11494<li>
11495
11496<p>Example:</p>
11497
11498<div>
11499<div>
11500<pre class="source">{
11501 &quot;a&quot;: to_string(nan_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11502 &quot;b&quot;: nan_if(1, 2)
11503};
11504</pre></div></div>
11505</li>
11506<li>
11507
11508<p>The expected result is:</p>
11509
11510<div>
11511<div>
11512<pre class="source">{ &quot;a&quot;: &quot;NaN&quot;, &quot;b&quot;: 1 }
11513</pre></div></div>
11514</li>
11515</ul>
11516<p>The function has an alias <tt>nanif</tt>.</p></div>
11517<div class="section">
11518<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
11519<ul>
11520
11521<li>
11522
11523<p>Syntax:</p>
11524
11525<div>
11526<div>
11527<pre class="source">posinf_if(expression1, expression2)
11528</pre></div></div>
11529</li>
11530<li>
11531
11532<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
11533</li>
11534<li>Arguments:
11535<ul>
11536
11537<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11538</ul>
11539</li>
11540<li>Return Value:
11541<ul>
11542
11543<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11544<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11545<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11546<li>a value of the first argument otherwise</li>
11547</ul>
11548</li>
11549<li>
11550
11551<p>Example:</p>
11552
11553<div>
11554<div>
11555<pre class="source">{
11556 &quot;a&quot;: to_string(posinf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11557 &quot;b&quot;: posinf_if(1, 2)
11558};
11559</pre></div></div>
11560</li>
11561<li>
11562
11563<p>The expected result is:</p>
11564
11565<div>
11566<div>
11567<pre class="source">{ &quot;a&quot;: &quot;+INF&quot;, &quot;b&quot;: 1 }
11568</pre></div></div>
11569</li>
11570</ul>
11571<p>The function has an alias <tt>posinfif</tt>.</p></div>
11572<div class="section">
11573<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
11574<ul>
11575
11576<li>
11577
11578<p>Syntax:</p>
11579
11580<div>
11581<div>
11582<pre class="source">neginf_if(expression1, expression2)
11583</pre></div></div>
11584</li>
11585<li>
11586
11587<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
11588</li>
11589<li>Arguments:
11590<ul>
11591
11592<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11593</ul>
11594</li>
11595<li>Return Value:
11596<ul>
11597
11598<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11599<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11600<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></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;: to_string(neginf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11612 &quot;b&quot;: neginf_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;a&quot;: &quot;-INF&quot;, &quot;b&quot;: 1 }
11623</pre></div></div>
11624</li>
11625</ul>
11626<p>The function has an alias <tt>neginfif</tt>.</p><!--
11627 ! Licensed to the Apache Software Foundation (ASF) under one
11628 ! or more contributor license agreements. See the NOTICE file
11629 ! distributed with this work for additional information
11630 ! regarding copyright ownership. The ASF licenses this file
11631 ! to you under the Apache License, Version 2.0 (the
11632 ! "License"); you may not use this file except in compliance
11633 ! with the License. You may obtain a copy of the License at
11634 !
11635 ! http://www.apache.org/licenses/LICENSE-2.0
11636 !
11637 ! Unless required by applicable law or agreed to in writing,
11638 ! software distributed under the License is distributed on an
11639 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11640 ! KIND, either express or implied. See the License for the
11641 ! specific language governing permissions and limitations
11642 ! under the License.
11643 !-->
11644</div></div>
11645<div class="section">
11646<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
11647<div class="section">
11648<h3><a name="uuid"></a>uuid</h3>
11649<ul>
11650
11651<li>
11652
11653<p>Syntax:</p>
11654
11655<div>
11656<div>
11657<pre class="source">uuid()
11658</pre></div></div>
11659</li>
11660<li>
11661
11662<p>Generates a <tt>uuid</tt>.</p>
11663</li>
11664<li>Arguments:
11665<ul>
11666
11667<li>none</li>
11668</ul>
11669</li>
11670<li>Return Value:
11671<ul>
11672
11673<li>a generated, random <tt>uuid</tt>.</li>
11674</ul>
11675</li>
11676</ul></div>
11677<div class="section">
11678<h3><a name="len"></a>len</h3>
11679<ul>
11680
11681<li>
11682
11683<p>Syntax:</p>
11684<p>len(array)</p>
11685</li>
11686<li>
11687
11688<p>Returns the length of the array array.</p>
11689</li>
11690<li>Arguments:
11691<ul>
11692
11693<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>
11694</ul>
11695</li>
11696<li>Return Value:
11697<ul>
11698
11699<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
11700<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11701<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11702</ul>
11703</li>
11704<li>
11705
11706<p>Example:</p>
11707
11708<div>
11709<div>
11710<pre class="source">len([&quot;Hello&quot;, &quot;World&quot;])
11711</pre></div></div>
11712</li>
11713<li>
11714
11715<p>The expected result is:</p>
11716
11717<div>
11718<div>
11719<pre class="source">2
11720</pre></div></div>
11721</li>
11722</ul></div>
11723<div class="section">
11724<h3><a name="not"></a>not</h3>
11725<ul>
11726
11727<li>
11728
11729<p>Syntax:</p>
11730
11731<div>
11732<div>
11733<pre class="source">not(expr)
11734</pre></div></div>
11735</li>
11736<li>
11737
11738<p>Inverts a <tt>boolean</tt> value</p>
11739</li>
11740<li>Arguments:
11741<ul>
11742
11743<li><tt>expr</tt> : an expression</li>
11744</ul>
11745</li>
11746<li>Return Value:
11747<ul>
11748
11749<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
11750<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11751<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
11752<li>other non-boolean argument value will cause a type error.</li>
11753</ul>
11754</li>
11755<li>Example:
11756
11757<div>
11758<div>
11759<pre class="source">{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
11760</pre></div></div>
11761</li>
11762<li>
11763
11764<p>The expected result is:</p>
11765
11766<div>
11767<div>
11768<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
11769</pre></div></div>
11770</li>
11771</ul></div>
11772<div class="section">
11773<h3><a name="random"></a>random</h3>
11774<ul>
11775
11776<li>
11777
11778<p>Syntax:</p>
11779
11780<div>
11781<div>
11782<pre class="source">random( [seed_value] )
11783</pre></div></div>
11784</li>
11785<li>
11786
11787<p>Returns a random number, accepting an optional seed value</p>
11788</li>
11789<li>Arguments:
11790<ul>
11791
11792<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>
11793</ul>
11794</li>
11795<li>Return Value:
11796<ul>
11797
11798<li>A random number of type <tt>double</tt> between 0 and 1,</li>
11799<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
11800<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
11801</ul>
11802</li>
11803<li>
11804
11805<p>Example:</p>
11806
11807<div>
11808<div>
11809<pre class="source">{
11810 &quot;v1&quot;: random(),
11811 &quot;v2&quot;: random(unix_time_from_datetime_in_ms(current_datetime()))
11812};
11813</pre></div></div>
11814</li>
11815</ul></div>
11816<div class="section">
11817<h3><a name="range"></a>range</h3>
11818<ul>
11819
11820<li>
11821
11822<p>Syntax:</p>
11823
11824<div>
11825<div>
11826<pre class="source">range(start_numeric_value, end_numeric_value)
11827</pre></div></div>
11828</li>
11829<li>
11830
11831<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>
11832</li>
11833<li>Arguments:</li>
11834<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>
11835<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>
11836<li>Return Value:
11837<ul>
11838
11839<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>
11840</ul>
11841</li>
11842<li>Example:
11843
11844<div>
11845<div>
11846<pre class="source">range(0, 3);
11847</pre></div></div>
11848</li>
11849<li>
11850
11851<p>The expected result is:</p>
11852
11853<div>
11854<div>
11855<pre class="source">[ 0, 1, 2, 3 ]
11856</pre></div></div>
11857</li>
11858</ul></div>
11859<div class="section">
11860<h3><a name="switch_case"></a>switch_case</h3>
11861<ul>
11862
11863<li>
11864
11865<p>Syntax:</p>
11866
11867<div>
11868<div>
11869<pre class="source">switch_case(
11870 condition,
11871 case1, case1_result,
11872 case2, case2_result,
11873 ...,
11874 default, default_result
11875)
11876</pre></div></div>
11877</li>
11878<li>
11879
11880<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>
11881</li>
11882<li>Arguments:
11883<ul>
11884
11885<li><tt>condition</tt>: a variable (any type is allowed).</li>
11886<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
11887<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
11888</ul>
11889</li>
11890<li>Return Value:
11891<ul>
11892
11893<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
11894</ul>
11895</li>
11896<li>Example 1:
11897
11898<div>
11899<div>
11900<pre class="source">switch_case(
11901 &quot;a&quot;,
11902 &quot;a&quot;, 0,
11903 &quot;x&quot;, 1,
11904 &quot;y&quot;, 2,
11905 &quot;z&quot;, 3
11906);
11907</pre></div></div>
11908</li>
11909<li>
11910
11911<p>The expected result is:</p>
11912
11913<div>
11914<div>
11915<pre class="source">0
11916</pre></div></div>
11917</li>
11918<li>
11919
11920<p>Example 2:</p>
11921
11922<div>
11923<div>
11924<pre class="source">switch_case(
11925 &quot;a&quot;,
11926 &quot;x&quot;, 1,
11927 &quot;y&quot;, 2,
11928 &quot;z&quot;, 3
11929);
11930</pre></div></div>
11931</li>
11932<li>
11933
11934<p>The expected result is:</p>
11935
11936<div>
11937<div>
11938<pre class="source">3
11939</pre></div></div>
11940</li>
11941</ul></div>
11942<div class="section">
11943<h3><a name="deep_equal"></a>deep_equal</h3>
11944<ul>
11945
11946<li>
11947
11948<p>Syntax:</p>
11949
11950<div>
11951<div>
11952<pre class="source">deep_equal(expr1, expr2)
11953</pre></div></div>
11954</li>
11955<li>
11956
11957<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>
11958</li>
11959<li>Arguments:
11960<ul>
11961
11962<li><tt>expr1</tt> : an expression,</li>
11963<li><tt>expr2</tt> : an expression.</li>
11964</ul>
11965</li>
11966<li>Return Value:
11967<ul>
11968
11969<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
11970<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11971<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11972</ul>
11973</li>
11974<li>
11975
11976<p>Example:</p>
11977
11978<div>
11979<div>
11980<pre class="source">deep_equal(
11981 {
11982 &quot;id&quot;:1,
11983 &quot;project&quot;:&quot;AsterixDB&quot;,
11984 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
11985 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
11986 },
11987 {
11988 &quot;id&quot;:1,
11989 &quot;project&quot;:&quot;AsterixDB&quot;,
11990 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
11991 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
11992 }
11993);
11994</pre></div></div>
11995</li>
11996<li>
11997
11998<p>The expected result is:</p>
11999
12000<div>
12001<div>
12002<pre class="source">false
12003</pre></div></div>
12004</li>
12005</ul></div></div>
12006 </div>
12007 </div>
12008 </div>
12009 <hr/>
12010 <footer>
12011 <div class="container-fluid">
12012 <div class="row-fluid">
12013<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
12014 feather logo, and the Apache AsterixDB project logo are either
12015 registered trademarks or trademarks of The Apache Software
12016 Foundation in the United States and other countries.
12017 All other marks mentioned may be trademarks or registered
12018 trademarks of their respective owners.
12019 </div>
12020 </div>
12021 </div>
12022 </footer>
12023 </body>
12024</html>