blob: b160b2271f4bd832f8b75f510cf37e25759eab53 [file] [log] [blame]
Ian Maxon49d15b22020-12-06 16:23:00 -08001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from target/generated-site/markdown/sqlpp/builtins.md at 2020-12-06
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="20201206" />
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-12-06</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.6-SNAPSHOT</li>
31 <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="../SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li class="active"><a href="#"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="../interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
61 <li class="nav-header">Deprecated</li>
62 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
63 <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>
64 <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
65</ul>
66 <hr />
67 <div id="poweredBy">
68 <div class="clear"></div>
69 <div class="clear"></div>
70 <div class="clear"></div>
71 <div class="clear"></div>
72<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
73 </div>
74 </div>
75 </div>
76 <div id="bodyColumn" class="span10" >
77<!--
78 ! Licensed to the Apache Software Foundation (ASF) under one
79 ! or more contributor license agreements. See the NOTICE file
80 ! distributed with this work for additional information
81 ! regarding copyright ownership. The ASF licenses this file
82 ! to you under the Apache License, Version 2.0 (the
83 ! "License"); you may not use this file except in compliance
84 ! with the License. You may obtain a copy of the License at
85 !
86 ! http://www.apache.org/licenses/LICENSE-2.0
87 !
88 ! Unless required by applicable law or agreed to in writing,
89 ! software distributed under the License is distributed on an
90 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
91 ! KIND, either express or implied. See the License for the
92 ! specific language governing permissions and limitations
93 ! under the License.
94 !-->
95<h1>Builtin Functions</h1><!--
96 ! Licensed to the Apache Software Foundation (ASF) under one
97 ! or more contributor license agreements. See the NOTICE file
98 ! distributed with this work for additional information
99 ! regarding copyright ownership. The ASF licenses this file
100 ! to you under the Apache License, Version 2.0 (the
101 ! "License"); you may not use this file except in compliance
102 ! with the License. You may obtain a copy of the License at
103 !
104 ! http://www.apache.org/licenses/LICENSE-2.0
105 !
106 ! Unless required by applicable law or agreed to in writing,
107 ! software distributed under the License is distributed on an
108 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
109 ! KIND, either express or implied. See the License for the
110 ! specific language governing permissions and limitations
111 ! under the License.
112 !-->
113
114<div class="section">
115<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
116<ul>
117
118<li><a href="#NumericFunctions">Numeric Functions</a></li>
119<li><a href="#StringFunctions">String Functions</a></li>
120<li><a href="#BinaryFunctions">Binary Functions</a></li>
121<li><a href="#SpatialFunctions">Spatial Functions</a></li>
122<li><a href="#SimilarityFunctions">Similarity Functions</a></li>
123<li><a href="#TokenizingFunctions">Tokenizing Functions</a></li>
124<li><a href="#TemporalFunctions">Temporal Functions</a></li>
125<li><a href="#ObjectFunctions">Object Functions</a></li>
126<li><a href="#AggregateFunctions">Aggregate Functions (Array Functions)</a></li>
127<li><a href="#ComparisonFunctions">Comparison Functions</a></li>
128<li><a href="#TypeFunctions">Type Functions</a></li>
129<li><a href="#ConditionalFunctions">Conditional Functions</a></li>
130<li><a href="#MiscFunctions">Miscellaneous Functions</a></li>
131<li><a href="#BitwiseFunctions">Bitwise Functions</a></li>
132<li><a href="#WindowFunctions">Window Functions</a></li>
133</ul><!--
134 ! Licensed to the Apache Software Foundation (ASF) under one
135 ! or more contributor license agreements. See the NOTICE file
136 ! distributed with this work for additional information
137 ! regarding copyright ownership. The ASF licenses this file
138 ! to you under the Apache License, Version 2.0 (the
139 ! "License"); you may not use this file except in compliance
140 ! with the License. You may obtain a copy of the License at
141 !
142 ! http://www.apache.org/licenses/LICENSE-2.0
143 !
144 ! Unless required by applicable law or agreed to in writing,
145 ! software distributed under the License is distributed on an
146 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
147 ! KIND, either express or implied. See the License for the
148 ! specific language governing permissions and limitations
149 ! under the License.
150 !-->
151
152<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><!--
153 ! Licensed to the Apache Software Foundation (ASF) under one
154 ! or more contributor license agreements. See the NOTICE file
155 ! distributed with this work for additional information
156 ! regarding copyright ownership. The ASF licenses this file
157 ! to you under the Apache License, Version 2.0 (the
158 ! "License"); you may not use this file except in compliance
159 ! with the License. You may obtain a copy of the License at
160 !
161 ! http://www.apache.org/licenses/LICENSE-2.0
162 !
163 ! Unless required by applicable law or agreed to in writing,
164 ! software distributed under the License is distributed on an
165 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
166 ! KIND, either express or implied. See the License for the
167 ! specific language governing permissions and limitations
168 ! under the License.
169 !-->
170</div>
171<div class="section">
172<h2><a name="Numeric_Functions"></a><a name="NumericFunctions" id="NumericFunctions">Numeric Functions</a></h2>
173<div class="section">
174<h3><a name="abs"></a>abs</h3>
175<ul>
176
177<li>
178
179<p>Syntax:</p>
180
181<div>
182<div>
183<pre class="source">abs(numeric_value)
184</pre></div></div>
185</li>
186<li>
187
188<p>Computes the absolute value of the argument.</p>
189</li>
190<li>Arguments:
191<ul>
192
193<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>
194</ul>
195</li>
196<li>Return Value:
197<ul>
198
199<li>The absolute value of the argument with the same type as the input argument,</li>
200<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
201<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
202<li>any other non-numeric input value will cause a type error.</li>
203</ul>
204</li>
205<li>
206
207<p>Example:</p>
208
209<div>
210<div>
211<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;)) };
212</pre></div></div>
213</li>
214<li>
215
216<p>The expected result is:</p>
217
218<div>
219<div>
220<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 }
221</pre></div></div>
222</li>
223</ul></div>
224<div class="section">
225<h3><a name="acos"></a>acos</h3>
226<ul>
227
228<li>
229
230<p>Syntax:</p>
231
232<div>
233<div>
234<pre class="source">acos(numeric_value)
235</pre></div></div>
236</li>
237<li>
238
239<p>Computes the arc cosine value of the argument.</p>
240</li>
241<li>Arguments:
242<ul>
243
244<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>
245</ul>
246</li>
247<li>Return Value:
248<ul>
249
250<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>
251<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
252<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
253<li>any other non-numeric input value will cause a type error,</li>
254<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
255</ul>
256</li>
257<li>
258
259<p>Example:</p>
260
261<div>
262<div>
263<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;)) };
264</pre></div></div>
265</li>
266<li>
267
268<p>The expected result is:</p>
269
270<div>
271<div>
272<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 }
273</pre></div></div>
274</li>
275</ul></div>
276<div class="section">
277<h3><a name="asin"></a>asin</h3>
278<ul>
279
280<li>
281
282<p>Syntax:</p>
283
284<div>
285<div>
286<pre class="source">asin(numeric_value)
287</pre></div></div>
288</li>
289<li>
290
291<p>Computes the arc sine value of the argument.</p>
292</li>
293<li>Arguments:
294<ul>
295
296<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>
297</ul>
298</li>
299<li>Return Value:
300<ul>
301
302<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>
303<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
304<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
305<li>any other non-numeric input value will cause a type error,</li>
306<li>&#x201c;NaN&#x201d; for other legitimate numeric values.</li>
307</ul>
308</li>
309<li>
310
311<p>Example:</p>
312
313<div>
314<div>
315<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;)) };
316</pre></div></div>
317</li>
318<li>
319
320<p>The expected result is:</p>
321
322<div>
323<div>
324<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 }
325</pre></div></div>
326</li>
327</ul></div>
328<div class="section">
329<h3><a name="atan"></a>atan</h3>
330<ul>
331
332<li>
333
334<p>Syntax:</p>
335
336<div>
337<div>
338<pre class="source">atan(numeric_value)
339</pre></div></div>
340</li>
341<li>
342
343<p>Computes the arc tangent value of the argument.</p>
344</li>
345<li>Arguments:
346<ul>
347
348<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>
349</ul>
350</li>
351<li>Return Value:
352<ul>
353
354<li>the <tt>double</tt> arc tangent in radians for the argument,</li>
355<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
356<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
357<li>any other non-numeric input value will cause a type error.</li>
358</ul>
359</li>
360<li>
361
362<p>Example:</p>
363
364<div>
365<div>
366<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;)) };
367</pre></div></div>
368</li>
369<li>
370
371<p>The expected result is:</p>
372
373<div>
374<div>
375<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 }
376</pre></div></div>
377</li>
378</ul></div>
379<div class="section">
380<h3><a name="atan2"></a>atan2</h3>
381<ul>
382
383<li>
384
385<p>Syntax:</p>
386
387<div>
388<div>
389<pre class="source">atan2(numeric_value1, numeric_value2)
390</pre></div></div>
391</li>
392<li>
393
394<p>Computes the arc tangent value of numeric_value2/numeric_value1.</p>
395</li>
396<li>Arguments:
397<ul>
398
399<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>
400<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>
401</ul>
402</li>
403<li>Return Value:
404<ul>
405
406<li>the <tt>double</tt> arc tangent in radians for <tt>numeric_value1</tt> and <tt>numeric_value2</tt>,</li>
407<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
408<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
409<li>any other non-numeric input value will cause a type error.</li>
410</ul>
411</li>
412<li>
413
414<p>Example:</p>
415
416<div>
417<div>
418<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;)) };
419</pre></div></div>
420</li>
421<li>
422
423<p>The expected result is:</p>
424
425<div>
426<div>
427<pre class="source">{ &quot;v1&quot;: 0.4636476090008061, &quot;v2&quot;: 0.0, &quot;v3&quot;: 2.356194490192345 }
428</pre></div></div>
429</li>
430</ul></div>
431<div class="section">
432<h3><a name="ceil"></a>ceil</h3>
433<ul>
434
435<li>
436
437<p>Syntax:</p>
438
439<div>
440<div>
441<pre class="source">ceil(numeric_value)
442</pre></div></div>
443</li>
444<li>
445
446<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>
447</li>
448<li>Arguments:
449<ul>
450
451<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>
452</ul>
453</li>
454<li>Return Value:
455<ul>
456
457<li>The ceiling value for the given number in the same type as the input argument,</li>
458<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
459<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
460<li>any other non-numeric input value will cause a type error.</li>
461</ul>
462</li>
463<li>
464
465<p>Example:</p>
466
467<div>
468<div>
469<pre class="source">{
470 &quot;v1&quot;: ceil(2013),
471 &quot;v2&quot;: ceil(-4036),
472 &quot;v3&quot;: ceil(0.3),
473 &quot;v4&quot;: ceil(float(&quot;-2013.2&quot;)),
474 &quot;v5&quot;: ceil(double(&quot;-2013.893823748327284&quot;))
475};
476</pre></div></div>
477</li>
478<li>
479
480<p>The expected result is:</p>
481
482<div>
483<div>
484<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 }
485</pre></div></div>
486</li>
487</ul></div>
488<div class="section">
489<h3><a name="cos"></a>cos</h3>
490<ul>
491
492<li>
493
494<p>Syntax:</p>
495
496<div>
497<div>
498<pre class="source">cos(numeric_value)
499</pre></div></div>
500</li>
501<li>
502
503<p>Computes the cosine value of the argument.</p>
504</li>
505<li>Arguments:
506<ul>
507
508<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>
509</ul>
510</li>
511<li>Return Value:
512<ul>
513
514<li>the <tt>double</tt> cosine value for the argument,</li>
515<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
516<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
517<li>any other non-numeric input value will cause a type error.</li>
518</ul>
519</li>
520<li>
521
522<p>Example:</p>
523
524<div>
525<div>
526<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;)) };
527</pre></div></div>
528</li>
529<li>
530
531<p>The expected result is:</p>
532
533<div>
534<div>
535<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 }
536</pre></div></div>
537</li>
538</ul></div>
539<div class="section">
540<h3><a name="cosh"></a>cosh</h3>
541<ul>
542
543<li>
544
545<p>Syntax:</p>
546
547<div>
548<div>
549<pre class="source">cosh(numeric_value)
550</pre></div></div>
551</li>
552<li>
553
554<p>Computes the hyperbolic cosine value of the argument.</p>
555</li>
556<li>Arguments:
557<ul>
558
559<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>
560</ul>
561</li>
562<li>Return Value:
563<ul>
564
565<li>the <tt>double</tt> hyperbolic cosine value for the argument,</li>
566<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
567<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
568<li>any other non-numeric input value will cause a type error.</li>
569</ul>
570</li>
571<li>
572
573<p>Example:</p>
574
575<div>
576<div>
577<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;)) };
578</pre></div></div>
579</li>
580<li>
581
582<p>The expected result is:</p>
583
584<div>
585<div>
586<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 }
587</pre></div></div>
588</li>
589</ul></div>
590<div class="section">
591<h3><a name="degrees"></a>degrees</h3>
592<ul>
593
594<li>
595
596<p>Syntax:</p>
597
598<div>
599<div>
600<pre class="source">degrees(numeric_value)
601</pre></div></div>
602</li>
603<li>
604
605<p>Converts radians to degrees</p>
606</li>
607<li>Arguments:
608<ul>
609
610<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>
611</ul>
612</li>
613<li>Return Value:
614<ul>
615
616<li>The degrees value for the given radians value. The returned value has type <tt>double</tt>,</li>
617<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
618<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
619<li>any other non-numeric input value will cause a type error.</li>
620</ul>
621</li>
622<li>
623
624<p>Example:</p>
625
626<div>
627<div>
628<pre class="source">{ &quot;v1&quot;: degrees(pi()) };
629</pre></div></div>
630</li>
631<li>
632
633<p>The expected result is:</p>
634
635<div>
636<div>
637<pre class="source">{ &quot;v1&quot;: 180.0 }
638</pre></div></div>
639</li>
640</ul></div>
641<div class="section">
642<h3><a name="e"></a>e</h3>
643<ul>
644
645<li>
646
647<p>Syntax:</p>
648
649<div>
650<div>
651<pre class="source">e()
652</pre></div></div>
653</li>
654<li>
655
656<p>Return Value:</p>
657<ul>
658
659<li>e (base of the natural logarithm)</li>
660</ul>
661</li>
662<li>
663
664<p>Example:</p>
665
666<div>
667<div>
668<pre class="source">{ &quot;v1&quot;: e() };
669</pre></div></div>
670</li>
671<li>
672
673<p>The expected result is:</p>
674
675<div>
676<div>
677<pre class="source">{ &quot;v1&quot;: 2.718281828459045 }
678</pre></div></div>
679</li>
680</ul></div>
681<div class="section">
682<h3><a name="exp"></a>exp</h3>
683<ul>
684
685<li>
686
687<p>Syntax:</p>
688
689<div>
690<div>
691<pre class="source">exp(numeric_value)
692</pre></div></div>
693</li>
694<li>
695
696<p>Computes e<sup>numeric_value</sup>.</p>
697</li>
698<li>Arguments:
699<ul>
700
701<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>
702</ul>
703</li>
704<li>Return Value:
705<ul>
706
707<li>e<sup>numeric_value</sup>,</li>
708<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
709<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
710<li>any other non-numeric input value will cause a type error.</li>
711</ul>
712</li>
713<li>
714
715<p>Example:</p>
716
717<div>
718<div>
719<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;)) };
720</pre></div></div>
721</li>
722<li>
723
724<p>The expected result is:</p>
725
726<div>
727<div>
728<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; }
729</pre></div></div>
730</li>
731</ul></div>
732<div class="section">
733<h3><a name="floor"></a>floor</h3>
734<ul>
735
736<li>
737
738<p>Syntax:</p>
739
740<div>
741<div>
742<pre class="source">floor(numeric_value)
743</pre></div></div>
744</li>
745<li>
746
747<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>
748</li>
749<li>Arguments:
750<ul>
751
752<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>
753</ul>
754</li>
755<li>Return Value:
756<ul>
757
758<li>The floor value for the given number in the same type as the input argument,</li>
759<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
760<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
761<li>any other non-numeric input value will cause a type error.</li>
762</ul>
763</li>
764<li>
765
766<p>Example:</p>
767
768<div>
769<div>
770<pre class="source">{
771 &quot;v1&quot;: floor(2013),
772 &quot;v2&quot;: floor(-4036),
773 &quot;v3&quot;: floor(0.8),
774 &quot;v4&quot;: floor(float(&quot;-2013.2&quot;)),
775 &quot;v5&quot;: floor(double(&quot;-2013.893823748327284&quot;))
776};
777</pre></div></div>
778</li>
779<li>
780
781<p>The expected result is:</p>
782
783<div>
784<div>
785<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 }
786</pre></div></div>
787</li>
788</ul></div>
789<div class="section">
790<h3><a name="ln"></a>ln</h3>
791<ul>
792
793<li>
794
795<p>Syntax:</p>
796
797<div>
798<div>
799<pre class="source">ln(numeric_value)
800</pre></div></div>
801</li>
802<li>
803
804<p>Computes log<sub>e</sub>numeric_value.</p>
805</li>
806<li>Arguments:
807<ul>
808
809<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>
810</ul>
811</li>
812<li>Return Value:
813<ul>
814
815<li>log<sub>e</sub>numeric_value,</li>
816<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
817<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
818<li>any other non-numeric input value will cause a type error.</li>
819</ul>
820</li>
821<li>
822
823<p>Example:</p>
824
825<div>
826<div>
827<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;)) };
828</pre></div></div>
829</li>
830<li>
831
832<p>The expected result is:</p>
833
834<div>
835<div>
836<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 }
837</pre></div></div>
838</li>
839</ul></div>
840<div class="section">
841<h3><a name="log"></a>log</h3>
842<ul>
843
844<li>
845
846<p>Syntax:</p>
847
848<div>
849<div>
850<pre class="source">log(numeric_value)
851</pre></div></div>
852</li>
853<li>
854
855<p>Computes log<sub>10</sub>numeric_value.</p>
856</li>
857<li>Arguments:
858<ul>
859
860<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>
861</ul>
862</li>
863<li>Return Value:
864<ul>
865
866<li>log<sub>10</sub>numeric_value,</li>
867<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
868<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
869<li>any other non-numeric input value will cause a type error.</li>
870</ul>
871</li>
872<li>
873
874<p>Example:</p>
875
876<div>
877<div>
878<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;)) };
879</pre></div></div>
880</li>
881<li>
882
883<p>The expected result is:</p>
884
885<div>
886<div>
887<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 }
888</pre></div></div>
889</li>
890</ul></div>
891<div class="section">
892<h3><a name="pi"></a>pi</h3>
893<ul>
894
895<li>
896
897<p>Syntax:</p>
898
899<div>
900<div>
901<pre class="source">pi()
902</pre></div></div>
903</li>
904<li>
905
906<p>Return Value:</p>
907<ul>
908
909<li>Pi</li>
910</ul>
911</li>
912<li>
913
914<p>Example:</p>
915
916<div>
917<div>
918<pre class="source">{ &quot;v1&quot;: pi() };
919</pre></div></div>
920</li>
921<li>
922
923<p>The expected result is:</p>
924
925<div>
926<div>
927<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
928</pre></div></div>
929</li>
930</ul></div>
931<div class="section">
932<h3><a name="power"></a>power</h3>
933<ul>
934
935<li>
936
937<p>Syntax:</p>
938
939<div>
940<div>
941<pre class="source">power(numeric_value1, numeric_value2)
942</pre></div></div>
943</li>
944<li>
945
946<p>Computes numeric_value1<sup>numeric_value2</sup>.</p>
947</li>
948<li>Arguments:
949<ul>
950
951<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>
952<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>
953</ul>
954</li>
955<li>Return Value:
956<ul>
957
958<li>numeric_value1<sup>numeric_value2</sup>,</li>
959<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
960<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
961<li>any other non-numeric input value will cause a type error.</li>
962</ul>
963</li>
964<li>
965
966<p>Example:</p>
967
968<div>
969<div>
970<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;)) };
971</pre></div></div>
972</li>
973<li>
974
975<p>The expected result is:</p>
976
977<div>
978<div>
979<pre class="source">{ &quot;v1&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1.4142135623730951 }
980</pre></div></div>
981</li>
982</ul></div>
983<div class="section">
984<h3><a name="radians"></a>radians</h3>
985<ul>
986
987<li>
988
989<p>Syntax:</p>
990
991<div>
992<div>
993<pre class="source">radians(numeric_value)
994</pre></div></div>
995</li>
996<li>
997
998<p>Converts degrees to radians</p>
999</li>
1000<li>Arguments:
1001<ul>
1002
1003<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>
1004</ul>
1005</li>
1006<li>Return Value:
1007<ul>
1008
1009<li>The radians value for the given degrees value. The returned value has type <tt>double</tt>,</li>
1010<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1011<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1012<li>any other non-numeric input value will cause a type error.</li>
1013</ul>
1014</li>
1015<li>
1016
1017<p>Example:</p>
1018
1019<div>
1020<div>
1021<pre class="source">{ &quot;v1&quot;: radians(180) };
1022</pre></div></div>
1023</li>
1024<li>
1025
1026<p>The expected result is:</p>
1027
1028<div>
1029<div>
1030<pre class="source">{ &quot;v1&quot;: 3.141592653589793 }
1031</pre></div></div>
1032</li>
1033</ul></div>
1034<div class="section">
1035<h3><a name="round"></a>round</h3>
1036<ul>
1037
1038<li>
1039
1040<p>Syntax:</p>
1041
1042<div>
1043<div>
1044<pre class="source">round(numeric_value[, round_digit])
1045</pre></div></div>
1046</li>
1047<li>
1048
1049<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>
1050</li>
1051<li>
1052
1053<p>Arguments:</p>
1054<ul>
1055
1056<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>
1057<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>
1058</ul>
1059</li>
1060<li>Return Value:
1061<ul>
1062
1063<li>The rounded value for the given number. The returned value has the following type:
1064<ul>
1065
1066<li><tt>bigint</tt> if the input value has type <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt> or <tt>bigint</tt>,</li>
1067<li><tt>float</tt> if the input value has type <tt>float</tt>,</li>
1068<li><tt>double</tt> if the input value has type <tt>double</tt>;</li>
1069</ul>
1070</li>
1071<li><tt>missing</tt> if the input value is a <tt>missing</tt> value,</li>
1072<li><tt>null</tt> if the input value is a <tt>null</tt> value,</li>
1073<li>any other non-numeric input value will return a <tt>null</tt> value.</li>
1074</ul>
1075</li>
1076<li>
1077
1078<p>Example:</p>
1079
1080<div>
1081<div>
1082<pre class="source">{
1083 &quot;v1&quot;: round(2013),
1084 &quot;v2&quot;: round(-4036),
1085 &quot;v3&quot;: round(0.8),
1086 &quot;v4&quot;: round(float(&quot;-2013.256&quot;)),
1087 &quot;v5&quot;: round(double(&quot;-2013.893823748327284&quot;))
1088 &quot;v6&quot;: round(123456, -1),
1089 &quot;v7&quot;: round(456.456, 2),
1090 &quot;v8&quot;: round(456.456, -1),
1091 &quot;v9&quot;: round(-456.456, -2)
1092};
1093</pre></div></div>
1094</li>
1095<li>
1096
1097<p>The expected result is:</p>
1098
1099<div>
1100<div>
1101<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 }
1102</pre></div></div>
1103</li>
1104</ul></div>
1105<div class="section">
1106<h3><a name="sign"></a>sign</h3>
1107<ul>
1108
1109<li>
1110
1111<p>Syntax:</p>
1112
1113<div>
1114<div>
1115<pre class="source">sign(numeric_value)
1116</pre></div></div>
1117</li>
1118<li>
1119
1120<p>Computes the sign of the argument.</p>
1121</li>
1122<li>Arguments:
1123<ul>
1124
1125<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>
1126</ul>
1127</li>
1128<li>Return Value:
1129<ul>
1130
1131<li>the sign (a <tt>tinyint</tt>) of the argument, -1 for negative values, 0 for 0, and 1 for positive values,</li>
1132<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1133<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1134<li>any other non-numeric input value will cause a type error.</li>
1135</ul>
1136</li>
1137<li>
1138
1139<p>Example:</p>
1140
1141<div>
1142<div>
1143<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;)) };
1144</pre></div></div>
1145</li>
1146<li>
1147
1148<p>The expected result is:</p>
1149
1150<div>
1151<div>
1152<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: 1, &quot;v3&quot;: 0, &quot;v4&quot;: 1, &quot;v5&quot;: -1 }
1153</pre></div></div>
1154</li>
1155</ul></div>
1156<div class="section">
1157<h3><a name="sin"></a>sin</h3>
1158<ul>
1159
1160<li>
1161
1162<p>Syntax:</p>
1163
1164<div>
1165<div>
1166<pre class="source">sin(numeric_value)
1167</pre></div></div>
1168</li>
1169<li>
1170
1171<p>Computes the sine value of the argument.</p>
1172</li>
1173<li>Arguments:
1174<ul>
1175
1176<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>
1177</ul>
1178</li>
1179<li>Return Value:
1180<ul>
1181
1182<li>the <tt>double</tt> sine value for the argument,</li>
1183<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1184<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1185<li>any other non-numeric input value will cause a type error.</li>
1186</ul>
1187</li>
1188<li>
1189
1190<p>Example:</p>
1191
1192<div>
1193<div>
1194<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;)) };
1195</pre></div></div>
1196</li>
1197<li>
1198
1199<p>The expected result is:</p>
1200
1201<div>
1202<div>
1203<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 }
1204</pre></div></div>
1205</li>
1206</ul></div>
1207<div class="section">
1208<h3><a name="sinh"></a>sinh</h3>
1209<ul>
1210
1211<li>
1212
1213<p>Syntax:</p>
1214
1215<div>
1216<div>
1217<pre class="source">sinh(numeric_value)
1218</pre></div></div>
1219</li>
1220<li>
1221
1222<p>Computes the hyperbolic sine value of the argument.</p>
1223</li>
1224<li>Arguments:
1225<ul>
1226
1227<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>
1228</ul>
1229</li>
1230<li>Return Value:
1231<ul>
1232
1233<li>the <tt>double</tt> hyperbolic sine value for the argument,</li>
1234<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1235<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1236<li>any other non-numeric input value will cause a type error.</li>
1237</ul>
1238</li>
1239<li>
1240
1241<p>Example:</p>
1242
1243<div>
1244<div>
1245<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;)) };
1246</pre></div></div>
1247</li>
1248<li>
1249
1250<p>The expected result is:</p>
1251
1252<div>
1253<div>
1254<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 }
1255</pre></div></div>
1256</li>
1257</ul></div>
1258<div class="section">
1259<h3><a name="sqrt"></a>sqrt</h3>
1260<ul>
1261
1262<li>
1263
1264<p>Syntax:</p>
1265
1266<div>
1267<div>
1268<pre class="source">sqrt(numeric_value)
1269</pre></div></div>
1270</li>
1271<li>
1272
1273<p>Computes the square root of the argument.</p>
1274</li>
1275<li>Arguments:
1276<ul>
1277
1278<li><tt>numeric_value</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt>/<tt>float</tt>/<tt>double</tt> value.</li>
1279</ul>
1280</li>
1281<li>Return Value:
1282<ul>
1283
1284<li>the <tt>double</tt> square root value for the argument,</li>
1285<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1286<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1287<li>any other non-numeric input value will cause a type error.</li>
1288</ul>
1289</li>
1290<li>
1291
1292<p>Example:</p>
1293
1294<div>
1295<div>
1296<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;)) };
1297</pre></div></div>
1298</li>
1299<li>
1300
1301<p>The expected result is:</p>
1302
1303<div>
1304<div>
1305<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 }
1306</pre></div></div>
1307</li>
1308</ul></div>
1309<div class="section">
1310<h3><a name="tan"></a>tan</h3>
1311<ul>
1312
1313<li>
1314
1315<p>Syntax:</p>
1316
1317<div>
1318<div>
1319<pre class="source">tan(numeric_value)
1320</pre></div></div>
1321</li>
1322<li>
1323
1324<p>Computes the tangent value of the argument.</p>
1325</li>
1326<li>Arguments:
1327<ul>
1328
1329<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>
1330</ul>
1331</li>
1332<li>Return Value:
1333<ul>
1334
1335<li>the <tt>double</tt> tangent value for the argument,</li>
1336<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1337<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1338<li>any other non-numeric input value will cause a type error.</li>
1339</ul>
1340</li>
1341<li>
1342
1343<p>Example:</p>
1344
1345<div>
1346<div>
1347<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;)) };
1348</pre></div></div>
1349</li>
1350<li>
1351
1352<p>The expected result is:</p>
1353
1354<div>
1355<div>
1356<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 }
1357</pre></div></div>
1358</li>
1359</ul></div>
1360<div class="section">
1361<h3><a name="tanh"></a>tanh</h3>
1362<ul>
1363
1364<li>
1365
1366<p>Syntax:</p>
1367
1368<div>
1369<div>
1370<pre class="source">tanh(numeric_value)
1371</pre></div></div>
1372</li>
1373<li>
1374
1375<p>Computes the hyperbolic tangent value of the argument.</p>
1376</li>
1377<li>Arguments:
1378<ul>
1379
1380<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>
1381</ul>
1382</li>
1383<li>Return Value:
1384<ul>
1385
1386<li>the <tt>double</tt> hyperbolic tangent value for the argument,</li>
1387<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1388<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1389<li>any other non-numeric input value will cause a type error.</li>
1390</ul>
1391</li>
1392<li>
1393
1394<p>Example:</p>
1395
1396<div>
1397<div>
1398<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;)) };
1399</pre></div></div>
1400</li>
1401<li>
1402
1403<p>The expected result is:</p>
1404
1405<div>
1406<div>
1407<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 }
1408</pre></div></div>
1409</li>
1410</ul></div>
1411<div class="section">
1412<h3><a name="trunc"></a>trunc</h3>
1413<ul>
1414
1415<li>
1416
1417<p>Syntax:</p>
1418
1419<div>
1420<div>
1421<pre class="source">trunc(numeric_value, number_digits)
1422</pre></div></div>
1423</li>
1424<li>
1425
1426<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>
1427</li>
1428<li>Arguments:
1429<ul>
1430
1431<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>
1432<li><tt>number_digits</tt>: a <tt>tinyint</tt>/<tt>smallint</tt>/<tt>integer</tt>/<tt>bigint</tt> value.</li>
1433</ul>
1434</li>
1435<li>Return Value:
1436<ul>
1437
1438<li>the <tt>double</tt> tangent value for the argument,</li>
1439<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1440<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is <tt>missing</tt>,</li>
1441<li>a type error will be raised if:
1442<ul>
1443
1444<li>the first argument is any other non-numeric value,</li>
1445<li>the second argument is any other non-tinyint, non-smallint, non-integer, and non-bigint value.</li>
1446</ul>
1447</li>
1448</ul>
1449</li>
1450<li>
1451
1452<p>Example:</p>
1453
1454<div>
1455<div>
1456<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) };
1457</pre></div></div>
1458</li>
1459<li>
1460
1461<p>The expected result is:</p>
1462
1463<div>
1464<div>
1465<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 }
1466</pre></div></div>
1467</li>
1468</ul><!--
1469 ! Licensed to the Apache Software Foundation (ASF) under one
1470 ! or more contributor license agreements. See the NOTICE file
1471 ! distributed with this work for additional information
1472 ! regarding copyright ownership. The ASF licenses this file
1473 ! to you under the Apache License, Version 2.0 (the
1474 ! "License"); you may not use this file except in compliance
1475 ! with the License. You may obtain a copy of the License at
1476 !
1477 ! http://www.apache.org/licenses/LICENSE-2.0
1478 !
1479 ! Unless required by applicable law or agreed to in writing,
1480 ! software distributed under the License is distributed on an
1481 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1482 ! KIND, either express or implied. See the License for the
1483 ! specific language governing permissions and limitations
1484 ! under the License.
1485 !-->
1486</div>
1487<div class="section">
1488<h3><a name="round_half_to_even"></a>round_half_to_even</h3>
1489<ul>
1490
1491<li>
1492
1493<p>Syntax:</p>
1494
1495<div>
1496<div>
1497<pre class="source">round_half_to_even(numeric_value, [precision])
1498</pre></div></div>
1499</li>
1500<li>
1501
1502<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>
1503</li>
1504<li>Arguments:
1505<ul>
1506
1507<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>
1508<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>
1509</ul>
1510</li>
1511<li>Return Value:
1512<ul>
1513
1514<li>The rounded value for the given number in the same type as the input argument,</li>
1515<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1516<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1517<li>a type error will be raised if:
1518<ul>
1519
1520<li>the first argument is any other non-numeric value,</li>
1521<li>or, the second argument is any other non-tinyint, non-smallint, non-integer, or non-bigint value.</li>
1522</ul>
1523</li>
1524</ul>
1525</li>
1526<li>
1527
1528<p>Example:</p>
1529
1530<div>
1531<div>
1532<pre class="source">{
1533 &quot;v1&quot;: round_half_to_even(2013),
1534 &quot;v2&quot;: round_half_to_even(-4036),
1535 &quot;v3&quot;: round_half_to_even(0.8),
1536 &quot;v4&quot;: round_half_to_even(float(&quot;-2013.256&quot;)),
1537 &quot;v5&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;)),
1538 &quot;v6&quot;: round_half_to_even(double(&quot;-2013.893823748327284&quot;), 2),
1539 &quot;v7&quot;: round_half_to_even(2013, 4),
1540 &quot;v8&quot;: round_half_to_even(float(&quot;-2013.256&quot;), 5)
1541};
1542</pre></div></div>
1543</li>
1544<li>
1545
1546<p>The expected result is:</p>
1547
1548<div>
1549<div>
1550<pre class="source">{ &quot;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 }
1551</pre></div></div>
1552</li>
1553</ul><!--
1554 ! Licensed to the Apache Software Foundation (ASF) under one
1555 ! or more contributor license agreements. See the NOTICE file
1556 ! distributed with this work for additional information
1557 ! regarding copyright ownership. The ASF licenses this file
1558 ! to you under the Apache License, Version 2.0 (the
1559 ! "License"); you may not use this file except in compliance
1560 ! with the License. You may obtain a copy of the License at
1561 !
1562 ! http://www.apache.org/licenses/LICENSE-2.0
1563 !
1564 ! Unless required by applicable law or agreed to in writing,
1565 ! software distributed under the License is distributed on an
1566 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1567 ! KIND, either express or implied. See the License for the
1568 ! specific language governing permissions and limitations
1569 ! under the License.
1570 !-->
1571</div></div>
1572<div class="section">
1573<h2><a name="String_Functions"></a><a name="StringFunctions" id="StringFunctions">String Functions</a></h2>
1574<div class="section">
1575<h3><a name="concat"></a>concat</h3>
1576<ul>
1577
1578<li>
1579
1580<p>Syntax:</p>
1581
1582<div>
1583<div>
1584<pre class="source">concat(string1, string2, ...)
1585</pre></div></div>
1586</li>
1587<li>
1588
1589<p>Returns a concatenated string from arguments.</p>
1590</li>
1591<li>Arguments:
1592<ul>
1593
1594<li><tt>string1</tt>: a string value,</li>
1595<li><tt>string2</tt>: a string value,</li>
1596<li>&#x2026;.</li>
1597</ul>
1598</li>
1599<li>Return Value:
1600<ul>
1601
1602<li>a concatenated string from arguments,</li>
1603<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1604<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1605<li>any other non-string input value will cause a type error.</li>
1606</ul>
1607</li>
1608<li>
1609
1610<p>Example:</p>
1611
1612<div>
1613<div>
1614<pre class="source">concat(&quot;test &quot;, &quot;driven &quot;, &quot;development&quot;);
1615</pre></div></div>
1616</li>
1617<li>
1618
1619<p>The expected result is:</p>
1620
1621<div>
1622<div>
1623<pre class="source">&quot;test driven development&quot;
1624</pre></div></div>
1625</li>
1626</ul></div>
1627<div class="section">
1628<h3><a name="contains"></a>contains</h3>
1629<ul>
1630
1631<li>
1632
1633<p>Syntax:</p>
1634
1635<div>
1636<div>
1637<pre class="source">contains(string, substring_to_contain)
1638</pre></div></div>
1639</li>
1640<li>
1641
1642<p>Checks whether the string <tt>string</tt> contains the string <tt>substring_to_contain</tt></p>
1643</li>
1644<li>Arguments:
1645<ul>
1646
1647<li><tt>string</tt> : a <tt>string</tt> that might contain the given substring,</li>
1648<li><tt>substring_to_contain</tt> : a target <tt>string</tt> that might be contained.</li>
1649</ul>
1650</li>
1651<li>Return Value:
1652<ul>
1653
1654<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1655<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1656<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1657<li>any other non-string input value will cause a type error,</li>
1658<li><tt>false</tt> otherwise.</li>
1659</ul>
1660</li>
1661<li>
1662
1663<p>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</p>
1664</li>
1665<li>Example:
1666
1667<div>
1668<div>
1669<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;) };
1670</pre></div></div>
1671</li>
1672<li>
1673
1674<p>The expected result is:</p>
1675
1676<div>
1677<div>
1678<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1679</pre></div></div>
1680</li>
1681</ul></div>
1682<div class="section">
1683<h3><a name="ends_with"></a>ends_with</h3>
1684<ul>
1685
1686<li>
1687
1688<p>Syntax:</p>
1689
1690<div>
1691<div>
1692<pre class="source">ends_with(string, substring_to_end_with)
1693</pre></div></div>
1694</li>
1695<li>
1696
1697<p>Checks whether the string <tt>string</tt> ends with the string <tt>substring_to_end_with</tt>.</p>
1698</li>
1699<li>Arguments:
1700<ul>
1701
1702<li><tt>string</tt> : a <tt>string</tt> that might end with the given string,</li>
1703<li><tt>substring_to_end_with</tt> : a <tt>string</tt> that might be contained as the ending substring.</li>
1704</ul>
1705</li>
1706<li>Return Value:
1707<ul>
1708
1709<li>a <tt>boolean</tt> value, <tt>true</tt> if <tt>string</tt> contains <tt>substring_to_contain</tt>,</li>
1710<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1711<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1712<li>any other non-string input value will cause a type error,</li>
1713<li><tt>false</tt> otherwise.</li>
1714</ul>
1715</li>
1716<li>
1717
1718<p>Example:</p>
1719
1720<div>
1721<div>
1722<pre class="source">{
1723 &quot;v1&quot;: ends_with(&quot; love product-b its shortcut_menu is awesome:)&quot;, &quot;:)&quot;),
1724 &quot;v2&quot;: ends_with(&quot; awsome:)&quot;, &quot;:-)&quot;)
1725};
1726</pre></div></div>
1727</li>
1728<li>
1729
1730<p>The expected result is:</p>
1731
1732<div>
1733<div>
1734<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
1735</pre></div></div>
1736</li>
1737</ul></div>
1738<div class="section">
1739<h3><a name="initcap_.28or_title.29"></a>initcap (or title)</h3>
1740<ul>
1741
1742<li>
1743
1744<p>Syntax:</p>
1745
1746<div>
1747<div>
1748<pre class="source">initcap(string)
1749</pre></div></div>
1750</li>
1751<li>
1752
1753<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>
1754</li>
1755<li>Arguments:
1756<ul>
1757
1758<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1759</ul>
1760</li>
1761<li>Return Value:
1762<ul>
1763
1764<li>a <tt>string</tt> as the title form of the given <tt>string</tt>,</li>
1765<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1766<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1767<li>any other non-string input value will cause a type error.</li>
1768</ul>
1769</li>
1770<li>
1771
1772<p>Example:</p>
1773
1774<div>
1775<div>
1776<pre class="source">{ &quot;v1&quot;: initcap(&quot;ASTERIXDB is here!&quot;), &quot;v2&quot;: title(&quot;ASTERIXDB is here!&quot;) };
1777</pre></div></div>
1778</li>
1779<li>
1780
1781<p>The expected result is:</p>
1782
1783<div>
1784<div>
1785<pre class="source">{ &quot;v1&quot;: &quot;Asterixdb Is Here!&quot;, &quot;v2&quot;: &quot;Asterixdb Is Here!&quot; }
1786</pre></div></div>
1787</li>
1788</ul></div>
1789<div class="section">
1790<h3><a name="length"></a>length</h3>
1791<ul>
1792
1793<li>
1794
1795<p>Syntax:</p>
1796
1797<div>
1798<div>
1799<pre class="source">length(string)
1800</pre></div></div>
1801</li>
1802<li>
1803
1804<p>Returns the length of the string <tt>string</tt>. Note that the length is in the unit of code point. See the following examples for more details.</p>
1805</li>
1806<li>Arguments:
1807<ul>
1808
1809<li><tt>string</tt> : a <tt>string</tt> or <tt>null</tt> that represents the string to be checked.</li>
1810</ul>
1811</li>
1812<li>Return Value:
1813<ul>
1814
1815<li>an <tt>bigint</tt> that represents the length of <tt>string</tt>,</li>
1816<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1817<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1818<li>any other non-string input value will cause a type error.</li>
1819</ul>
1820</li>
1821<li>
1822
1823<p>Example:</p>
1824
1825<div>
1826<div>
1827<pre class="source">length(&quot;test string&quot;);
1828</pre></div></div>
1829</li>
1830<li>
1831
1832<p>The expected result is:</p>
1833
1834<div>
1835<div>
1836<pre class="source">11
1837</pre></div></div>
1838</li>
1839<li>
1840
1841<p>Example:</p>
1842
1843<div>
1844<div>
1845<pre class="source">length(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;);
1846</pre></div></div>
1847</li>
1848<li>
1849
1850<p>The expected result is (the emoji character &#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points):</p>
1851
1852<div>
1853<div>
1854<pre class="source">7
1855</pre></div></div>
1856</li>
1857</ul></div>
1858<div class="section">
1859<h3><a name="lower"></a>lower</h3>
1860<ul>
1861
1862<li>
1863
1864<p>Syntax:</p>
1865
1866<div>
1867<div>
1868<pre class="source">lower(string)
1869</pre></div></div>
1870</li>
1871<li>
1872
1873<p>Converts a given string <tt>string</tt> to its lowercase form.</p>
1874</li>
1875<li>Arguments:
1876<ul>
1877
1878<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
1879</ul>
1880</li>
1881<li>Return Value:
1882<ul>
1883
1884<li>a <tt>string</tt> as the lowercase form of the given <tt>string</tt>,</li>
1885<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
1886<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
1887<li>any other non-string input value will cause a type error.</li>
1888</ul>
1889</li>
1890<li>
1891
1892<p>Example:</p>
1893
1894<div>
1895<div>
1896<pre class="source">lower(&quot;ASTERIXDB&quot;);
1897</pre></div></div>
1898</li>
1899<li>
1900
1901<p>The expected result is:</p>
1902
1903<div>
1904<div>
1905<pre class="source">&quot;asterixdb&quot;
1906</pre></div></div>
1907</li>
1908</ul></div>
1909<div class="section">
1910<h3><a name="ltrim"></a>ltrim</h3>
1911<ul>
1912
1913<li>
1914
1915<p>Syntax:</p>
1916
1917<div>
1918<div>
1919<pre class="source">ltrim(string[, chars]);
1920</pre></div></div>
1921</li>
1922<li>
1923
1924<p>Returns a new string with all leading characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
1925</li>
1926<li>Arguments:
1927<ul>
1928
1929<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
1930<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
1931</ul>
1932</li>
1933<li>Return Value:
1934<ul>
1935
1936<li>a trimmed, new <tt>string</tt>,</li>
1937<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
1938<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
1939<li>any other non-string input value will cause a type error.</li>
1940</ul>
1941</li>
1942<li>Related functions: see <tt>trim()</tt>, <tt>rtrim()</tt></li>
1943<li>
1944
1945<p>Example:</p>
1946
1947<div>
1948<div>
1949<pre class="source">ltrim(&quot;me like x-phone&quot;, &quot;eml&quot;);
1950</pre></div></div>
1951</li>
1952<li>
1953
1954<p>The expected result is:</p>
1955
1956<div>
1957<div>
1958<pre class="source">&quot; like x-phone&quot;
1959</pre></div></div>
1960</li>
1961<li>
1962
1963<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
1964
1965<div>
1966<div>
1967<pre class="source">ltrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
1968</pre></div></div>
1969</li>
1970<li>
1971
1972<p>The expected result is (only woman, girl and boy are left in the family):</p>
1973
1974<div>
1975<div>
1976<pre class="source">&quot;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;
1977</pre></div></div>
1978</li>
1979</ul></div>
1980<div class="section">
1981<h3><a name="position"></a>position</h3>
1982<ul>
1983
1984<li>
1985
1986<p>Syntax:</p>
1987
1988<div>
1989<div>
1990<pre class="source">position(string, string_pattern)
1991</pre></div></div>
1992</li>
1993<li>
1994
1995<p>Returns the first position of <tt>string_pattern</tt> within <tt>string</tt>. The result is counted in the unit of code points. See the following example for more details.</p>
1996</li>
1997<li>
1998
1999<p>The function returns the 0-based position. Another version of the function returns the 1-based position. Below are the aliases for each version:</p>
2000<ul>
2001
2002<li>0-based: <tt>position</tt>, <tt>pos</tt>, <tt>position0</tt>, <tt>pos0</tt>.</li>
2003<li>1-based: <tt>position1</tt>, <tt>pos1</tt>.</li>
2004</ul>
2005</li>
2006<li>
2007
2008<p>Arguments:</p>
2009<ul>
2010
2011<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2012<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2013</ul>
2014</li>
2015<li>Return Value:
2016<ul>
2017
2018<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>
2019<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2020<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2021<li>any other non-string input value will return a <tt>null</tt>.</li>
2022</ul>
2023</li>
2024<li>
2025
2026<p>Example:</p>
2027
2028<div>
2029<div>
2030<pre class="source">{
2031 &quot;v1&quot;: position(&quot;ppphonepp&quot;, &quot;phone&quot;),
2032 &quot;v2&quot;: position(&quot;hone&quot;, &quot;phone&quot;),
2033 &quot;v3&quot;: position1(&quot;ppphonepp&quot;, &quot;phone&quot;),
2034 &quot;v4&quot;: position1(&quot;hone&quot;, &quot;phone&quot;)
2035};
2036</pre></div></div>
2037</li>
2038<li>
2039
2040<p>The expected result is:</p>
2041
2042<div>
2043<div>
2044<pre class="source">{ &quot;v1&quot;: 2, &quot;v2&quot;: -1, v3&quot;: 3, &quot;v4&quot;: -1 }
2045</pre></div></div>
2046</li>
2047<li>
2048
2049<p>Example of multi-code-point character:</p>
2050
2051<div>
2052<div>
2053<pre class="source">position(&quot;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x1f3c0;&quot;, &quot;&#x1f3c0;&quot;);
2054</pre></div></div>
2055</li>
2056<li>
2057
2058<p>The expected result is (the emoji family character has 7 code points):</p>
2059
2060<div>
2061<div>
2062<pre class="source">7
2063</pre></div></div>
2064</li>
2065</ul></div>
2066<div class="section">
2067<h3><a name="regexp_contains"></a>regexp_contains</h3>
2068<ul>
2069
2070<li>
2071
2072<p>Syntax:</p>
2073
2074<div>
2075<div>
2076<pre class="source">regexp_contains(string, string_pattern[, string_flags])
2077</pre></div></div>
2078</li>
2079<li>
2080
2081<p>Checks whether the strings <tt>string</tt> contains the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2082</li>
2083<li>
2084
2085<p>Aliases:</p>
2086<ul>
2087
2088<li><tt>regexp_contains</tt>, <tt>regex_contains</tt>, <tt>contains_regexp</tt>, <tt>contains_regex</tt>.</li>
2089</ul>
2090</li>
2091<li>
2092
2093<p>Arguments:</p>
2094<ul>
2095
2096<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2097<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2098<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2099<ul>
2100
2101<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2102</ul>
2103</li>
2104</ul>
2105</li>
2106<li>Return Value:
2107<ul>
2108
2109<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>
2110<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2111<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2112<li>any other non-string input value will return a <tt>null</tt>.</li>
2113</ul>
2114</li>
2115<li>
2116
2117<p>Example:</p>
2118
2119<div>
2120<div>
2121<pre class="source">{
2122 &quot;v1&quot;: regexp_contains(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2123 &quot;v2&quot;: regexp_contains(&quot;hone&quot;, &quot;p+hone&quot;)
2124};
2125</pre></div></div>
2126</li>
2127<li>
2128
2129<p>The expected result is:</p>
2130
2131<div>
2132<div>
2133<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2134</pre></div></div>
2135</li>
2136</ul></div>
2137<div class="section">
2138<h3><a name="regexp_like"></a>regexp_like</h3>
2139<ul>
2140
2141<li>
2142
2143<p>Syntax:</p>
2144
2145<div>
2146<div>
2147<pre class="source">regexp_like(string, string_pattern[, string_flags])
2148</pre></div></div>
2149</li>
2150<li>
2151
2152<p>Checks whether the string <tt>string</tt> exactly matches the regular expression pattern <tt>string_pattern</tt> (a Java regular expression pattern).</p>
2153</li>
2154<li>
2155
2156<p>Aliases:</p>
2157<ul>
2158
2159<li><tt>regexp_like</tt>, <tt>regex_like</tt>.</li>
2160</ul>
2161</li>
2162<li>
2163
2164<p>Arguments:</p>
2165<ul>
2166
2167<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2168<li><tt>string_pattern</tt> : a pattern <tt>string</tt> that might be contained.</li>
2169<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2170<ul>
2171
2172<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2173</ul>
2174</li>
2175</ul>
2176</li>
2177<li>Return Value:
2178<ul>
2179
2180<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>
2181<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2182<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2183<li>any other non-string input value will return a <tt>null</tt>.</li>
2184</ul>
2185</li>
2186<li>
2187
2188<p>Example:</p>
2189
2190<div>
2191<div>
2192<pre class="source">{
2193 &quot;v1&quot;: regexp_like(&quot; can't stand acast the network is horrible:(&quot;, &quot;.*acast.*&quot;),
2194 &quot;v2&quot;: regexp_like(&quot;acast&quot;, &quot;.*acst.*&quot;)
2195};
2196</pre></div></div>
2197</li>
2198<li>
2199
2200<p>The expected result is:</p>
2201
2202<div>
2203<div>
2204<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2205</pre></div></div>
2206</li>
2207</ul></div>
2208<div class="section">
2209<h3><a name="regexp_position"></a>regexp_position</h3>
2210<ul>
2211
2212<li>
2213
2214<p>Syntax:</p>
2215
2216<div>
2217<div>
2218<pre class="source">regexp_position(string, string_pattern[, string_flags])
2219</pre></div></div>
2220</li>
2221<li>
2222
2223<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>
2224</li>
2225<li>
2226
2227<p>Aliases:</p>
2228<ul>
2229
2230<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>
2231<li>1-Based: <tt>regexp_position1</tt>, <tt>regexp_pos1</tt>, <tt>regex_position1</tt> <tt>regex_pos1</tt>.</li>
2232</ul>
2233</li>
2234<li>
2235
2236<p>Arguments:</p>
2237<ul>
2238
2239<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2240<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2241<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during regular expression matching.
2242<ul>
2243
2244<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2245</ul>
2246</li>
2247</ul>
2248</li>
2249<li>Return Value:
2250<ul>
2251
2252<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>
2253<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2254<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2255<li>any other non-string input value will return a <tt>null</tt>.</li>
2256</ul>
2257</li>
2258<li>
2259
2260<p>Example:</p>
2261
2262<div>
2263<div>
2264<pre class="source">{
2265 &quot;v1&quot;: regexp_position(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2266 &quot;v2&quot;: regexp_position(&quot;hone&quot;, &quot;p+hone&quot;),
2267 &quot;v3&quot;: regexp_position1(&quot;pphonepp&quot;, &quot;p*hone&quot;),
2268 &quot;v4&quot;: regexp_position1(&quot;hone&quot;, &quot;p+hone&quot;)
2269};
2270</pre></div></div>
2271</li>
2272<li>
2273
2274<p>The expected result is:</p>
2275
2276<div>
2277<div>
2278<pre class="source">{ &quot;v1&quot;: 0, &quot;v2&quot;: -1, &quot;v3&quot;: 1, &quot;v4&quot;: -1 }
2279</pre></div></div>
2280</li>
2281</ul></div>
2282<div class="section">
2283<h3><a name="regexp_replace"></a>regexp_replace</h3>
2284<ul>
2285
2286<li>
2287
2288<p>Syntax:</p>
2289
2290<div>
2291<div>
2292<pre class="source">regexp_replace(string, string_pattern, string_replacement[, string_flags])
2293regexp_replace(string, string_pattern, string_replacement[, replacement_limit])
2294</pre></div></div>
2295</li>
2296<li>
2297
2298<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>
2299</li>
2300<li>
2301
2302<p>Aliases:</p>
2303<ul>
2304
2305<li><tt>regexp_replace</tt>, <tt>regex_replace</tt>.</li>
2306</ul>
2307</li>
2308<li>
2309
2310<p>Arguments:</p>
2311<ul>
2312
2313<li><tt>string</tt> : a <tt>string</tt> that might contain the pattern.</li>
2314<li><tt>string_pattern</tt> : a pattern <tt>string</tt> to be matched.</li>
2315<li><tt>string_replacement</tt> : a pattern <tt>string</tt> to be used as the replacement.</li>
2316<li><tt>string_flag</tt> : (Optional) a <tt>string</tt> with flags to be used during replace.
2317<ul>
2318
2319<li>The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x).</li>
2320</ul>
2321</li>
2322<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>
2323</ul>
2324</li>
2325<li>Return Value:
2326<ul>
2327
2328<li>Returns a <tt>string</tt> that is obtained after the replacements.</li>
2329<li><tt>missing</tt> if any argument is a <tt>missing</tt> value.</li>
2330<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2331<li>any other non-string input value will return a <tt>null</tt>.</li>
2332</ul>
2333</li>
2334<li>
2335
2336<p>Example:</p>
2337
2338<div>
2339<div>
2340<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;);
2341</pre></div></div>
2342</li>
2343<li>
2344
2345<p>The expected result is:</p>
2346
2347<div>
2348<div>
2349<pre class="source">&quot;like product-a the voicemail_service is awesome&quot;
2350</pre></div></div>
2351</li>
2352</ul></div>
2353<div class="section">
2354<h3><a name="repeat"></a>repeat</h3>
2355<ul>
2356
2357<li>
2358
2359<p>Syntax:</p>
2360
2361<div>
2362<div>
2363<pre class="source">repeat(string, n)
2364</pre></div></div>
2365</li>
2366<li>
2367
2368<p>Returns a string formed by repeating the input <tt>string</tt> <tt>n</tt> times.</p>
2369</li>
2370<li>Arguments:
2371<ul>
2372
2373<li><tt>string</tt> : a <tt>string</tt> to be repeated,</li>
2374<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>
2375</ul>
2376</li>
2377<li>Return Value:
2378<ul>
2379
2380<li>a string that repeats the input <tt>string</tt> <tt>n</tt> times,</li>
2381<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2382<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2383<li>a type error will be raised if:
2384<ul>
2385
2386<li>the first argument is any other non-string value,</li>
2387<li>or, the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2388</ul>
2389</li>
2390</ul>
2391</li>
2392<li>
2393
2394<p>Example:</p>
2395
2396<div>
2397<div>
2398<pre class="source">repeat(&quot;test&quot;, 3);
2399</pre></div></div>
2400</li>
2401<li>
2402
2403<p>The expected result is:</p>
2404
2405<div>
2406<div>
2407<pre class="source">&quot;testtesttest&quot;
2408</pre></div></div>
2409</li>
2410</ul></div>
2411<div class="section">
2412<h3><a name="replace"></a>replace</h3>
2413<ul>
2414
2415<li>
2416
2417<p>Syntax:</p>
2418
2419<div>
2420<div>
2421<pre class="source">replace(string, search_string, replacement_string[, limit])
2422</pre></div></div>
2423</li>
2424<li>
2425
2426<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>
2427</li>
2428<li>Arguments:
2429<ul>
2430
2431<li><tt>string</tt> : an input <tt>string</tt>,</li>
2432<li><tt>search_string</tt> : a <tt>string</tt> substring to be searched for,</li>
2433<li><tt>replacement_string</tt> : a <tt>string</tt> to be used as the replacement,</li>
2434<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>
2435</ul>
2436</li>
2437<li>Return Value:
2438<ul>
2439
2440<li>Returns a <tt>string</tt> that is obtained after the replacements,</li>
2441<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2442<li>any other non-string input value or non-integer <tt>limit</tt> will cause a type error,</li>
2443<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
2444</ul>
2445</li>
2446<li>
2447
2448<p>Example:</p>
2449
2450<div>
2451<div>
2452<pre class="source">{
2453 &quot;v1&quot;: replace(&quot; like x-phone the voicemail_service is awesome&quot;, &quot; like x-phone&quot;, &quot;like product-a&quot;),
2454 &quot;v2&quot;: replace(&quot;x-phone and x-phone&quot;, &quot;x-phone&quot;, &quot;product-a&quot;, 1)
2455};
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">{
2465 &quot;v1&quot;: &quot;like product-a the voicemail_service is awesome&quot;,
2466 &quot;v2&quot;: &quot;product-a and x-phone&quot;
2467}
2468</pre></div></div>
2469</li>
2470</ul></div>
2471<div class="section">
2472<h3><a name="reverse"></a>reverse</h3>
2473<ul>
2474
2475<li>
2476
2477<p>Syntax:</p>
2478
2479<div>
2480<div>
2481<pre class="source">reverse(string)
2482</pre></div></div>
2483</li>
2484<li>
2485
2486<p>Returns a string formed by reversing characters in the input <tt>string</tt>. For characters of multiple code points, code point is the minimal unit to reverse. See the following examples for more details.</p>
2487</li>
2488<li>Arguments:
2489<ul>
2490
2491<li><tt>string</tt> : a <tt>string</tt> to be reversed</li>
2492</ul>
2493</li>
2494<li>Return Value:
2495<ul>
2496
2497<li>a string containing characters from the the input <tt>string</tt> in the reverse order,</li>
2498<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2499<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2500<li>a type error will be raised if:
2501<ul>
2502
2503<li>the first argument is any other non-string value</li>
2504</ul>
2505</li>
2506</ul>
2507</li>
2508<li>
2509
2510<p>Example:</p>
2511
2512<div>
2513<div>
2514<pre class="source">reverse(&quot;hello&quot;);
2515</pre></div></div>
2516</li>
2517<li>
2518
2519<p>The expected result is:</p>
2520
2521<div>
2522<div>
2523<pre class="source">&quot;olleh&quot;
2524</pre></div></div>
2525</li>
2526<li>
2527
2528<p>Example of multi-code-point character (Korean):</p>
2529
2530<div>
2531<div>
2532<pre class="source">reverse(&quot;&#x1112;&#x1161;&#x11ab;&#x1100;&#x1173;&#x11af;&quot;);
2533</pre></div></div>
2534</li>
2535<li>
2536
2537<p>The expected result is (the Korean characters are splitted into code points and then the code points are reversed):</p>
2538
2539<div>
2540<div>
2541<pre class="source">&quot;&#x11af;&#x1173;&#x1100;&#x11ab;&#x1161;&#x1112;&quot;
2542</pre></div></div>
2543</li>
2544</ul></div>
2545<div class="section">
2546<h3><a name="rtrim"></a>rtrim</h3>
2547<ul>
2548
2549<li>
2550
2551<p>Syntax:</p>
2552
2553<div>
2554<div>
2555<pre class="source">rtrim(string[, chars]);
2556</pre></div></div>
2557</li>
2558<li>
2559
2560<p>Returns a new string with all trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2561</li>
2562<li>Arguments:
2563<ul>
2564
2565<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2566<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2567</ul>
2568</li>
2569<li>Return Value:
2570<ul>
2571
2572<li>a trimmed, new <tt>string</tt>,</li>
2573<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2574<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2575<li>any other non-string input value will cause a type error.</li>
2576</ul>
2577</li>
2578<li>Related functions: see <tt>trim()</tt>, <tt>ltrim()</tt></li>
2579<li>
2580
2581<p>Example:</p>
2582
2583<div>
2584<div>
2585<pre class="source">{
2586 &quot;v1&quot;: rtrim(&quot;i like x-phone&quot;, &quot;x-phone&quot;),
2587 &quot;v2&quot;: rtrim(&quot;i like x-phone&quot;, &quot;onexph&quot;)
2588};
2589</pre></div></div>
2590</li>
2591<li>
2592
2593<p>The expected result is:</p>
2594
2595<div>
2596<div>
2597<pre class="source">{ &quot;v1&quot;: &quot;i like &quot;, &quot;v2&quot;: &quot;i like x-&quot; }
2598</pre></div></div>
2599</li>
2600<li>
2601
2602<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2603
2604<div>
2605<div>
2606<pre class="source">rtrim(&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&quot;, &quot;&#x1f468;&#x200d;&#x1f466;&quot;)
2607</pre></div></div>
2608</li>
2609<li>
2610
2611<p>The expected result is (only man, woman and girl are left in the family):</p>
2612
2613<div>
2614<div>
2615<pre class="source">&quot;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&quot;
2616</pre></div></div>
2617</li>
2618</ul></div>
2619<div class="section">
2620<h3><a name="split"></a>split</h3>
2621<ul>
2622
2623<li>
2624
2625<p>Syntax:</p>
2626
2627<div>
2628<div>
2629<pre class="source">split(string, sep)
2630</pre></div></div>
2631</li>
2632<li>
2633
2634<p>Splits the input <tt>string</tt> into an array of substrings separated by the string <tt>sep</tt>.</p>
2635</li>
2636<li>Arguments:
2637<ul>
2638
2639<li><tt>string</tt> : a <tt>string</tt> to be split.</li>
2640</ul>
2641</li>
2642<li>Return Value:
2643<ul>
2644
2645<li>an array of substrings by splitting the input <tt>string</tt> by <tt>sep</tt>,</li>
2646<li>in case of two consecutive <tt>sep</tt>s in the <tt>string</tt>, the result of splitting the two consecutive <tt>sep</tt>s will be the empty string <tt>&quot;&quot;</tt>,</li>
2647<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2648<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2649<li>any other non-string input value will cause a type error.</li>
2650</ul>
2651</li>
2652<li>
2653
2654<p>Example:</p>
2655
2656<div>
2657<div>
2658<pre class="source">split(&quot;test driven development&quot;, &quot; &quot;);
2659</pre></div></div>
2660</li>
2661<li>
2662
2663<p>The expected result is:</p>
2664
2665<div>
2666<div>
2667<pre class="source">[ &quot;test&quot;, &quot;driven&quot;, &quot;development&quot; ]
2668</pre></div></div>
2669</li>
2670<li>
2671
2672<p>Example with two consecutive <tt>sep</tt>s in the <tt>string</tt>:</p>
2673
2674<div>
2675<div>
2676<pre class="source">split(&quot;123//456&quot;, &quot;/&quot;);
2677</pre></div></div>
2678</li>
2679<li>
2680
2681<p>The expected result is:</p>
2682
2683<div>
2684<div>
2685<pre class="source">[ &quot;123&quot;, &quot;&quot;, &quot;456&quot; ]
2686</pre></div></div>
2687</li>
2688</ul></div>
2689<div class="section">
2690<h3><a name="starts_with"></a>starts_with</h3>
2691<ul>
2692
2693<li>
2694
2695<p>Syntax:</p>
2696
2697<div>
2698<div>
2699<pre class="source">starts_with(string, substring_to_start_with)
2700</pre></div></div>
2701</li>
2702<li>
2703
2704<p>Checks whether the string <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>.</p>
2705</li>
2706<li>Arguments:
2707<ul>
2708
2709<li><tt>string</tt> : a <tt>string</tt> that might start with the given string.</li>
2710<li><tt>substring_to_start_with</tt> : a <tt>string</tt> that might be contained as the starting substring.</li>
2711</ul>
2712</li>
2713<li>Return Value:
2714<ul>
2715
2716<li>a <tt>boolean</tt>, returns <tt>true</tt> if <tt>string</tt> starts with the string <tt>substring_to_start_with</tt>,</li>
2717<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2718<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2719<li>any other non-string input value will cause a type error,</li>
2720<li><tt>false</tt> otherwise.</li>
2721</ul>
2722</li>
2723<li>
2724
2725<p>Example:</p>
2726
2727<div>
2728<div>
2729<pre class="source">{
2730 &quot;v1&quot; : starts_with(&quot; like the plan, amazing&quot;, &quot; like&quot;),
2731 &quot;v2&quot; : starts_with(&quot;I like the plan, amazing&quot;, &quot; like&quot;)
2732};
2733</pre></div></div>
2734</li>
2735<li>
2736
2737<p>The expected result is:</p>
2738
2739<div>
2740<div>
2741<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
2742</pre></div></div>
2743</li>
2744</ul></div>
2745<div class="section">
2746<h3><a name="substr"></a>substr</h3>
2747<ul>
2748
2749<li>
2750
2751<p>Syntax:</p>
2752
2753<div>
2754<div>
2755<pre class="source">substr(string, offset[, length])
2756</pre></div></div>
2757</li>
2758<li>
2759
2760<p>Returns the substring from the given string <tt>string</tt> based on the given start offset <tt>offset</tt> with the optional <tt>length</tt>. Note that both of the <tt>offset</tt> and <tt>length</tt> are in the unit of code point (e.g. the emoji family &#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466; has 7 code points). The function uses the 0-based position. Another version of the function uses the 1-based position. Below are the aliases for each version:</p>
2761</li>
2762<li>
2763
2764<p>Aliases:</p>
2765<ul>
2766
2767<li>0-Based: <tt>substring</tt>, <tt>substr</tt>, <tt>substring0</tt>, <tt>substr0</tt>.</li>
2768<li>1-Based: <tt>substring1</tt>, <tt>substr1</tt>.</li>
2769</ul>
2770</li>
2771<li>
2772
2773<p>Arguments:</p>
2774<ul>
2775
2776<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
2777<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>
2778<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>
2779</ul>
2780</li>
2781<li>Return Value:
2782<ul>
2783
2784<li>a <tt>string</tt> that represents the substring,</li>
2785<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2786<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>
2787<li>a <tt>null</tt> will be returned if:
2788<ul>
2789
2790<li>the first argument is any other non-string value.</li>
2791<li>the second argument is not a <tt>tinyint</tt>, <tt>smallint</tt>, <tt>integer</tt>, or <tt>bigint</tt>.</li>
2792<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>
2793</ul>
2794</li>
2795</ul>
2796</li>
2797<li>
2798
2799<p>Example:</p>
2800
2801<div>
2802<div>
2803<pre class="source">{ &quot;v1&quot;: substr(&quot;test string&quot;, 6, 3), &quot;v2&quot;: substr1(&quot;test string&quot;, 6, 3) };
2804</pre></div></div>
2805</li>
2806<li>
2807
2808<p>The expected result is:</p>
2809
2810<div>
2811<div>
2812<pre class="source">{ &quot;v1&quot;: &quot;tri&quot;, &quot;v2&quot;: &quot;str&quot; }
2813</pre></div></div>
2814</li>
2815</ul>
2816<p>The function has an alias <tt>substring</tt>.</p></div>
2817<div class="section">
2818<h3><a name="trim"></a>trim</h3>
2819<ul>
2820
2821<li>
2822
2823<p>Syntax:</p>
2824
2825<div>
2826<div>
2827<pre class="source">trim(string[, chars]);
2828</pre></div></div>
2829</li>
2830<li>
2831
2832<p>Returns a new string with all leading and trailing characters that appear in <tt>chars</tt> removed. By default, white space is the character to trim. Note that here one character means one code point. For example, the emoji 4-people-family notation &#x201c;&#x1f469;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d; contains 7 code points, and it is possible to trim a few code points (such as a 2-people-family &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;) from it. See the following example for more details.</p>
2833</li>
2834<li>Arguments:
2835<ul>
2836
2837<li><tt>string</tt> : a <tt>string</tt> to be trimmed,</li>
2838<li><tt>chars</tt> : a <tt>string</tt> that contains characters that are used to trim.</li>
2839</ul>
2840</li>
2841<li>Return Value:
2842<ul>
2843
2844<li>a trimmed, new <tt>string</tt>,</li>
2845<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
2846<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2847<li>any other non-string input value will cause a type error.</li>
2848</ul>
2849</li>
2850<li>Related functions: see <tt>ltrim()</tt>, <tt>rtrim()</tt></li>
2851<li>
2852
2853<p>Example:</p>
2854
2855<div>
2856<div>
2857<pre class="source">trim(&quot;i like x-phone&quot;, &quot;xphoen&quot;);
2858</pre></div></div>
2859</li>
2860<li>
2861
2862<p>The expected result is:</p>
2863
2864<div>
2865<div>
2866<pre class="source">&quot; like &quot;
2867</pre></div></div>
2868</li>
2869<li>
2870
2871<p>Example with multi-codepoint notation (trim the man and boy from the family of man, woman, girl and boy):</p>
2872<p>trim(&#x201c;&#x1f468;&#x200d;&#x1f469;&#x200d;&#x1f467;&#x200d;&#x1f466;&#x201d;, &#x201c;&#x1f468;&#x200d;&#x1f466;&#x201d;)</p>
2873</li>
2874<li>
2875
2876<p>The expected result is (only woman and girl are left in the family):</p>
2877
2878<div>
2879<div>
2880<pre class="source"> &quot;&#x1f469;&#x200d;&#x1f467;&quot;
2881</pre></div></div>
2882</li>
2883</ul></div>
2884<div class="section">
2885<h3><a name="upper"></a>upper</h3>
2886<ul>
2887
2888<li>
2889
2890<p>Syntax:</p>
2891
2892<div>
2893<div>
2894<pre class="source">upper(string)
2895</pre></div></div>
2896</li>
2897<li>
2898
2899<p>Converts a given string <tt>string</tt> to its uppercase form.</p>
2900</li>
2901<li>Arguments:
2902<ul>
2903
2904<li><tt>string</tt> : a <tt>string</tt> to be converted.</li>
2905</ul>
2906</li>
2907<li>Return Value:
2908<ul>
2909
2910<li>a <tt>string</tt> as the uppercase form of the given <tt>string</tt>,</li>
2911<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2912<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
2913<li>any other non-string input value will cause a type error.</li>
2914</ul>
2915</li>
2916<li>
2917
2918<p>Example:</p>
2919
2920<div>
2921<div>
2922<pre class="source">upper(&quot;hello&quot;)
2923</pre></div></div>
2924</li>
2925<li>
2926
2927<p>The expected result is:</p>
2928
2929<div>
2930<div>
2931<pre class="source">&quot;HELLO&quot;
2932</pre></div></div>
2933</li>
2934</ul><!--
2935 ! Licensed to the Apache Software Foundation (ASF) under one
2936 ! or more contributor license agreements. See the NOTICE file
2937 ! distributed with this work for additional information
2938 ! regarding copyright ownership. The ASF licenses this file
2939 ! to you under the Apache License, Version 2.0 (the
2940 ! "License"); you may not use this file except in compliance
2941 ! with the License. You may obtain a copy of the License at
2942 !
2943 ! http://www.apache.org/licenses/LICENSE-2.0
2944 !
2945 ! Unless required by applicable law or agreed to in writing,
2946 ! software distributed under the License is distributed on an
2947 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2948 ! KIND, either express or implied. See the License for the
2949 ! specific language governing permissions and limitations
2950 ! under the License.
2951 !-->
2952</div>
2953<div class="section">
2954<h3><a name="string_concat"></a>string_concat</h3>
2955<ul>
2956
2957<li>
2958
2959<p>Syntax:</p>
2960
2961<div>
2962<div>
2963<pre class="source">string_concat(array)
2964</pre></div></div>
2965</li>
2966<li>
2967
2968<p>Concatenates an array of strings <tt>array</tt> into a single string.</p>
2969</li>
2970<li>Arguments:
2971<ul>
2972
2973<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>
2974</ul>
2975</li>
2976<li>Return Value:
2977<ul>
2978
2979<li>the concatenated <tt>string</tt> value,</li>
2980<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
2981<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
2982<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
2983<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>
2984<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
2985</ul>
2986</li>
2987<li>
2988
2989<p>Example:</p>
2990
2991<div>
2992<div>
2993<pre class="source">string_concat([&quot;ASTERIX&quot;, &quot; &quot;, &quot;ROCKS!&quot;]);
2994</pre></div></div>
2995</li>
2996<li>
2997
2998<p>The expected result is:</p>
2999
3000<div>
3001<div>
3002<pre class="source">&quot;ASTERIX ROCKS!&quot;
3003</pre></div></div>
3004</li>
3005</ul></div>
3006<div class="section">
3007<h3><a name="string_join"></a>string_join</h3>
3008<ul>
3009
3010<li>
3011
3012<p>Syntax:</p>
3013
3014<div>
3015<div>
3016<pre class="source">string_join(array, string)
3017</pre></div></div>
3018</li>
3019<li>
3020
3021<p>Joins an array or multiset of strings <tt>array</tt> with the given separator <tt>string</tt> into a single string.</p>
3022</li>
3023<li>Arguments:
3024<ul>
3025
3026<li><tt>array</tt> : an <tt>array</tt> or <tt>multiset</tt> of strings (could be <tt>null</tt>) to be joined.</li>
3027<li><tt>string</tt> : a <tt>string</tt> to serve as the separator.</li>
3028</ul>
3029</li>
3030<li>Return Value:
3031<ul>
3032
3033<li>the joined <tt>string</tt>,</li>
3034<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3035<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3036<li><tt>missing</tt> if the first argument array contains a <tt>missing</tt>,</li>
3037<li><tt>null</tt> if the first argument array contains a <tt>null</tt> but does not contain a <tt>missing</tt>,</li>
3038<li>a type error will be raised if:
3039<ul>
3040
3041<li>the first argument is any other non-array value, or contains any other non-string value,</li>
3042<li>or, the second argument is any other non-string value.</li>
3043</ul>
3044</li>
3045</ul>
3046</li>
3047<li>
3048
3049<p>Example:</p>
3050
3051<div>
3052<div>
3053<pre class="source">string_join([&quot;ASTERIX&quot;, &quot;ROCKS~&quot;], &quot;!! &quot;);
3054</pre></div></div>
3055</li>
3056<li>
3057
3058<p>The expected result is:</p>
3059
3060<div>
3061<div>
3062<pre class="source">&quot;ASTERIX!! ROCKS~&quot;
3063</pre></div></div>
3064</li>
3065</ul></div>
3066<div class="section">
3067<h3><a name="string_to_codepoint"></a>string_to_codepoint</h3>
3068<ul>
3069
3070<li>
3071
3072<p>Syntax:</p>
3073
3074<div>
3075<div>
3076<pre class="source">string_to_codepoint(string)
3077</pre></div></div>
3078</li>
3079<li>
3080
3081<p>Converts the string <tt>string</tt> to its code_based representation.</p>
3082</li>
3083<li>Arguments:
3084<ul>
3085
3086<li><tt>string</tt> : a <tt>string</tt> that will be converted.</li>
3087</ul>
3088</li>
3089<li>Return Value:
3090<ul>
3091
3092<li>an <tt>array</tt> of the code points for the string <tt>string</tt>,</li>
3093<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3094<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3095<li>any other non-string input value will cause a type error.</li>
3096</ul>
3097</li>
3098<li>
3099
3100<p>Example:</p>
3101
3102<div>
3103<div>
3104<pre class="source">string_to_codepoint(&quot;Hello ASTERIX!&quot;);
3105</pre></div></div>
3106</li>
3107<li>
3108
3109<p>The expected result is:</p>
3110
3111<div>
3112<div>
3113<pre class="source">[ 72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33 ]
3114</pre></div></div>
3115</li>
3116</ul></div>
3117<div class="section">
3118<h3><a name="codepoint_to_string"></a>codepoint_to_string</h3>
3119<ul>
3120
3121<li>
3122
3123<p>Syntax:</p>
3124
3125<div>
3126<div>
3127<pre class="source">codepoint_to_string(array)
3128</pre></div></div>
3129</li>
3130<li>
3131
3132<p>Converts the ordered code_based representation <tt>array</tt> to the corresponding string.</p>
3133</li>
3134<li>Arguments:
3135<ul>
3136
3137<li><tt>array</tt> : an <tt>array</tt> of integer code_points.</li>
3138</ul>
3139</li>
3140<li>Return Value:
3141<ul>
3142
3143<li>a <tt>string</tt> representation of <tt>array</tt>.</li>
3144<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3145<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3146<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3147<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>
3148<li>any other non-array input value or non-integer element in the input array will cause a type error.</li>
3149</ul>
3150</li>
3151<li>
3152
3153<p>Example:</p>
3154
3155<div>
3156<div>
3157<pre class="source">codepoint_to_string([72, 101, 108, 108, 111, 32, 65, 83, 84, 69, 82, 73, 88, 33]);
3158</pre></div></div>
3159</li>
3160<li>
3161
3162<p>The expected result is:</p>
3163
3164<div>
3165<div>
3166<pre class="source">&quot;Hello ASTERIX!&quot;
3167</pre></div></div>
3168</li>
3169</ul></div>
3170<div class="section">
3171<h3><a name="substring_before"></a>substring_before</h3>
3172<ul>
3173
3174<li>
3175
3176<p>Syntax:</p>
3177
3178<div>
3179<div>
3180<pre class="source">substring_before(string, string_pattern)
3181</pre></div></div>
3182</li>
3183<li>
3184
3185<p>Returns the substring from the given string <tt>string</tt> before the given pattern <tt>string_pattern</tt>.</p>
3186</li>
3187<li>Arguments:
3188<ul>
3189
3190<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3191<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3192</ul>
3193</li>
3194<li>Return Value:
3195<ul>
3196
3197<li>a <tt>string</tt> that represents the substring,</li>
3198<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3199<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3200<li>any other non-string input value will cause a type error.</li>
3201</ul>
3202</li>
3203<li>
3204
3205<p>Example:</p>
3206
3207<div>
3208<div>
3209<pre class="source">substring_before(&quot; like x-phone&quot;, &quot;x-phone&quot;);
3210</pre></div></div>
3211</li>
3212<li>
3213
3214<p>The expected result is:</p>
3215
3216<div>
3217<div>
3218<pre class="source">&quot; like &quot;
3219</pre></div></div>
3220</li>
3221</ul></div>
3222<div class="section">
3223<h3><a name="substring_after"></a>substring_after</h3>
3224<ul>
3225
3226<li>
3227
3228<p>Syntax:</p>
3229<p>substring_after(string, string_pattern);</p>
3230</li>
3231<li>
3232
3233<p>Returns the substring from the given string <tt>string</tt> after the given pattern <tt>string_pattern</tt>.</p>
3234</li>
3235<li>Arguments:
3236<ul>
3237
3238<li><tt>string</tt> : a <tt>string</tt> to be extracted.</li>
3239<li><tt>string_pattern</tt> : a <tt>string</tt> pattern to be searched.</li>
3240</ul>
3241</li>
3242<li>Return Value:
3243<ul>
3244
3245<li>a <tt>string</tt> that represents the substring,</li>
3246<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3247<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3248<li>any other non-string input value will cause a type error.</li>
3249</ul>
3250</li>
3251<li>
3252
3253<p>Example:</p>
3254
3255<div>
3256<div>
3257<pre class="source">substring_after(&quot; like x-phone&quot;, &quot;xph&quot;);
3258</pre></div></div>
3259</li>
3260<li>
3261
3262<p>The expected result is:</p>
3263
3264<div>
3265<div>
3266<pre class="source">&quot;one&quot;
3267</pre></div></div>
3268</li>
3269</ul><!--
3270 ! Licensed to the Apache Software Foundation (ASF) under one
3271 ! or more contributor license agreements. See the NOTICE file
3272 ! distributed with this work for additional information
3273 ! regarding copyright ownership. The ASF licenses this file
3274 ! to you under the Apache License, Version 2.0 (the
3275 ! "License"); you may not use this file except in compliance
3276 ! with the License. You may obtain a copy of the License at
3277 !
3278 ! http://www.apache.org/licenses/LICENSE-2.0
3279 !
3280 ! Unless required by applicable law or agreed to in writing,
3281 ! software distributed under the License is distributed on an
3282 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3283 ! KIND, either express or implied. See the License for the
3284 ! specific language governing permissions and limitations
3285 ! under the License.
3286 !-->
3287</div></div>
3288<div class="section">
3289<h2><a name="Binary_Functions"></a><a name="BinaryFunctions" id="BinaryFunctions">Binary Functions</a></h2>
3290<div class="section">
3291<h3><a name="parse_binary"></a>parse_binary</h3>
3292<ul>
3293
3294<li>
3295
3296<p>Syntax:</p>
3297<p>parse_binary(string, encoding)</p>
3298</li>
3299<li>
3300
3301<p>Creates a <tt>binary</tt> from an string encoded in <tt>encoding</tt> format.</p>
3302</li>
3303<li>Arguments:
3304<ul>
3305
3306<li><tt>string</tt> : an encoded <tt>string</tt>,</li>
3307<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>
3308</ul>
3309</li>
3310<li>Return Value:
3311<ul>
3312
3313<li>a <tt>binary</tt> that is decoded from the given <tt>string</tt>,</li>
3314<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3315<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3316<li>any other non-string input value will cause a type error.</li>
3317</ul>
3318</li>
3319<li>
3320
3321<p>Example:</p>
3322<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>
3323</li>
3324<li>
3325
3326<p>The expected result is:</p>
3327<p>[ hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;ABCDEF0123456789&#x201d;), hex(&#x201c;4173746572697801&#x201d;) ]</p>
3328</li>
3329</ul></div>
3330<div class="section">
3331<h3><a name="print_binary"></a>print_binary</h3>
3332<ul>
3333
3334<li>
3335
3336<p>Syntax:</p>
3337<p>print_binary(binary, encoding)</p>
3338</li>
3339<li>
3340
3341<p>Prints a <tt>binary</tt> to the required encoding <tt>string</tt> format.</p>
3342</li>
3343<li>Arguments:
3344<ul>
3345
3346<li><tt>binary</tt> : a <tt>binary</tt> data need to be printed.</li>
3347<li><tt>encoding</tt> : a string notation specifies the expected encoding type. Currently we support <tt>hex</tt> and <tt>base64</tt> format.</li>
3348</ul>
3349</li>
3350<li>Return Value:
3351<ul>
3352
3353<li>a <tt>string</tt> that represents the encoded format of a <tt>binary</tt>,</li>
3354<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3355<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3356<li>any other non-string input value will cause a type error.</li>
3357</ul>
3358</li>
3359<li>
3360
3361<p>Example:</p>
3362
3363<div>
3364<div>
3365<pre class="source">[ print_binary(hex(&quot;ABCDEF0123456789&quot;), &quot;base64&quot;), print_binary(base64(&quot;q83vASNFZ4k=&quot;), &quot;hex&quot;) ]
3366</pre></div></div>
3367</li>
3368<li>
3369
3370<p>The expected result are:</p>
3371
3372<div>
3373<div>
3374<pre class="source">[ &quot;q83vASNFZ4k=&quot;, &quot;ABCDEF0123456789&quot; ]
3375</pre></div></div>
3376</li>
3377</ul></div>
3378<div class="section">
3379<h3><a name="binary_length"></a>binary_length</h3>
3380<ul>
3381
3382<li>
3383
3384<p>Syntax:</p>
3385<p>binary_length(binary)</p>
3386</li>
3387<li>
3388
3389<p>Returns the number of bytes storing the binary data.</p>
3390</li>
3391<li>Arguments:
3392<ul>
3393
3394<li><tt>binary</tt> : a <tt>binary</tt> value to be checked.</li>
3395</ul>
3396</li>
3397<li>Return Value:
3398<ul>
3399
3400<li>an <tt>bigint</tt> that represents the number of bytes,</li>
3401<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3402<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3403<li>any other non-binary input value will cause a type error.</li>
3404</ul>
3405</li>
3406<li>
3407
3408<p>Example:</p>
3409
3410<div>
3411<div>
3412<pre class="source">binary_length(hex(&quot;00AA&quot;))
3413</pre></div></div>
3414</li>
3415<li>
3416
3417<p>The expected result is:</p>
3418<p>2</p>
3419</li>
3420</ul></div>
3421<div class="section">
3422<h3><a name="sub_binary"></a>sub_binary</h3>
3423<ul>
3424
3425<li>
3426
3427<p>Syntax:</p>
3428<p>sub_binary(binary, offset[, length])</p>
3429</li>
3430<li>
3431
3432<p>Returns the sub binary from the given <tt>binary</tt> based on the given start offset with the optional <tt>length</tt>.</p>
3433</li>
3434<li>Arguments:
3435<ul>
3436
3437<li><tt>binary</tt> : a <tt>binary</tt> to be extracted,</li>
3438<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>
3439<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>
3440</ul>
3441</li>
3442<li>Return Value:
3443<ul>
3444
3445<li>a <tt>binary</tt> that represents the sub binary,</li>
3446<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3447<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3448<li>a type error will be raised if:
3449<ul>
3450
3451<li>the first argument is any other non-binary value,</li>
3452<li>or, the second argument is any other non-integer value,</li>
3453<li>or, the third argument is any other non-integer value, if it is present.</li>
3454</ul>
3455</li>
3456</ul>
3457</li>
3458<li>
3459
3460<p>Example:</p>
3461
3462<div>
3463<div>
3464<pre class="source">sub_binary(hex(&quot;AABBCCDD&quot;), 4);
3465</pre></div></div>
3466</li>
3467<li>
3468
3469<p>The expected result is</p>
3470
3471<div>
3472<div>
3473<pre class="source">hex(&quot;DD&quot;)
3474</pre></div></div>
3475</li>
3476</ul></div>
3477<div class="section">
3478<h3><a name="binary_concat"></a>binary_concat</h3>
3479<ul>
3480
3481<li>
3482
3483<p>Syntax:</p>
3484<p>binary_concat(array)</p>
3485</li>
3486<li>
3487
3488<p>Concatenates a binary <tt>array</tt> or <tt>multiset</tt> into a single binary.</p>
3489</li>
3490<li>Arguments:
3491<ul>
3492
3493<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>
3494</ul>
3495</li>
3496<li>Return Value :
3497<ul>
3498
3499<li>the concatenated <tt>binary</tt> value,</li>
3500<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3501<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3502<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3503<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>
3504<li>any other non-array input value or non-binary element in the input array will cause a type error.</li>
3505</ul>
3506</li>
3507<li>
3508
3509<p>Example:</p>
3510<p>binary_concat([hex(&#x201c;42&#x201d;), hex(&quot;&quot;), hex(&#x2018;42&#x2019;)]);</p>
3511</li>
3512<li>
3513
3514<p>The expected result is</p>
3515<p>hex(&#x201c;4242&#x201d;)</p>
3516</li>
3517</ul><!--
3518 ! Licensed to the Apache Software Foundation (ASF) under one
3519 ! or more contributor license agreements. See the NOTICE file
3520 ! distributed with this work for additional information
3521 ! regarding copyright ownership. The ASF licenses this file
3522 ! to you under the Apache License, Version 2.0 (the
3523 ! "License"); you may not use this file except in compliance
3524 ! with the License. You may obtain a copy of the License at
3525 !
3526 ! http://www.apache.org/licenses/LICENSE-2.0
3527 !
3528 ! Unless required by applicable law or agreed to in writing,
3529 ! software distributed under the License is distributed on an
3530 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3531 ! KIND, either express or implied. See the License for the
3532 ! specific language governing permissions and limitations
3533 ! under the License.
3534 !-->
3535</div></div>
3536<div class="section">
3537<h2><a name="Spatial_Functions"></a><a name="SpatialFunctions" id="SpatialFunctions">Spatial Functions</a></h2>
3538<div class="section">
3539<h3><a name="create_point"></a>create_point</h3>
3540<ul>
3541
3542<li>
3543
3544<p>Syntax:</p>
3545
3546<div>
3547<div>
3548<pre class="source">create_point(x, y)
3549</pre></div></div>
3550</li>
3551<li>
3552
3553<p>Creates the primitive type <tt>point</tt> using an <tt>x</tt> and <tt>y</tt> value.</p>
3554</li>
3555<li>Arguments:</li>
3556<li><tt>x</tt> : a <tt>double</tt> that represents the x-coordinate,</li>
3557<li><tt>y</tt> : a <tt>double</tt> that represents the y-coordinate.</li>
3558<li>Return Value:</li>
3559<li>a <tt>point</tt> representing the ordered pair (<tt>x</tt>, <tt>y</tt>),</li>
3560<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3561<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3562<li>any other non-double input value will cause a type error.</li>
3563<li>
3564
3565<p>Example:</p>
3566
3567<div>
3568<div>
3569<pre class="source">{ &quot;point&quot;: create_point(30.0,70.0) };
3570</pre></div></div>
3571</li>
3572<li>
3573
3574<p>The expected result is:</p>
3575
3576<div>
3577<div>
3578<pre class="source">{ &quot;point&quot;: point(&quot;30.0,70.0&quot;) }
3579</pre></div></div>
3580</li>
3581</ul></div>
3582<div class="section">
3583<h3><a name="create_line"></a>create_line</h3>
3584<ul>
3585
3586<li>
3587
3588<p>Syntax:</p>
3589
3590<div>
3591<div>
3592<pre class="source">create_line(point1, point2)
3593</pre></div></div>
3594</li>
3595<li>
3596
3597<p>Creates the primitive type <tt>line</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3598</li>
3599<li>Arguments:
3600<ul>
3601
3602<li><tt>point1</tt> : a <tt>point</tt> that represents the start point of the line.</li>
3603<li><tt>point2</tt> : a <tt>point</tt> that represents the end point of the line.</li>
3604</ul>
3605</li>
3606<li>Return Value:
3607<ul>
3608
3609<li>a spatial <tt>line</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3610<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3611<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3612<li>any other non-point input value will cause a type error.</li>
3613</ul>
3614</li>
3615<li>
3616
3617<p>Example:</p>
3618
3619<div>
3620<div>
3621<pre class="source">{ &quot;line&quot;: create_line(create_point(30.0,70.0), create_point(50.0,90.0)) };
3622</pre></div></div>
3623</li>
3624<li>
3625
3626<p>The expected result is:</p>
3627
3628<div>
3629<div>
3630<pre class="source">{ &quot;line&quot;: line(&quot;30.0,70.0 50.0,90.0&quot;) }
3631</pre></div></div>
3632</li>
3633</ul></div>
3634<div class="section">
3635<h3><a name="create_rectangle"></a>create_rectangle</h3>
3636<ul>
3637
3638<li>
3639
3640<p>Syntax:</p>
3641
3642<div>
3643<div>
3644<pre class="source">create_rectangle(point1, point2)
3645</pre></div></div>
3646</li>
3647<li>
3648
3649<p>Creates the primitive type <tt>rectangle</tt> using <tt>point1</tt> and <tt>point2</tt>.</p>
3650</li>
3651<li>Arguments:
3652<ul>
3653
3654<li><tt>point1</tt> : a <tt>point</tt> that represents the lower_left point of the rectangle.</li>
3655<li><tt>point2</tt> : a <tt>point</tt> that represents the upper_right point of the rectangle.</li>
3656</ul>
3657</li>
3658<li>Return Value:
3659<ul>
3660
3661<li>a spatial <tt>rectangle</tt> created using the points provided in <tt>point1</tt> and <tt>point2</tt>,</li>
3662<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3663<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3664<li>any other non-point input value will cause a type error.</li>
3665</ul>
3666</li>
3667<li>
3668
3669<p>Example:</p>
3670
3671<div>
3672<div>
3673<pre class="source">{ &quot;rectangle&quot;: create_rectangle(create_point(30.0,70.0), create_point(50.0,90.0)) };
3674</pre></div></div>
3675</li>
3676<li>
3677
3678<p>The expected result is:</p>
3679
3680<div>
3681<div>
3682<pre class="source">{ &quot;rectangle&quot;: rectangle(&quot;30.0,70.0 50.0,90.0&quot;) }
3683</pre></div></div>
3684</li>
3685</ul></div>
3686<div class="section">
3687<h3><a name="create_circle"></a>create_circle</h3>
3688<ul>
3689
3690<li>
3691
3692<p>Syntax:</p>
3693
3694<div>
3695<div>
3696<pre class="source">create_circle(point, radius)
3697</pre></div></div>
3698</li>
3699<li>
3700
3701<p>Creates the primitive type <tt>circle</tt> using <tt>point</tt> and <tt>radius</tt>.</p>
3702</li>
3703<li>Arguments:
3704<ul>
3705
3706<li><tt>point</tt> : a <tt>point</tt> that represents the center of the circle.</li>
3707<li><tt>radius</tt> : a <tt>double</tt> that represents the radius of the circle.</li>
3708</ul>
3709</li>
3710<li>Return Value:
3711<ul>
3712
3713<li>a spatial <tt>circle</tt> created using the center point and the radius provided in <tt>point</tt> and <tt>radius</tt>.</li>
3714<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3715<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3716<li>a type error will be raised if:
3717<ul>
3718
3719<li>the first argument is any other non-point value,</li>
3720<li>or, the second argument is any other non-double value.</li>
3721</ul>
3722</li>
3723</ul>
3724</li>
3725<li>
3726
3727<p>Example:</p>
3728
3729<div>
3730<div>
3731<pre class="source">{ &quot;circle&quot;: create_circle(create_point(30.0,70.0), 5.0) }
3732</pre></div></div>
3733</li>
3734<li>
3735
3736<p>The expected result is:</p>
3737
3738<div>
3739<div>
3740<pre class="source">{ &quot;circle&quot;: circle(&quot;30.0,70.0 5.0&quot;) }
3741</pre></div></div>
3742</li>
3743</ul></div>
3744<div class="section">
3745<h3><a name="create_polygon"></a>create_polygon</h3>
3746<ul>
3747
3748<li>
3749
3750<p>Syntax:</p>
3751
3752<div>
3753<div>
3754<pre class="source">create_polygon(array)
3755</pre></div></div>
3756</li>
3757<li>
3758
3759<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>
3760</li>
3761<li>Arguments:
3762<ul>
3763
3764<li><tt>array</tt> : an array of doubles representing the points of the polygon.</li>
3765</ul>
3766</li>
3767<li>Return Value:
3768<ul>
3769
3770<li>a <tt>polygon</tt>, represents a spatial simple polygon created using the points provided in <tt>array</tt>.</li>
3771<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3772<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3773<li><tt>missing</tt> if any element in the input array is <tt>missing</tt>,</li>
3774<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>
3775<li>any other non-array input value or non-double element in the input array will cause a type error.</li>
3776</ul>
3777</li>
3778<li>
3779
3780<p>Example:</p>
3781
3782<div>
3783<div>
3784<pre class="source">{ &quot;polygon&quot;: create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]) };
3785</pre></div></div>
3786</li>
3787<li>
3788
3789<p>The expected result is:</p>
3790
3791<div>
3792<div>
3793<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;) }
3794</pre></div></div>
3795</li>
3796</ul></div>
3797<div class="section">
3798<h3><a name="get_x.2Fget_y"></a>get_x/get_y</h3>
3799<ul>
3800
3801<li>
3802
3803<p>Syntax:</p>
3804
3805<div>
3806<div>
3807<pre class="source">get_x(point) or get_y(point)
3808</pre></div></div>
3809</li>
3810<li>
3811
3812<p>Returns the x or y coordinates of a point <tt>point</tt>.</p>
3813</li>
3814<li>Arguments:
3815<ul>
3816
3817<li><tt>point</tt> : a <tt>point</tt>.</li>
3818</ul>
3819</li>
3820<li>Return Value:
3821<ul>
3822
3823<li>a <tt>double</tt> representing the x or y coordinates of the point <tt>point</tt>,</li>
3824<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3825<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3826<li>any other non-point input value will cause a type error.</li>
3827</ul>
3828</li>
3829<li>
3830
3831<p>Example:</p>
3832
3833<div>
3834<div>
3835<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)) };
3836</pre></div></div>
3837</li>
3838<li>
3839
3840<p>The expected result is:</p>
3841
3842<div>
3843<div>
3844<pre class="source">{ &quot;x_coordinate&quot;: 2.3, &quot;y_coordinate&quot;: 5.0 }
3845</pre></div></div>
3846</li>
3847</ul></div>
3848<div class="section">
3849<h3><a name="get_points"></a>get_points</h3>
3850<ul>
3851
3852<li>
3853
3854<p>Syntax:</p>
3855
3856<div>
3857<div>
3858<pre class="source">get_points(spatial_object)
3859</pre></div></div>
3860</li>
3861<li>
3862
3863<p>Returns an ordered array of the points forming the spatial object <tt>spatial_object</tt>.</p>
3864</li>
3865<li>Arguments:
3866<ul>
3867
3868<li><tt>spatial_object</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
3869</ul>
3870</li>
3871<li>Return Value:
3872<ul>
3873
3874<li>an <tt>array</tt> of the points forming the spatial object <tt>spatial_object</tt>,</li>
3875<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3876<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3877<li>any other non-spatial-object input value will cause a type error.</li>
3878</ul>
3879</li>
3880<li>
3881
3882<p>Example:</p>
3883
3884<div>
3885<div>
3886<pre class="source">get_points(create_polygon([1.0,1.0,2.0,2.0,3.0,3.0,4.0,4.0]))
3887</pre></div></div>
3888</li>
3889<li>
3890
3891<p>The expected result is:</p>
3892
3893<div>
3894<div>
3895<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;) ]
3896</pre></div></div>
3897</li>
3898</ul></div>
3899<div class="section">
3900<h3><a name="get_center.2Fget_radius"></a>get_center/get_radius</h3>
3901<ul>
3902
3903<li>
3904
3905<p>Syntax:</p>
3906
3907<div>
3908<div>
3909<pre class="source">get_center(circle_expression) or get_radius(circle_expression)
3910</pre></div></div>
3911</li>
3912<li>
3913
3914<p>Returns the center and the radius of a circle <tt>circle_expression</tt>, respectively.</p>
3915</li>
3916<li>Arguments:
3917<ul>
3918
3919<li><tt>circle_expression</tt> : a <tt>circle</tt>.</li>
3920</ul>
3921</li>
3922<li>Return Value:
3923<ul>
3924
3925<li>a <tt>point</tt> or <tt>double</tt>, represent the center or radius of the circle <tt>circle_expression</tt>.</li>
3926<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
3927<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
3928<li>any other non-circle input value will cause a type error.</li>
3929</ul>
3930</li>
3931<li>
3932
3933<p>Example:</p>
3934
3935<div>
3936<div>
3937<pre class="source">{
3938 &quot;circle_radius&quot;: get_radius(create_circle(create_point(6.0,3.0), 1.0)),
3939 &quot;circle_center&quot;: get_center(create_circle(create_point(6.0,3.0), 1.0))
3940};
3941</pre></div></div>
3942</li>
3943<li>
3944
3945<p>The expected result is:</p>
3946
3947<div>
3948<div>
3949<pre class="source">{ &quot;circle_radius&quot;: 1.0, &quot;circle_center&quot;: point(&quot;6.0,3.0&quot;) }
3950</pre></div></div>
3951</li>
3952</ul></div>
3953<div class="section">
3954<h3><a name="spatial_distance"></a>spatial_distance</h3>
3955<ul>
3956
3957<li>
3958
3959<p>Syntax:</p>
3960
3961<div>
3962<div>
3963<pre class="source">spatial_distance(point1, point2)
3964</pre></div></div>
3965</li>
3966<li>
3967
3968<p>Returns the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</p>
3969</li>
3970<li>Arguments:
3971<ul>
3972
3973<li><tt>point1</tt> : a <tt>point</tt>.</li>
3974<li><tt>point2</tt> : a <tt>point</tt>.</li>
3975</ul>
3976</li>
3977<li>Return Value:
3978<ul>
3979
3980<li>a <tt>double</tt> as the Euclidean distance between <tt>point1</tt> and <tt>point2</tt>.</li>
3981<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
3982<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
3983<li>any other non-point input value will cause a type error.</li>
3984</ul>
3985</li>
3986<li>
3987
3988<p>Example:</p>
3989
3990<div>
3991<div>
3992<pre class="source">spatial_distance(point(&quot;47.44,80.65&quot;), create_point(30.0,70.0));
3993</pre></div></div>
3994</li>
3995<li>
3996
3997<p>The expected result is:</p>
3998
3999<div>
4000<div>
4001<pre class="source">20.434678857275934
4002</pre></div></div>
4003</li>
4004</ul></div>
4005<div class="section">
4006<h3><a name="spatial_area"></a>spatial_area</h3>
4007<ul>
4008
4009<li>
4010
4011<p>Syntax:</p>
4012
4013<div>
4014<div>
4015<pre class="source">spatial_area(spatial_2d_expression)
4016</pre></div></div>
4017</li>
4018<li>
4019
4020<p>Returns the spatial area of <tt>spatial_2d_expression</tt>.</p>
4021</li>
4022<li>Arguments:
4023<ul>
4024
4025<li><tt>spatial_2d_expression</tt> : a <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4026</ul>
4027</li>
4028<li>Return Value:
4029<ul>
4030
4031<li>a <tt>double</tt> representing the area of <tt>spatial_2d_expression</tt>.</li>
4032<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4033<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4034<li>any other non-2d-spatial-object will cause a type error.</li>
4035</ul>
4036</li>
4037<li>
4038
4039<p>Example:</p>
4040
4041<div>
4042<div>
4043<pre class="source">spatial_area(create_circle(create_point(0.0,0.0), 5.0));
4044</pre></div></div>
4045</li>
4046<li>
4047
4048<p>The expected result is:</p>
4049
4050<div>
4051<div>
4052<pre class="source">78.53981625
4053</pre></div></div>
4054</li>
4055</ul></div>
4056<div class="section">
4057<h3><a name="spatial_intersect"></a>spatial_intersect</h3>
4058<ul>
4059
4060<li>
4061
4062<p>Syntax:</p>
4063
4064<div>
4065<div>
4066<pre class="source">spatial_intersect(spatial_object1, spatial_object2)
4067</pre></div></div>
4068</li>
4069<li>
4070
4071<p>Checks whether <tt>@arg1</tt> and <tt>@arg2</tt> spatially intersect each other.</p>
4072</li>
4073<li>Arguments:
4074<ul>
4075
4076<li><tt>spatial_object1</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4077<li><tt>spatial_object2</tt> : a <tt>point</tt>, <tt>line</tt>, <tt>rectangle</tt>, <tt>circle</tt>, or <tt>polygon</tt>.</li>
4078</ul>
4079</li>
4080<li>Return Value:
4081<ul>
4082
4083<li>a <tt>boolean</tt> representing whether <tt>spatial_object1</tt> and <tt>spatial_object2</tt> spatially overlap with each other,</li>
4084<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4085<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4086<li>any other non-spatial-object input value will cause a type error.</li>
4087</ul>
4088</li>
4089<li>
4090
4091<p>Example:</p>
4092
4093<div>
4094<div>
4095<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)));
4096</pre></div></div>
4097</li>
4098<li>
4099
4100<p>The expected result is:</p>
4101
4102<div>
4103<div>
4104<pre class="source">true
4105</pre></div></div>
4106</li>
4107</ul></div>
4108<div class="section">
4109<h3><a name="spatial_cell"></a>spatial_cell</h3>
4110<ul>
4111
4112<li>
4113
4114<p>Syntax:</p>
4115
4116<div>
4117<div>
4118<pre class="source">spatial_cell(point1, point2, x_increment, y_increment)
4119</pre></div></div>
4120</li>
4121<li>
4122
4123<p>Returns the grid cell that <tt>point1</tt> belongs to.</p>
4124</li>
4125<li>Arguments:
4126<ul>
4127
4128<li><tt>point1</tt> : a <tt>point</tt> representing the point of interest that its grid cell will be returned.</li>
4129<li><tt>point2</tt> : a <tt>point</tt> representing the origin of the grid.</li>
4130<li><tt>x_increment</tt> : a <tt>double</tt>, represents X increments.</li>
4131<li><tt>y_increment</tt> : a <tt>double</tt>, represents Y increments.</li>
4132</ul>
4133</li>
4134<li>Return Value:
4135<ul>
4136
4137<li>a <tt>rectangle</tt> representing the grid cell that <tt>point1</tt> belongs to,</li>
4138<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4139<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4140<li>a type error will be raised if:
4141<ul>
4142
4143<li>the first or second argument is any other non-point value,</li>
4144<li>or, the second or third argument is any other non-double value.</li>
4145</ul>
4146</li>
4147</ul>
4148</li>
4149<li>
4150
4151<p>Example:</p>
4152
4153<div>
4154<div>
4155<pre class="source">spatial_cell(point(&quot;39.28,70.48&quot;), create_point(20.0,50.0), 5.5, 6.0);
4156</pre></div></div>
4157</li>
4158<li>
4159
4160<p>The expected result is:</p>
4161
4162<div>
4163<div>
4164<pre class="source">rectangle(&quot;36.5,68.0 42.0,74.0&quot;);
4165</pre></div></div>
4166</li>
4167</ul><!--
4168 ! Licensed to the Apache Software Foundation (ASF) under one
4169 ! or more contributor license agreements. See the NOTICE file
4170 ! distributed with this work for additional information
4171 ! regarding copyright ownership. The ASF licenses this file
4172 ! to you under the Apache License, Version 2.0 (the
4173 ! "License"); you may not use this file except in compliance
4174 ! with the License. You may obtain a copy of the License at
4175 !
4176 ! http://www.apache.org/licenses/LICENSE-2.0
4177 !
4178 ! Unless required by applicable law or agreed to in writing,
4179 ! software distributed under the License is distributed on an
4180 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4181 ! KIND, either express or implied. See the License for the
4182 ! specific language governing permissions and limitations
4183 ! under the License.
4184 !-->
4185</div></div>
4186<div class="section">
4187<h2><a name="Similarity_Functions"></a><a name="SimilarityFunctions" id="SimilarityFunctions">Similarity Functions</a></h2>
4188<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>
4189<div class="section">
4190<h3><a name="edit_distance"></a>edit_distance</h3>
4191<ul>
4192
4193<li>
4194
4195<p>Syntax:</p>
4196
4197<div>
4198<div>
4199<pre class="source">edit_distance(expression1, expression2)
4200</pre></div></div>
4201</li>
4202<li>
4203
4204<p>Returns the edit distance of <tt>expression1</tt> and <tt>expression2</tt>.</p>
4205</li>
4206<li>Arguments:
4207<ul>
4208
4209<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4210<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4211</ul>
4212</li>
4213<li>Return Value:
4214<ul>
4215
4216<li>an <tt>bigint</tt> that represents the edit distance between <tt>expression1</tt> and <tt>expression2</tt>,</li>
4217<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4218<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4219<li>any other non-string input value will cause a type error.</li>
4220</ul>
4221</li>
4222<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4223<li>Example:
4224
4225<div>
4226<div>
4227<pre class="source">edit_distance(&quot;SuzannaTillson&quot;, &quot;Suzanna Tilson&quot;);
4228</pre></div></div>
4229</li>
4230<li>
4231
4232<p>The expected result is:</p>
4233
4234<div>
4235<div>
4236<pre class="source">2
4237</pre></div></div>
4238</li>
4239</ul></div>
4240<div class="section">
4241<h3><a name="edit_distance_check"></a>edit_distance_check</h3>
4242<ul>
4243
4244<li>
4245
4246<p>Syntax:</p>
4247
4248<div>
4249<div>
4250<pre class="source">edit_distance_check(expression1, expression2, threshold)
4251</pre></div></div>
4252</li>
4253<li>
4254
4255<p>Checks whether the edit distance of <tt>expression1</tt> and <tt>expression2</tt> is within a given threshold.</p>
4256</li>
4257<li>
4258
4259<p>Arguments:</p>
4260<ul>
4261
4262<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4263<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4264<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4265</ul>
4266</li>
4267<li>Return Value:
4268<ul>
4269
4270<li>an <tt>array</tt> with two items:
4271<ul>
4272
4273<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>
4274<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>
4275<li>If the first item is false, then the second item is set to 2147483647.</li>
4276</ul>
4277</li>
4278<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4279<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4280<li>a type error will be raised if:
4281<ul>
4282
4283<li>the first or second argument is any other non-string value,</li>
4284<li>or, the third argument is any other non-bigint value.</li>
4285</ul>
4286</li>
4287</ul>
4288</li>
4289<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4290<li>Example:
4291
4292<div>
4293<div>
4294<pre class="source">edit_distance_check(&quot;happy&quot;,&quot;hapr&quot;,2);
4295</pre></div></div>
4296</li>
4297<li>
4298
4299<p>The expected result is:</p>
4300
4301<div>
4302<div>
4303<pre class="source">[ true, 2 ]
4304</pre></div></div>
4305</li>
4306</ul></div>
4307<div class="section">
4308<h3><a name="edit_distance_contains"></a>edit_distance_contains</h3>
4309<ul>
4310
4311<li>
4312
4313<p>Syntax:</p>
4314
4315<div>
4316<div>
4317<pre class="source">edit_distance_contains(expression1, expression2, threshold)
4318</pre></div></div>
4319</li>
4320<li>
4321
4322<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>
4323</li>
4324<li>
4325
4326<p>Arguments:</p>
4327<ul>
4328
4329<li><tt>expression1</tt> : a <tt>string</tt> or a homogeneous <tt>array</tt> of a comparable item type.</li>
4330<li><tt>expression2</tt> : The same type as <tt>expression1</tt>.</li>
4331<li><tt>threshold</tt> : a <tt>bigint</tt> that represents the distance threshold.</li>
4332</ul>
4333</li>
4334<li>Return Value:
4335<ul>
4336
4337<li>an <tt>array</tt> with two items:
4338<ul>
4339
4340<li>The first item contains a <tt>boolean</tt> value representing whether <tt>expression1</tt> can contain <tt>expression2</tt>.</li>
4341<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>
4342</ul>
4343</li>
4344<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4345<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4346<li>a type error will be raised if:
4347<ul>
4348
4349<li>the first or second argument is any other non-string value,</li>
4350<li>or, the third argument is any other non-bigint value.</li>
4351</ul>
4352</li>
4353</ul>
4354</li>
4355<li>Note: an <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">n_gram index</a> can be utilized for this function.</li>
4356<li>Example:
4357
4358<div>
4359<div>
4360<pre class="source">edit_distance_contains(&quot;happy&quot;,&quot;hapr&quot;,2);
4361</pre></div></div>
4362</li>
4363<li>
4364
4365<p>The expected result is:</p>
4366
4367<div>
4368<div>
4369<pre class="source">[ true, 1 ]
4370</pre></div></div>
4371</li>
4372</ul></div>
4373<div class="section">
4374<h3><a name="similarity_jaccard"></a>similarity_jaccard</h3>
4375<ul>
4376
4377<li>
4378
4379<p>Syntax:</p>
4380
4381<div>
4382<div>
4383<pre class="source">similarity_jaccard(array1, array2)
4384</pre></div></div>
4385</li>
4386<li>
4387
4388<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>
4389</li>
4390<li>Arguments:
4391<ul>
4392
4393<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4394<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4395</ul>
4396</li>
4397<li>Return Value:
4398<ul>
4399
4400<li>a <tt>float</tt> that represents the Jaccard similarity of <tt>array1</tt> and <tt>array2</tt>,</li>
4401<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4402<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4403<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4404<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>
4405<li>any other non-array input value or non-integer element in any input array will cause a type error.</li>
4406</ul>
4407</li>
4408<li>
4409
4410<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4411</li>
4412<li>Example:
4413
4414<div>
4415<div>
4416<pre class="source">similarity_jaccard([1,5,8,9], [1,5,9,10]);
4417</pre></div></div>
4418</li>
4419<li>
4420
4421<p>The expected result is:</p>
4422
4423<div>
4424<div>
4425<pre class="source">0.6
4426</pre></div></div>
4427</li>
4428</ul></div>
4429<div class="section">
4430<h3><a name="similarity_jaccard_check"></a>similarity_jaccard_check</h3>
4431<ul>
4432
4433<li>
4434
4435<p>Syntax:</p>
4436
4437<div>
4438<div>
4439<pre class="source">similarity_jaccard_check(array1, array2, threshold)
4440</pre></div></div>
4441</li>
4442<li>
4443
4444<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>
4445</li>
4446<li>
4447
4448<p>Arguments:</p>
4449<ul>
4450
4451<li><tt>array1</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4452<li><tt>array2</tt> : an <tt>array</tt> or <tt>multiset</tt>.</li>
4453<li><tt>threshold</tt> : a <tt>double</tt> that represents the similarity threshold.</li>
4454</ul>
4455</li>
4456<li>Return Value:
4457<ul>
4458
4459<li>an <tt>array</tt> with two items:
4460<ul>
4461
4462<li>The first item contains a <tt>boolean</tt> value representing whether <tt>array1</tt> and <tt>array2</tt> are similar.</li>
4463<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>
4464</ul>
4465</li>
4466<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4467<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4468<li><tt>missing</tt> if any element in any input array is <tt>missing</tt>,</li>
4469<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>
4470<li>a type error will be raised if:
4471<ul>
4472
4473<li>the first or second argument is any other non-array value,
4474<ul>
4475
4476<li>or, the third argument is any other non-double value.</li>
4477</ul>
4478</li>
4479</ul>
4480</li>
4481</ul>
4482</li>
4483<li>
4484
4485<p>Note: a <a href="similarity.html#UsingIndexesToSupportSimilarityQueries">keyword index</a> can be utilized for this function.</p>
4486</li>
4487<li>Example:
4488
4489<div>
4490<div>
4491<pre class="source">similarity_jaccard_check([1,5,8,9], [1,5,9,10], 0.6);
4492</pre></div></div>
4493</li>
4494<li>
4495
4496<p>The expected result is:</p>
4497
4498<div>
4499<div>
4500<pre class="source">[ false, 0.0 ]
4501</pre></div></div>
4502</li>
4503</ul><!--
4504 ! Licensed to the Apache Software Foundation (ASF) under one
4505 ! or more contributor license agreements. See the NOTICE file
4506 ! distributed with this work for additional information
4507 ! regarding copyright ownership. The ASF licenses this file
4508 ! to you under the Apache License, Version 2.0 (the
4509 ! "License"); you may not use this file except in compliance
4510 ! with the License. You may obtain a copy of the License at
4511 !
4512 ! http://www.apache.org/licenses/LICENSE-2.0
4513 !
4514 ! Unless required by applicable law or agreed to in writing,
4515 ! software distributed under the License is distributed on an
4516 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4517 ! KIND, either express or implied. See the License for the
4518 ! specific language governing permissions and limitations
4519 ! under the License.
4520 !-->
4521</div></div>
4522<div class="section">
4523<h2><a name="Tokenizing_Functions"></a><a name="TokenizingFunctions" id="TokenizingFunctions">Tokenizing Functions</a></h2>
4524<div class="section">
4525<h3><a name="word_tokens"></a>word_tokens</h3>
4526<ul>
4527
4528<li>
4529
4530<p>Syntax:</p>
4531
4532<div>
4533<div>
4534<pre class="source">word_tokens(string)
4535</pre></div></div>
4536</li>
4537<li>
4538
4539<p>Returns an array of word tokens of <tt>string</tt> using non_alphanumeric characters as delimiters.</p>
4540</li>
4541<li>Arguments:
4542<ul>
4543
4544<li><tt>string</tt> : a <tt>string</tt> that will be tokenized.</li>
4545</ul>
4546</li>
4547<li>Return Value:
4548<ul>
4549
4550<li>an <tt>array</tt> of <tt>string</tt> word tokens,</li>
4551<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4552<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4553<li>any other non-string input value will cause a type error.</li>
4554</ul>
4555</li>
4556<li>
4557
4558<p>Example:</p>
4559
4560<div>
4561<div>
4562<pre class="source">word_tokens(&quot;I like the phone, awesome!&quot;);
4563</pre></div></div>
4564</li>
4565<li>
4566
4567<p>The expected result is:</p>
4568
4569<div>
4570<div>
4571<pre class="source">[ &quot;i&quot;, &quot;like&quot;, &quot;the&quot;, &quot;phone&quot;, &quot;awesome&quot; ]
4572</pre></div></div>
4573</li>
4574</ul><!--
4575 ! Licensed to the Apache Software Foundation (ASF) under one
4576 ! or more contributor license agreements. See the NOTICE file
4577 ! distributed with this work for additional information
4578 ! regarding copyright ownership. The ASF licenses this file
4579 ! to you under the Apache License, Version 2.0 (the
4580 ! "License"); you may not use this file except in compliance
4581 ! with the License. You may obtain a copy of the License at
4582 !
4583 ! http://www.apache.org/licenses/LICENSE-2.0
4584 !
4585 ! Unless required by applicable law or agreed to in writing,
4586 ! software distributed under the License is distributed on an
4587 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4588 ! KIND, either express or implied. See the License for the
4589 ! specific language governing permissions and limitations
4590 ! under the License.
4591 !-->
4592</div></div>
4593<div class="section">
4594<h2><a name="Temporal_Functions"></a><a name="TemporalFunctions" id="TemporalFunctions">Temporal Functions</a></h2>
4595<div class="section">
4596<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>
4597<ul>
4598
4599<li>
4600
4601<p>Syntax:</p>
4602
4603<div>
4604<div>
4605<pre class="source">get_year/get_month/get_day/get_hour/get_minute/get_second/get_millisecond(temporal_value)
4606</pre></div></div>
4607</li>
4608<li>
4609
4610<p>Accessors for accessing fields in a temporal value</p>
4611</li>
4612<li>Arguments:
4613<ul>
4614
4615<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>
4616</ul>
4617</li>
4618<li>Return Value:
4619<ul>
4620
4621<li>an <tt>bigint</tt> value representing the field to be extracted,</li>
4622<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4623<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4624<li>any other non-interval input value will cause a type error.</li>
4625</ul>
4626</li>
4627<li>
4628
4629<p>Example:</p>
4630
4631<div>
4632<div>
4633<pre class="source">{
4634 &quot;year&quot;: get_year(date(&quot;2010-10-30&quot;)),
4635 &quot;month&quot;: get_month(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4636 &quot;day&quot;: get_day(date(&quot;2010-10-30&quot;)),
4637 &quot;hour&quot;: get_hour(time(&quot;12:23:34.930+07:00&quot;)),
4638 &quot;min&quot;: get_minute(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;)),
4639 &quot;second&quot;: get_second(datetime(&quot;1987-11-19T23:49:23.938&quot;)),
4640 &quot;ms&quot;: get_millisecond(duration(&quot;P3Y73M632DT49H743M3948.94S&quot;))
4641};
4642</pre></div></div>
4643</li>
4644<li>
4645
4646<p>The expected result is:</p>
4647
4648<div>
4649<div>
4650<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 }
4651</pre></div></div>
4652</li>
4653</ul></div>
4654<div class="section">
4655<h3><a name="adjust_datetime_for_timezone"></a>adjust_datetime_for_timezone</h3>
4656<ul>
4657
4658<li>
4659
4660<p>Syntax:</p>
4661
4662<div>
4663<div>
4664<pre class="source">adjust_datetime_for_timezone(datetime, string)
4665</pre></div></div>
4666</li>
4667<li>
4668
4669<p>Adjusts the given datetime <tt>datetime</tt> by applying the timezone information <tt>string</tt>.</p>
4670</li>
4671<li>Arguments:
4672<ul>
4673
4674<li><tt>datetime</tt> : a <tt>datetime</tt> value to be adjusted.</li>
4675<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4676</ul>
4677</li>
4678<li>Return Value:
4679<ul>
4680
4681<li>a <tt>string</tt> value representing the new datetime after being adjusted by the timezone information,</li>
4682<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4683<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4684<li>a type error will be raised if:
4685<ul>
4686
4687<li>the first argument is any other non-datetime value,</li>
4688<li>or, the second argument is any other non-string value.</li>
4689</ul>
4690</li>
4691</ul>
4692</li>
4693<li>
4694
4695<p>Example:</p>
4696
4697<div>
4698<div>
4699<pre class="source">adjust_datetime_for_timezone(datetime(&quot;2008-04-26T10:10:00&quot;), &quot;+08:00&quot;);
4700</pre></div></div>
4701</li>
4702<li>
4703
4704<p>The expected result is:</p>
4705
4706<div>
4707<div>
4708<pre class="source">&quot;2008-04-26T18:10:00.000+08:00&quot;
4709</pre></div></div>
4710</li>
4711</ul></div>
4712<div class="section">
4713<h3><a name="adjust_time_for_timezone"></a>adjust_time_for_timezone</h3>
4714<ul>
4715
4716<li>
4717
4718<p>Syntax:</p>
4719
4720<div>
4721<div>
4722<pre class="source">adjust_time_for_timezone(time, string)
4723</pre></div></div>
4724</li>
4725<li>
4726
4727<p>Adjusts the given time <tt>time</tt> by applying the timezone information <tt>string</tt>.</p>
4728</li>
4729<li>Arguments:
4730<ul>
4731
4732<li><tt>time</tt> : a <tt>time</tt> value to be adjusted.</li>
4733<li><tt>string</tt> : a <tt>string</tt> representing the timezone information.</li>
4734</ul>
4735</li>
4736<li>Return Value:
4737<ul>
4738
4739<li>a <tt>string</tt> value representing the new time after being adjusted by the timezone information,</li>
4740<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4741<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4742<li>a type error will be raised if:
4743<ul>
4744
4745<li>the first argument is any other non-time value,</li>
4746<li>or, the second argument is any other non-string value.</li>
4747</ul>
4748</li>
4749</ul>
4750</li>
4751<li>
4752
4753<p>Example:</p>
4754
4755<div>
4756<div>
4757<pre class="source">adjust_time_for_timezone(get_time_from_datetime(datetime(&quot;2008-04-26T10:10:00&quot;)), &quot;+08:00&quot;);
4758</pre></div></div>
4759</li>
4760<li>
4761
4762<p>The expected result is:</p>
4763
4764<div>
4765<div>
4766<pre class="source">&quot;18:10:00.000+08:00&quot;
4767</pre></div></div>
4768</li>
4769</ul></div>
4770<div class="section">
4771<h3><a name="calendar_duration_from_datetime"></a>calendar_duration_from_datetime</h3>
4772<ul>
4773
4774<li>
4775
4776<p>Syntax:</p>
4777
4778<div>
4779<div>
4780<pre class="source">calendar_duration_from_datetime(datetime, duration_value)
4781</pre></div></div>
4782</li>
4783<li>
4784
4785<p>Gets a user_friendly representation of the duration <tt>duration_value</tt> based on the given datetime <tt>datetime</tt>.</p>
4786</li>
4787<li>Arguments:
4788<ul>
4789
4790<li><tt>datetime</tt> : a <tt>datetime</tt> value to be used as the reference time point.</li>
4791<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4792</ul>
4793</li>
4794<li>Return Value:
4795<ul>
4796
4797<li>a <tt>duration</tt> value with the duration as <tt>duration_value</tt> but with a user_friendly representation,</li>
4798<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
4799<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
4800<li>a type error will be raised if:
4801<ul>
4802
4803<li>the first argument is any other non-datetime value,</li>
4804<li>or, the second argument is any other non-duration input value.</li>
4805</ul>
4806</li>
4807</ul>
4808</li>
4809<li>
4810
4811<p>Example:</p>
4812
4813<div>
4814<div>
4815<pre class="source">calendar_duration_from_datetime(
4816 datetime(&quot;2016-03-26T10:10:00&quot;),
4817 datetime(&quot;2016-03-26T10:10:00&quot;) - datetime(&quot;2011-01-01T00:00:00&quot;)
4818);
4819</pre></div></div>
4820</li>
4821<li>
4822
4823<p>The expected result is:</p>
4824
4825<div>
4826<div>
4827<pre class="source">duration(&quot;P5Y2M24DT10H10M&quot;)
4828</pre></div></div>
4829</li>
4830</ul></div>
4831<div class="section">
4832<h3><a name="get_year_month_duration.2Fget_day_time_duration"></a>get_year_month_duration/get_day_time_duration</h3>
4833<ul>
4834
4835<li>
4836
4837<p>Syntax:</p>
4838
4839<div>
4840<div>
4841<pre class="source">get_year_month_duration/get_day_time_duration(duration_value)
4842</pre></div></div>
4843</li>
4844<li>
4845
4846<p>Extracts the correct <tt>duration</tt> subtype from <tt>duration_value</tt>.</p>
4847</li>
4848<li>Arguments:
4849<ul>
4850
4851<li><tt>duration_value</tt> : a <tt>duration</tt> value to be converted.</li>
4852</ul>
4853</li>
4854<li>Return Value:
4855<ul>
4856
4857<li>a <tt>year_month_duration</tt> value or a <tt>day_time_duration</tt> value,</li>
4858<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4859<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4860<li>any other non-duration input value will cause a type error.</li>
4861</ul>
4862</li>
4863<li>
4864
4865<p>Example:</p>
4866
4867<div>
4868<div>
4869<pre class="source">get_year_month_duration(duration(&quot;P12M50DT10H&quot;));
4870</pre></div></div>
4871</li>
4872<li>
4873
4874<p>The expected result is:</p>
4875
4876<div>
4877<div>
4878<pre class="source">year_month_duration(&quot;P1Y&quot;)
4879</pre></div></div>
4880</li>
4881</ul></div>
4882<div class="section">
4883<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>
4884<ul>
4885
4886<li>
4887
4888<p>Syntax:</p>
4889
4890<div>
4891<div>
4892<pre class="source">months_from_year_month_duration/ms_from_day_time_duration(duration_value)
4893</pre></div></div>
4894</li>
4895<li>
4896
4897<p>Extracts the number of months or the number of milliseconds from the <tt>duration</tt> subtype.</p>
4898</li>
4899<li>Arguments:
4900<ul>
4901
4902<li><tt>duration_value</tt> : a <tt>duration</tt> of the correct subtype.</li>
4903</ul>
4904</li>
4905<li>Return Value:
4906<ul>
4907
4908<li>a <tt>bigint</tt> representing the number of months/milliseconds,</li>
4909<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4910<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4911<li>any other non-duration input value will cause a type error.</li>
4912</ul>
4913</li>
4914<li>
4915
4916<p>Example:</p>
4917
4918<div>
4919<div>
4920<pre class="source">{
4921 &quot;months&quot;: months_from_year_month_duration(get_year_month_duration(duration(&quot;P5Y7MT50M&quot;))),
4922 &quot;milliseconds&quot;: ms_from_day_time_duration(get_day_time_duration(duration(&quot;P5Y7MT50M&quot;)))
4923};
4924</pre></div></div>
4925</li>
4926<li>
4927
4928<p>The expected result is:</p>
4929
4930<div>
4931<div>
4932<pre class="source">{&quot;months&quot;: 67, &quot;milliseconds&quot;: 3000000}
4933</pre></div></div>
4934</li>
4935</ul></div>
4936<div class="section">
4937<h3><a name="duration_from_months.2Fduration_from_ms"></a>duration_from_months/duration_from_ms</h3>
4938<ul>
4939
4940<li>
4941
4942<p>Syntax:</p>
4943
4944<div>
4945<div>
4946<pre class="source">duration_from_months/duration_from_ms(number_value)
4947</pre></div></div>
4948</li>
4949<li>
4950
4951<p>Creates a <tt>duration</tt> from <tt>number_value</tt>.</p>
4952</li>
4953<li>Arguments:
4954<ul>
4955
4956<li><tt>number_value</tt> : a <tt>bigint</tt> representing the number of months/milliseconds</li>
4957</ul>
4958</li>
4959<li>Return Value:
4960<ul>
4961
4962<li>a <tt>duration</tt> containing <tt>number_value</tt> value for months/milliseconds,</li>
4963<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
4964<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
4965<li>any other non-duration input value will cause a type error.</li>
4966</ul>
4967</li>
4968<li>
4969
4970<p>Example:</p>
4971
4972<div>
4973<div>
4974<pre class="source">duration_from_months(8);
4975</pre></div></div>
4976</li>
4977<li>
4978
4979<p>The expected result is:</p>
4980
4981<div>
4982<div>
4983<pre class="source">duration(&quot;P8M&quot;)
4984</pre></div></div>
4985</li>
4986</ul></div>
4987<div class="section">
4988<h3><a name="duration_from_interval"></a>duration_from_interval</h3>
4989<ul>
4990
4991<li>
4992
4993<p>Syntax:</p>
4994
4995<div>
4996<div>
4997<pre class="source">duration_from_interval(interval_value)
4998</pre></div></div>
4999</li>
5000<li>
5001
5002<p>Creates a <tt>duration</tt> from <tt>interval_value</tt>.</p>
5003</li>
5004<li>Arguments:
5005<ul>
5006
5007<li><tt>interval_value</tt> : an <tt>interval</tt> value</li>
5008</ul>
5009</li>
5010<li>Return Value:
5011<ul>
5012
5013<li>a <tt>duration</tt> representing the time in the <tt>interval_value</tt></li>
5014<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5015<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5016<li>any other non-duration input value will cause a type error.</li>
5017</ul>
5018</li>
5019<li>
5020
5021<p>Example:</p>
5022
5023<div>
5024<div>
5025<pre class="source">{
5026 &quot;dr1&quot; : duration_from_interval(interval(date(&quot;2010-10-30&quot;), date(&quot;2010-12-21&quot;))),
5027 &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;))),
5028 &quot;dr3&quot; : duration_from_interval(interval(time(&quot;12:32:38&quot;), time(&quot;20:29:20&quot;))),
5029 &quot;dr4&quot; : duration_from_interval(null)
5030};
5031</pre></div></div>
5032</li>
5033<li>
5034
5035<p>The expected result is:</p>
5036
5037<div>
5038<div>
5039<pre class="source">{
5040 &quot;dr1&quot;: day_time_duration(&quot;P52D&quot;),
5041 &quot;dr2&quot;: day_time_duration(&quot;P31DT1H1M1.111S&quot;),
5042 &quot;dr3&quot;: day_time_duration(&quot;PT7H56M42S&quot;),
5043 &quot;dr4&quot;: null
5044}
5045</pre></div></div>
5046</li>
5047</ul></div>
5048<div class="section">
5049<h3><a name="current_date"></a>current_date</h3>
5050<ul>
5051
5052<li>
5053
5054<p>Syntax:</p>
5055
5056<div>
5057<div>
5058<pre class="source">current_date()
5059</pre></div></div>
5060</li>
5061<li>
5062
5063<p>Gets the current date.</p>
5064</li>
5065<li>Arguments: None</li>
5066<li>Return Value:
5067<ul>
5068
5069<li>a <tt>date</tt> value of the date when the function is called.</li>
5070</ul>
5071</li>
5072</ul></div>
5073<div class="section">
5074<h3><a name="current_time"></a>current_time</h3>
5075<ul>
5076
5077<li>
5078
5079<p>Syntax:</p>
5080
5081<div>
5082<div>
5083<pre class="source">current_time()
5084</pre></div></div>
5085</li>
5086<li>
5087
5088<p>Get the current time</p>
5089</li>
5090<li>Arguments: None</li>
5091<li>Return Value:
5092<ul>
5093
5094<li>a <tt>time</tt> value of the time when the function is called.</li>
5095</ul>
5096</li>
5097</ul></div>
5098<div class="section">
5099<h3><a name="current_datetime"></a>current_datetime</h3>
5100<ul>
5101
5102<li>
5103
5104<p>Syntax:</p>
5105
5106<div>
5107<div>
5108<pre class="source">current_datetime()
5109</pre></div></div>
5110</li>
5111<li>
5112
5113<p>Get the current datetime</p>
5114</li>
5115<li>Arguments: None</li>
5116<li>Return Value:
5117<ul>
5118
5119<li>a <tt>datetime</tt> value of the datetime when the function is called.</li>
5120</ul>
5121</li>
5122</ul></div>
5123<div class="section">
5124<h3><a name="get_date_from_datetime"></a>get_date_from_datetime</h3>
5125<ul>
5126
5127<li>
5128
5129<p>Syntax:</p>
5130
5131<div>
5132<div>
5133<pre class="source">get_date_from_datetime(datetime)
5134</pre></div></div>
5135</li>
5136<li>
5137
5138<p>Gets the date value from the given datetime value <tt>datetime</tt>.</p>
5139</li>
5140<li>Arguments:
5141<ul>
5142
5143<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5144</ul>
5145</li>
5146<li>Return Value:
5147<ul>
5148
5149<li>a <tt>date</tt> value from the datetime,</li>
5150<li>any other non-datetime input value will cause a type error.</li>
5151</ul>
5152</li>
5153</ul></div>
5154<div class="section">
5155<h3><a name="get_time_from_datetime"></a>get_time_from_datetime</h3>
5156<ul>
5157
5158<li>
5159
5160<p>Syntax:</p>
5161
5162<div>
5163<div>
5164<pre class="source">get_time_from_datetime(datetime)
5165</pre></div></div>
5166</li>
5167<li>
5168
5169<p>Get the time value from the given datetime value <tt>datetime</tt></p>
5170</li>
5171<li>Arguments:
5172<ul>
5173
5174<li><tt>datetime</tt>: a <tt>datetime</tt> value to be extracted from.</li>
5175</ul>
5176</li>
5177<li>Return Value:
5178<ul>
5179
5180<li>a <tt>time</tt> value from the datetime.</li>
5181<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5182<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5183<li>any other non-datetime input value will cause a type error.</li>
5184</ul>
5185</li>
5186<li>
5187
5188<p>Example:</p>
5189
5190<div>
5191<div>
5192<pre class="source">get_time_from_datetime(datetime(&quot;2016-03-26T10:10:00&quot;));
5193</pre></div></div>
5194</li>
5195<li>
5196
5197<p>The expected result is:</p>
5198
5199<div>
5200<div>
5201<pre class="source">time(&quot;10:10:00.000Z&quot;)
5202</pre></div></div>
5203</li>
5204</ul></div>
5205<div class="section">
5206<h3><a name="day_of_week"></a>day_of_week</h3>
5207<ul>
5208
5209<li>
5210
5211<p>Syntax:</p>
5212
5213<div>
5214<div>
5215<pre class="source">day_of_week(date)
5216</pre></div></div>
5217</li>
5218<li>
5219
5220<p>Finds the day of the week for a given date (1_7)</p>
5221</li>
5222<li>Arguments:
5223<ul>
5224
5225<li><tt>date</tt>: a <tt>date</tt> value (Can also be a <tt>datetime</tt>)</li>
5226</ul>
5227</li>
5228<li>Return Value:
5229<ul>
5230
5231<li>an <tt>tinyint</tt> representing the day of the week (1_7),</li>
5232<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5233<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5234<li>any other non-date input value will cause a type error.</li>
5235</ul>
5236</li>
5237<li>
5238
5239<p>Example:</p>
5240
5241<div>
5242<div>
5243<pre class="source">day_of_week(datetime(&quot;2012-12-30T12:12:12.039Z&quot;));
5244</pre></div></div>
5245</li>
5246<li>
5247
5248<p>The expected result is:</p>
5249
5250<div>
5251<div>
5252<pre class="source">7
5253</pre></div></div>
5254</li>
5255</ul></div>
5256<div class="section">
5257<h3><a name="date_from_unix_time_in_days"></a>date_from_unix_time_in_days</h3>
5258<ul>
5259
5260<li>
5261
5262<p>Syntax:</p>
5263
5264<div>
5265<div>
5266<pre class="source">date_from_unix_time_in_days(numeric_value)
5267</pre></div></div>
5268</li>
5269<li>
5270
5271<p>Gets a date representing the time after <tt>numeric_value</tt> days since 1970_01_01.</p>
5272</li>
5273<li>Arguments:
5274<ul>
5275
5276<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>
5277</ul>
5278</li>
5279<li>Return Value:
5280<ul>
5281
5282<li>a <tt>date</tt> value as the time after <tt>numeric_value</tt> days since 1970-01-01,</li>
5283<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5284<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5285<li>any other non-numeric input value will cause a type error.</li>
5286</ul>
5287</li>
5288</ul></div>
5289<div class="section">
5290<h3><a name="datetime_from_unix_time_in_ms"></a>datetime_from_unix_time_in_ms</h3>
5291<ul>
5292
5293<li>
5294
5295<p>Syntax:</p>
5296
5297<div>
5298<div>
5299<pre class="source">datetime_from_unix_time_in_ms(numeric_value)
5300</pre></div></div>
5301</li>
5302<li>
5303
5304<p>Gets a datetime representing the time after <tt>numeric_value</tt> milliseconds since 1970_01_01T00:00:00Z.</p>
5305</li>
5306<li>Arguments:
5307<ul>
5308
5309<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>
5310</ul>
5311</li>
5312<li>Return Value:
5313<ul>
5314
5315<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> milliseconds since 1970-01-01T00:00:00Z,</li>
5316<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5317<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5318<li>any other non-numeric input value will cause a type error.</li>
5319</ul>
5320</li>
5321</ul></div>
5322<div class="section">
5323<h3><a name="datetime_from_unix_time_in_secs"></a>datetime_from_unix_time_in_secs</h3>
5324<ul>
5325
5326<li>
5327
5328<p>Syntax:</p>
5329
5330<div>
5331<div>
5332<pre class="source">datetime_from_unix_time_in_secs(numeric_value)
5333</pre></div></div>
5334</li>
5335<li>
5336
5337<p>Gets a datetime representing the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z.</p>
5338</li>
5339<li>Arguments:
5340<ul>
5341
5342<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>
5343</ul>
5344</li>
5345<li>Return Value:
5346<ul>
5347
5348<li>a <tt>datetime</tt> value as the time after <tt>numeric_value</tt> seconds since 1970_01_01T00:00:00Z,</li>
5349<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5350<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5351<li>any other non-numeric input value will cause a type error.</li>
5352</ul>
5353</li>
5354</ul></div>
5355<div class="section">
5356<h3><a name="datetime_from_date_time"></a>datetime_from_date_time</h3>
5357<ul>
5358
5359<li>Syntax:</li>
5360</ul>
5361<p>datetime_from_date_time(date,time)</p>
5362<ul>
5363
5364<li>Gets a datetime representing the combination of <tt>date</tt> and <tt>time</tt>
5365<ul>
5366
5367<li>Arguments:</li>
5368<li><tt>date</tt>: a <tt>date</tt> value</li>
5369<li><tt>time</tt> a <tt>time</tt> value</li>
5370</ul>
5371</li>
5372<li>Return Value:
5373<ul>
5374
5375<li>a <tt>datetime</tt> value by combining <tt>date</tt> and <tt>time</tt>,</li>
5376<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5377<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5378<li>a type error will be raised if
5379<ul>
5380
5381<li>the first argument is any other non-date value,</li>
5382<li>or, the second argument is any other non-time value.</li>
5383</ul>
5384</li>
5385</ul>
5386</li>
5387</ul></div>
5388<div class="section">
5389<h3><a name="time_from_unix_time_in_ms"></a>time_from_unix_time_in_ms</h3>
5390<ul>
5391
5392<li>
5393
5394<p>Syntax:</p>
5395
5396<div>
5397<div>
5398<pre class="source">time_from_unix_time_in_ms(numeric_value)
5399</pre></div></div>
5400</li>
5401<li>
5402
5403<p>Gets a time representing the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z.</p>
5404</li>
5405<li>Arguments:
5406<ul>
5407
5408<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>
5409</ul>
5410</li>
5411<li>Return Value:
5412<ul>
5413
5414<li>a <tt>time</tt> value as the time after <tt>numeric_value</tt> milliseconds since 00:00:00.000Z,</li>
5415<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5416<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5417<li>any other non-numeric input value will cause a type error.</li>
5418</ul>
5419</li>
5420<li>
5421
5422<p>Example:</p>
5423
5424<div>
5425<div>
5426<pre class="source">{
5427 &quot;date&quot;: date_from_unix_time_in_days(15800),
5428 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5429 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5430};
5431</pre></div></div>
5432</li>
5433<li>
5434
5435<p>The expected result is:</p>
5436
5437<div>
5438<div>
5439<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;) }
5440</pre></div></div>
5441</li>
5442</ul></div>
5443<div class="section">
5444<h3><a name="unix_time_from_date_in_days"></a>unix_time_from_date_in_days</h3>
5445<ul>
5446
5447<li>
5448
5449<p>Syntax:</p>
5450
5451<div>
5452<div>
5453<pre class="source">unix_time_from_date_in_days(date_value)
5454</pre></div></div>
5455</li>
5456<li>
5457
5458<p>Gets an integer value representing the number of days since 1970_01_01 for <tt>date_value</tt>.</p>
5459</li>
5460<li>Arguments:
5461<ul>
5462
5463<li><tt>date_value</tt>: a <tt>date</tt> value.</li>
5464</ul>
5465</li>
5466<li>Return Value:
5467<ul>
5468
5469<li>a <tt>bigint</tt> value representing the number of days,</li>
5470<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5471<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5472<li>any other non-date input value will cause a type error.</li>
5473</ul>
5474</li>
5475</ul></div>
5476<div class="section">
5477<h3><a name="unix_time_from_datetime_in_ms"></a>unix_time_from_datetime_in_ms</h3>
5478<ul>
5479
5480<li>
5481
5482<p>Syntax:</p>
5483
5484<div>
5485<div>
5486<pre class="source">unix_time_from_datetime_in_ms(datetime_value)
5487</pre></div></div>
5488</li>
5489<li>
5490
5491<p>Gets an integer value representing the time in milliseconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5492</li>
5493<li>Arguments:
5494<ul>
5495
5496<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5497</ul>
5498</li>
5499<li>Return Value:
5500<ul>
5501
5502<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5503<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5504<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5505<li>any other non-datetime input value will cause a type error.</li>
5506</ul>
5507</li>
5508</ul></div>
5509<div class="section">
5510<h3><a name="unix_time_from_datetime_in_secs"></a>unix_time_from_datetime_in_secs</h3>
5511<ul>
5512
5513<li>
5514
5515<p>Syntax:</p>
5516
5517<div>
5518<div>
5519<pre class="source">unix_time_from_datetime_in_secs(datetime_value)
5520</pre></div></div>
5521</li>
5522<li>
5523
5524<p>Gets an integer value representing the time in seconds since 1970_01_01T00:00:00Z for <tt>datetime_value</tt>.</p>
5525</li>
5526<li>Arguments:
5527<ul>
5528
5529<li><tt>datetime_value</tt> : a <tt>datetime</tt> value.</li>
5530</ul>
5531</li>
5532<li>Return Value:
5533<ul>
5534
5535<li>a <tt>bigint</tt> value representing the number of seconds,</li>
5536<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5537<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5538<li>any other non-datetime input value will cause a type error.</li>
5539</ul>
5540</li>
5541</ul></div>
5542<div class="section">
5543<h3><a name="unix_time_from_time_in_ms"></a>unix_time_from_time_in_ms</h3>
5544<ul>
5545
5546<li>
5547
5548<p>Syntax:</p>
5549
5550<div>
5551<div>
5552<pre class="source">unix_time_from_time_in_ms(time_value)
5553</pre></div></div>
5554</li>
5555<li>
5556
5557<p>Gets an integer value representing the time the milliseconds since 00:00:00.000Z for <tt>time_value</tt>.</p>
5558</li>
5559<li>Arguments:
5560<ul>
5561
5562<li><tt>time_value</tt> : a <tt>time</tt> value.</li>
5563</ul>
5564</li>
5565<li>Return Value:
5566<ul>
5567
5568<li>a <tt>bigint</tt> value representing the number of milliseconds,</li>
5569<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5570<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5571<li>any other non-datetime input value will cause a type error.</li>
5572</ul>
5573</li>
5574<li>
5575
5576<p>Example:</p>
5577
5578<div>
5579<div>
5580<pre class="source">{
5581 &quot;date&quot;: date_from_unix_time_in_days(15800),
5582 &quot;datetime&quot;: datetime_from_unix_time_in_ms(1365139700000),
5583 &quot;time&quot;: time_from_unix_time_in_ms(3748)
5584}
5585</pre></div></div>
5586</li>
5587<li>
5588
5589<p>The expected result is:</p>
5590
5591<div>
5592<div>
5593<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;) }
5594</pre></div></div>
5595</li>
5596</ul></div>
5597<div class="section">
5598<h3><a name="parse_date.2Fparse_time.2Fparse_datetime"></a>parse_date/parse_time/parse_datetime</h3>
5599<ul>
5600
5601<li>Syntax:</li>
5602</ul>
5603<p>parse_date/parse_time/parse_datetime(date,formatting_expression)</p>
5604<ul>
5605
5606<li>Creates a <tt>date/time/date_time</tt> value by treating <tt>date</tt> with formatting <tt>formatting_expression</tt></li>
5607<li>Arguments:
5608<ul>
5609
5610<li><tt>date</tt>: a <tt>string</tt> value representing the <tt>date/time/datetime</tt>.</li>
5611<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>
5612<li><tt>h</tt> hours</li>
5613<li><tt>m</tt> minutes</li>
5614<li><tt>s</tt> seconds</li>
5615<li><tt>n</tt> milliseconds</li>
5616<li><tt>a</tt> am/pm</li>
5617<li><tt>z</tt> timezone</li>
5618<li><tt>Y</tt> year</li>
5619<li><tt>M</tt> month</li>
5620<li><tt>D</tt> day</li>
5621<li><tt>W</tt> weekday</li>
5622<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5623</ul>
5624</li>
5625<li>Return Value:
5626<ul>
5627
5628<li>a <tt>date/time/date_time</tt> value corresponding to <tt>date</tt>,</li>
5629<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5630<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5631<li>a type error will be raised if:</li>
5632<li>the first argument is any other non-date value,</li>
5633<li>the second argument is any other non-string value.</li>
5634</ul>
5635</li>
5636<li>
5637
5638<p>Example:</p>
5639
5640<div>
5641<div>
5642<pre class="source">parse_time(&quot;30:30&quot;,&quot;m:s&quot;);
5643</pre></div></div>
5644</li>
5645<li>
5646
5647<p>The expected result is:</p>
5648
5649<div>
5650<div>
5651<pre class="source">time(&quot;00:30:30.000Z&quot;)
5652</pre></div></div>
5653</li>
5654</ul></div>
5655<div class="section">
5656<h3><a name="print_date.2Fprint_time.2Fprint_datetime"></a>print_date/print_time/print_datetime</h3>
5657<ul>
5658
5659<li>
5660
5661<p>Syntax:</p>
5662
5663<div>
5664<div>
5665<pre class="source">print_date/print_time/print_datetime(date,formatting_expression)
5666</pre></div></div>
5667</li>
5668<li>
5669
5670<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>
5671</li>
5672<li>Arguments:
5673<ul>
5674
5675<li><tt>date</tt>: a <tt>date/time/datetime</tt> value.</li>
5676<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>
5677<li><tt>h</tt> hours</li>
5678<li><tt>m</tt> minutes</li>
5679<li><tt>s</tt> seconds</li>
5680<li><tt>n</tt> milliseconds</li>
5681<li><tt>a</tt> am/pm</li>
5682<li><tt>z</tt> timezone</li>
5683<li><tt>Y</tt> year</li>
5684<li><tt>M</tt> month</li>
5685<li><tt>D</tt> day</li>
5686<li><tt>W</tt> weekday</li>
5687<li><tt>_</tt>, <tt>'</tt>, <tt>/</tt>, <tt>.</tt>, <tt>,</tt>, <tt>T</tt> seperators for both time and date</li>
5688</ul>
5689</li>
5690<li>Return Value:
5691<ul>
5692
5693<li>a <tt>string</tt> value corresponding to <tt>date</tt>,</li>
5694<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5695<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5696<li>a type error will be raised if:
5697<ul>
5698
5699<li>the first argument is any other non-date value,</li>
5700<li>the second argument is any other non-string value.</li>
5701</ul>
5702</li>
5703</ul>
5704</li>
5705<li>
5706
5707<p>Example:</p>
5708
5709<div>
5710<div>
5711<pre class="source">print_time(time(&quot;00:30:30.000Z&quot;),&quot;m:s&quot;);
5712</pre></div></div>
5713</li>
5714<li>
5715
5716<p>The expected result is:</p>
5717
5718<div>
5719<div>
5720<pre class="source">&quot;30:30&quot;
5721</pre></div></div>
5722</li>
5723</ul></div>
5724<div class="section">
5725<h3><a name="get_interval_start.2C_get_interval_end"></a>get_interval_start, get_interval_end</h3>
5726<ul>
5727
5728<li>
5729
5730<p>Syntax:</p>
5731
5732<div>
5733<div>
5734<pre class="source">get_interval_start/get_interval_end(interval)
5735</pre></div></div>
5736</li>
5737<li>
5738
5739<p>Gets the start/end of the given interval.</p>
5740</li>
5741<li>Arguments:
5742<ul>
5743
5744<li><tt>interval</tt>: the interval to be accessed.</li>
5745</ul>
5746</li>
5747<li>Return Value:
5748<ul>
5749
5750<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>
5751<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5752<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5753<li>any other non-interval value will cause a type error.</li>
5754</ul>
5755</li>
5756<li>
5757
5758<p>Example:</p>
5759
5760<div>
5761<div>
5762<pre class="source">{
5763 &quot;start&quot;: get_interval_start(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5764 &quot;end&quot;: get_interval_end(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;))
5765};
5766</pre></div></div>
5767</li>
5768<li>
5769
5770<p>The expected result is:</p>
5771
5772<div>
5773<div>
5774<pre class="source">{ &quot;start&quot;: date(&quot;1984_01_01&quot;), &quot;end&quot;: date(&quot;1985_01_01&quot;) }
5775</pre></div></div>
5776</li>
5777</ul></div>
5778<div class="section">
5779<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>
5780<ul>
5781
5782<li>
5783
5784<p>Syntax:</p>
5785
5786<div>
5787<div>
5788<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)
5789</pre></div></div>
5790</li>
5791<li>
5792
5793<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5794</li>
5795<li>Arguments:
5796<ul>
5797
5798<li><tt>interval</tt>: the interval to be accessed.</li>
5799</ul>
5800</li>
5801<li>Return Value:
5802<ul>
5803
5804<li>a <tt>time</tt>, <tt>date</tt>, or <tt>datetime</tt> (depending on the function) representing the starting or ending time,</li>
5805<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
5806<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
5807<li>any other non-interval value will cause a type error.</li>
5808</ul>
5809</li>
5810<li>
5811
5812<p>Example:</p>
5813
5814<div>
5815<div>
5816<pre class="source">{
5817 &quot;start1&quot;: get_interval_start_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5818 &quot;end1&quot;: get_interval_end_date(interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;)),
5819 &quot;start2&quot;: get_interval_start_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5820 &quot;end2&quot;: get_interval_end_datetime(interval_start_from_datetime(&quot;1984-01-01T08:30:00.000&quot;, &quot;P1Y1H&quot;)),
5821 &quot;start3&quot;: get_interval_start_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;)),
5822 &quot;end3&quot;: get_interval_end_time(interval_start_from_time(&quot;08:30:00.000&quot;, &quot;P1H&quot;))
5823};
5824</pre></div></div>
5825</li>
5826<li>
5827
5828<p>The expected result is:</p>
5829
5830<div>
5831<div>
5832<pre class="source">{
5833 &quot;start1&quot;: date(&quot;1984-01-01&quot;),
5834 &quot;end1&quot;: date(&quot;1985-01-01&quot;),
5835 &quot;start2&quot;: datetime(&quot;1984-01-01T08:30:00.000Z&quot;),
5836 &quot;end2&quot;: datetime(&quot;1985-01-01T09:30:00.000Z&quot;),
5837 &quot;start3&quot;: time(&quot;08:30:00.000Z&quot;),
5838 &quot;end3&quot;: time(&quot;09:30:00.000Z&quot;)
5839}
5840</pre></div></div>
5841</li>
5842</ul></div>
5843<div class="section">
5844<h3><a name="get_overlapping_interval"></a>get_overlapping_interval</h3>
5845<ul>
5846
5847<li>
5848
5849<p>Syntax:</p>
5850
5851<div>
5852<div>
5853<pre class="source">get_overlapping_interval(interval1, interval2)
5854</pre></div></div>
5855</li>
5856<li>
5857
5858<p>Gets the start/end of the given interval for the specific date/datetime/time type.</p>
5859</li>
5860<li>Arguments:
5861<ul>
5862
5863<li><tt>interval1</tt>: an <tt>interval</tt> value</li>
5864<li><tt>interval2</tt>: an <tt>interval</tt> value</li>
5865</ul>
5866</li>
5867<li>Return Value:
5868<ul>
5869
5870<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>
5871<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5872<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5873<li>any other non-interval input value will cause a type error.</li>
5874</ul>
5875</li>
5876<li>
5877
5878<p>Example:</p>
5879
5880<div>
5881<div>
5882<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;))),
5883 &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;))),
5884 &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;))),
5885 &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;))),
5886 &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;))),
5887 &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;)))
5888};
5889</pre></div></div>
5890</li>
5891<li>
5892
5893<p>The expected result is:</p>
5894
5895<div>
5896<div>
5897<pre class="source">{ &quot;overlap1&quot;: interval(time(&quot;12:23:39.000Z&quot;), time(&quot;18:27:19.000Z&quot;)),
5898 &quot;overlap2&quot;: null,
5899 &quot;overlap3&quot;: null,
5900 &quot;overlap4&quot;: interval(date(&quot;2013-01-01&quot;), date(&quot;2014_01_01&quot;)),
5901 &quot;overlap5&quot;: interval(datetime(&quot;1989-03-04T12:23:39.000Z&quot;), datetime(&quot;2000-10-30T18:27:19.000Z&quot;)),
5902 &quot;overlap6&quot;: null
5903}
5904</pre></div></div>
5905</li>
5906</ul></div>
5907<div class="section">
5908<h3><a name="interval_bin"></a>interval_bin</h3>
5909<ul>
5910
5911<li>
5912
5913<p>Syntax:</p>
5914
5915<div>
5916<div>
5917<pre class="source">interval_bin(time_to_bin, time_bin_anchor, duration_bin_size)
5918</pre></div></div>
5919</li>
5920<li>
5921
5922<p>Returns the <tt>interval</tt> value representing the bin containing the <tt>time_to_bin</tt> value.</p>
5923</li>
5924<li>Arguments:
5925<ul>
5926
5927<li><tt>time_to_bin</tt>: a date/time/datetime value representing the time to be binned.</li>
5928<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>
5929<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:
5930<ul>
5931
5932<li>datetime +|_ year_month_duration</li>
5933<li>datetime +|_ day_time_duration</li>
5934<li>date +|_ year_month_duration</li>
5935<li>date +|_ day_time_duration</li>
5936<li>time +|_ day_time_duration</li>
5937</ul>
5938</li>
5939</ul>
5940</li>
5941<li>Return Value:
5942<ul>
5943
5944<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>
5945<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
5946<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
5947<li>a type error will be raised if:
5948<ul>
5949
5950<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
5951<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
5952</ul>
5953</li>
5954</ul>
5955</li>
5956<li>
5957
5958<p>Example:</p>
5959
5960<div>
5961<div>
5962<pre class="source">{
5963 &quot;bin1&quot;: interval_bin(date(&quot;2010-10-30&quot;), date(&quot;1990-01-01&quot;), year_month_duration(&quot;P1Y&quot;)),
5964 &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;)),
5965 &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;)),
5966 &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;))
5967};
5968</pre></div></div>
5969</li>
5970<li>
5971
5972<p>The expected result is:</p>
5973
5974<div>
5975<div>
5976<pre class="source">{
5977 &quot;bin1&quot;: interval(date(&quot;2010-01-01&quot;),date(&quot;2011-01-01&quot;)),
5978 &quot;bin2&quot;: interval(datetime(&quot;1987-07-01T00:00:00.000Z&quot;), datetime(&quot;1988-01-01T00:00:00.000Z&quot;)),
5979 &quot;bin3&quot;: interval(time(&quot;05:23:00.000Z&quot;), time(&quot;05:24:00.000Z&quot;)),
5980 &quot;bin4&quot;: interval(datetime(&quot;1987-11-19T00:00:00.000Z&quot;), datetime(&quot;1987-11-20T00:00:00.000Z&quot;))
5981}
5982</pre></div></div>
5983</li>
5984</ul></div>
5985<div class="section">
5986<h3><a name="interval_start_from_date.2Ftime.2Fdatetime"></a>interval_start_from_date/time/datetime</h3>
5987<ul>
5988
5989<li>
5990
5991<p>Syntax:</p>
5992
5993<div>
5994<div>
5995<pre class="source">interval_start_from_date/time/datetime(date/time/datetime, duration)
5996</pre></div></div>
5997</li>
5998<li>
5999
6000<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>
6001</li>
6002<li>Arguments:
6003<ul>
6004
6005<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>
6006<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>
6007</ul>
6008</li>
6009<li>Return Value:
6010<ul>
6011
6012<li>an <tt>interval</tt> value representing the interval starting from the given time point with the length of duration,</li>
6013<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6014<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6015<li>a type error will be raised if:
6016<ul>
6017
6018<li>the first argument or the second argument is any other non-date/non-time/non-datetime value,</li>
6019<li>or, the second argument is any other non-duration value.</li>
6020</ul>
6021</li>
6022</ul>
6023</li>
6024<li>
6025
6026<p>Example:</p>
6027
6028<div>
6029<div>
6030<pre class="source">{
6031 &quot;interval1&quot;: interval_start_from_date(&quot;1984-01-01&quot;, &quot;P1Y&quot;),
6032 &quot;interval2&quot;: interval_start_from_time(time(&quot;02:23:28.394&quot;), &quot;PT3H24M&quot;),
6033 &quot;interval3&quot;: interval_start_from_datetime(&quot;1999-09-09T09:09:09.999&quot;, duration(&quot;P2M30D&quot;))
6034};
6035</pre></div></div>
6036</li>
6037<li>
6038
6039<p>The expectecd result is:</p>
6040
6041<div>
6042<div>
6043<pre class="source">{
6044 &quot;interval1&quot;: interval(date(&quot;1984-01-01&quot;), date(&quot;1985-01-01&quot;)),
6045 &quot;interval2&quot;: interval(time(&quot;02:23:28.394Z&quot;), time(&quot;05:47:28.394Z&quot;)),
6046 &quot;interval3&quot;: interval(datetime(&quot;1999-09-09T09:09:09.999Z&quot;), datetime(&quot;1999-12-09T09:09:09.999Z&quot;))
6047}
6048</pre></div></div>
6049</li>
6050</ul></div>
6051<div class="section">
6052<h3><a name="overlap_bins"></a>overlap_bins</h3>
6053<ul>
6054
6055<li>
6056
6057<p>Return Value:</p>
6058<ul>
6059
6060<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>
6061</ul>
6062</li>
6063<li>
6064
6065<p>Syntax:</p>
6066
6067<div>
6068<div>
6069<pre class="source">overlap_bins(interval, time_bin_anchor, duration_bin_size)
6070</pre></div></div>
6071</li>
6072<li>
6073
6074<p>Returns an ordered list of <tt>interval</tt> values representing each bin that is overlapping the <tt>interval</tt>.</p>
6075</li>
6076<li>Arguments:
6077<ul>
6078
6079<li><tt>interval</tt>: an <tt>interval</tt> value</li>
6080<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>
6081<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:
6082<ul>
6083
6084<li>datetime +|_ year_month_duration</li>
6085<li>datetime +|_ day_time_duration</li>
6086<li>date +|_ year_month_duration</li>
6087<li>date +|_ day_time_duration</li>
6088<li>time +|_ day_time_duration</li>
6089</ul>
6090</li>
6091</ul>
6092</li>
6093<li>Return Value:
6094<ul>
6095
6096<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>
6097<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6098<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6099<li>a type error will be raised if:
6100<ul>
6101
6102<li>the first arugment is any other non-interval value,</li>
6103<li>or, the second argument is any other non-date/non-time/non-datetime value,</li>
6104<li>or, the second argument is any other non-year_month_duration/non-day_time_duration value.</li>
6105</ul>
6106</li>
6107</ul>
6108</li>
6109<li>
6110
6111<p>Example:</p>
6112
6113<div>
6114<div>
6115<pre class="source">{
6116 &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;)),
6117 &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;)),
6118 &quot;datetimebins&quot;: overlap_bins(interval(datetime(&quot;1800-01-01T23:59:48.938&quot;), datetime(&quot;2015-07-26T13:28:30.218&quot;)),
6119 datetime(&quot;1900-01-01T00:00:00.000&quot;), year_month_duration(&quot;P100Y&quot;))
6120};
6121</pre></div></div>
6122</li>
6123<li>
6124
6125<p>The expected result is:</p>
6126
6127<div>
6128<div>
6129<pre class="source">{
6130 &quot;timebins&quot;: [
6131 interval(time(&quot;17:00:00.000Z&quot;), time(&quot;17:30:00.000Z&quot;)),
6132 interval(time(&quot;17:30:00.000Z&quot;), time(&quot;18:00:00.000Z&quot;)),
6133 interval(time(&quot;18:00:00.000Z&quot;), time(&quot;18:30:00.000Z&quot;)),
6134 interval(time(&quot;18:30:00.000Z&quot;), time(&quot;19:00:00.000Z&quot;))
6135 ],
6136 &quot;datebins&quot;: [
6137 interval(date(&quot;1980-01-01&quot;), date(&quot;1990-01-01&quot;)),
6138 interval(date(&quot;1990-01-01&quot;), date(&quot;2000-01-01&quot;)),
6139 interval(date(&quot;2000-01-01&quot;), date(&quot;2010-01-01&quot;)),
6140 interval(date(&quot;2010-01-01&quot;), date(&quot;2020-01-01&quot;))
6141 ],
6142 &quot;datetimebins&quot;: [
6143 interval(datetime(&quot;1800-01-01T00:00:00.000Z&quot;), datetime(&quot;1900-01-01T00:00:00.000Z&quot;)),
6144 interval(datetime(&quot;1900-01-01T00:00:00.000Z&quot;), datetime(&quot;2000-01-01T00:00:00.000Z&quot;)),
6145 interval(datetime(&quot;2000-01-01T00:00:00.000Z&quot;), datetime(&quot;2100-01-01T00:00:00.000Z&quot;))
6146 ]
6147};
6148</pre></div></div>
6149</li>
6150</ul><!--
6151 ! Licensed to the Apache Software Foundation (ASF) under one
6152 ! or more contributor license agreements. See the NOTICE file
6153 ! distributed with this work for additional information
6154 ! regarding copyright ownership. The ASF licenses this file
6155 ! to you under the Apache License, Version 2.0 (the
6156 ! "License"); you may not use this file except in compliance
6157 ! with the License. You may obtain a copy of the License at
6158 !
6159 ! http://www.apache.org/licenses/LICENSE-2.0
6160 !
6161 ! Unless required by applicable law or agreed to in writing,
6162 ! software distributed under the License is distributed on an
6163 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6164 ! KIND, either express or implied. See the License for the
6165 ! specific language governing permissions and limitations
6166 ! under the License.
6167 !-->
6168</div>
6169<div class="section">
6170<h3><a name="interval_before.2C_interval_after"></a>interval_before, interval_after</h3>
6171<ul>
6172
6173<li>
6174
6175<p>Syntax:</p>
6176
6177<div>
6178<div>
6179<pre class="source">interval_before(interval1, interval2)
6180interval_after(interval1, interval2)
6181</pre></div></div>
6182</li>
6183<li>
6184
6185<p>These two functions check whether an interval happens before/after another interval.</p>
6186</li>
6187<li>Arguments:
6188<ul>
6189
6190<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6191</ul>
6192</li>
6193<li>Return Value:
6194<ul>
6195
6196<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>
6197<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6198<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6199<li>any other non-interval input value will cause a type error.</li>
6200</ul>
6201</li>
6202<li>
6203
6204<p>Examples:</p>
6205
6206<div>
6207<div>
6208<pre class="source">{
6209 &quot;interval_before&quot;: interval_before(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6210 interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;))),
6211 &quot;interval_after&quot;: interval_after(interval(date(&quot;2005-05-01&quot;), date(&quot;2012-09-09&quot;)),
6212 interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)))
6213};
6214</pre></div></div>
6215</li>
6216<li>
6217
6218<p>The expected result is:</p>
6219
6220<div>
6221<div>
6222<pre class="source">{ &quot;interval_before&quot;: true, &quot;interval_after&quot;: true }
6223</pre></div></div>
6224</li>
6225</ul></div>
6226<div class="section">
6227<h3><a name="interval_covers.2C_interval_covered_by"></a>interval_covers, interval_covered_by</h3>
6228<ul>
6229
6230<li>
6231
6232<p>Syntax:</p>
6233
6234<div>
6235<div>
6236<pre class="source">interval_covers(interval1, interval2)
6237interval_covered_by(interval1, interval2)
6238</pre></div></div>
6239</li>
6240<li>
6241
6242<p>These two functions check whether one interval covers the other interval.</p>
6243</li>
6244<li>Arguments:
6245<ul>
6246
6247<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6248</ul>
6249</li>
6250<li>Return Value:
6251<ul>
6252
6253<li>
6254
6255<p>a <tt>boolean</tt> value. Specifically, <tt>interval_covers(interval1, interval2)</tt> is true if and only if</p>
6256<p>interval1.start &lt;= interval2.start AND interval1.end &gt;= interval2.end</p>
6257<p><tt>interval_covered_by(interval1, interval2)</tt> is true if and only if</p>
6258<p>interval2.start &lt;= interval1.start AND interval2.end &gt;= interval1.end</p>
6259</li>
6260<li>
6261
6262<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6263</li>
6264<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6265<li>any other non-interval input value will cause a type error.</li>
6266</ul>
6267</li>
6268<li>
6269
6270<p>Examples:</p>
6271
6272<div>
6273<div>
6274<pre class="source">{
6275 &quot;interval_covers&quot;: interval_covers(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6276 interval(date(&quot;2000-03-01&quot;), date(&quot;2004-09-09&quot;))),
6277 &quot;interval_covered_by&quot;: interval_covered_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6278 interval(date(&quot;2004-09-10&quot;), date(&quot;2012-08-01&quot;)))
6279};
6280</pre></div></div>
6281</li>
6282<li>
6283
6284<p>The expected result is:</p>
6285
6286<div>
6287<div>
6288<pre class="source">{ &quot;interval_covers&quot;: true, &quot;interval_covered_by&quot;: true }
6289</pre></div></div>
6290</li>
6291</ul></div>
6292<div class="section">
6293<h3><a name="interval_overlaps.2C_interval_overlapped_by"></a>interval_overlaps, interval_overlapped_by</h3>
6294<ul>
6295
6296<li>
6297
6298<p>Syntax:</p>
6299
6300<div>
6301<div>
6302<pre class="source">interval_overlaps(interval1, interval2)
6303interval_overlapped_by(interval1, interval2)
6304</pre></div></div>
6305</li>
6306<li>
6307
6308<p>These functions check whether two intervals overlap with each other.</p>
6309</li>
6310<li>Arguments:
6311<ul>
6312
6313<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6314</ul>
6315</li>
6316<li>Return Value:
6317<ul>
6318
6319<li>a <tt>boolean</tt> value. Specifically, <tt>interval_overlaps(interval1, interval2)</tt> is true if and only if
6320<p>interval1.start &lt; interval2.start AND interval2.end &gt; interval1.end AND interval1.end &gt; interval2.start</p></li>
6321</ul>
6322<p><tt>interval_overlapped_by(interval1, interval2)</tt> is true if and only if</p>
6323
6324<div>
6325<div>
6326<pre class="source">interval2.start &lt; interval1.start
6327AND interval1.end &gt; interval2.end
6328AND interval2.end &gt; interval1.start
6329</pre></div></div>
6330
6331<ul>
6332
6333<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6334<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6335<li>any other non-interval input value will cause a type error.</li>
6336</ul>
6337<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>
6338</li>
6339<li>
6340
6341<p>Examples:</p>
6342
6343<div>
6344<div>
6345<pre class="source">{
6346 &quot;overlaps&quot;: interval_overlaps(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6347 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6348 &quot;overlapped_by&quot;: interval_overlapped_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6349 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))))
6350};
6351</pre></div></div>
6352</li>
6353<li>
6354
6355<p>The expected result is:</p>
6356
6357<div>
6358<div>
6359<pre class="source">{ &quot;overlaps&quot;: true, &quot;overlapped_by&quot;: true }
6360</pre></div></div>
6361</li>
6362</ul></div>
6363<div class="section">
6364<h3><a name="interval_overlapping"></a>interval_overlapping</h3>
6365<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>
6366<ul>
6367
6368<li>
6369
6370<p>Syntax:</p>
6371
6372<div>
6373<div>
6374<pre class="source">interval_overlapping(interval1, interval2)
6375</pre></div></div>
6376</li>
6377<li>
6378
6379<p>This functions check whether two intervals share any points with each other.</p>
6380</li>
6381<li>Arguments:
6382<ul>
6383
6384<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6385</ul>
6386</li>
6387<li>Return Value:
6388<ul>
6389
6390<li>
6391
6392<p>a <tt>boolean</tt> value. Specifically, <tt>interval_overlapping(interval1, interval2)</tt> is true if</p>
6393<p>interval1.start &lt; interval2.end AND interval1.end &gt; interval2.start</p>
6394</li>
6395<li>
6396
6397<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6398</li>
6399<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6400<li>any other non-interval input value will cause a type error.</li>
6401</ul>
6402</li>
6403<li>
6404
6405<p>Examples:</p>
6406
6407<div>
6408<div>
6409<pre class="source">{
6410 &quot;overlapping1&quot;: interval_overlapping(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6411 interval(date(&quot;2004-05-01&quot;), date(&quot;2012-09-09&quot;))),
6412 &quot;overlapping2&quot;: interval_overlapping(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6413 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-12-31&quot;)))
6414};
6415</pre></div></div>
6416</li>
6417<li>
6418
6419<p>The expected result is:</p>
6420
6421<div>
6422<div>
6423<pre class="source">{ &quot;overlapping1&quot;: true, &quot;overlapping2&quot;: true }
6424</pre></div></div>
6425</li>
6426</ul></div>
6427<div class="section">
6428<h3><a name="interval_meets.2C_interval_met_by"></a>interval_meets, interval_met_by</h3>
6429<ul>
6430
6431<li>
6432
6433<p>Syntax:</p>
6434
6435<div>
6436<div>
6437<pre class="source">interval_meets(interval1, interval2)
6438interval_met_by(interval1, interval2)
6439</pre></div></div>
6440</li>
6441<li>
6442
6443<p>These two functions check whether an interval meets with another interval.</p>
6444</li>
6445<li>Arguments:
6446<ul>
6447
6448<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6449</ul>
6450</li>
6451<li>Return Value:
6452<ul>
6453
6454<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>
6455<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6456<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6457<li>any other non-interval input value will cause a type error.</li>
6458</ul>
6459</li>
6460<li>
6461
6462<p>Examples:</p>
6463
6464<div>
6465<div>
6466<pre class="source">{
6467 &quot;meets&quot;: interval_meets(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6468 interval(date(&quot;2005-01-01&quot;), date(&quot;2012-09-09&quot;))),
6469 &quot;metby&quot;: interval_met_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6470 interval(date(&quot;2004-09-10&quot;), date(&quot;2006-08-01&quot;)))
6471};
6472</pre></div></div>
6473</li>
6474<li>
6475
6476<p>The expected result is:</p>
6477
6478<div>
6479<div>
6480<pre class="source">{ &quot;meets&quot;: true, &quot;metby&quot;: true }
6481</pre></div></div>
6482</li>
6483</ul></div>
6484<div class="section">
6485<h3><a name="interval_starts.2C_interval_started_by"></a>interval_starts, interval_started_by</h3>
6486<ul>
6487
6488<li>
6489
6490<p>Syntax:</p>
6491
6492<div>
6493<div>
6494<pre class="source">interval_starts(interval1, interval2)
6495interval_started_by(interval1, interval2)
6496</pre></div></div>
6497</li>
6498<li>
6499
6500<p>These two functions check whether one interval starts with the other interval.</p>
6501</li>
6502<li>Arguments:
6503<ul>
6504
6505<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6506</ul>
6507</li>
6508<li>Return Value:
6509<ul>
6510
6511<li>a <tt>boolean</tt> value. Specifically, <tt>interval_starts(interval1, interval2)</tt> returns true if and only if
6512<p>interval1.start = interval2.start AND interval1.end &lt;= interval2.end</p></li>
6513</ul>
6514<p><tt>interval_started_by(interval1, interval2)</tt> returns true if and only if</p>
6515
6516<div>
6517<div>
6518<pre class="source">interval1.start = interval2.start
6519AND interval2.end &lt;= interval1.end
6520</pre></div></div>
6521
6522<ul>
6523
6524<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6525<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6526<li>any other non-interval input value will cause a type error.</li>
6527</ul>
6528</li>
6529<li>
6530
6531<p>Examples:</p>
6532
6533<div>
6534<div>
6535<pre class="source">{
6536 &quot;interval_starts&quot;: interval_starts(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6537 interval(date(&quot;2000-01-01&quot;), date(&quot;2012-09-09&quot;))),
6538 &quot;interval_started_by&quot;: interval_started_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6539 interval(date(&quot;2006-08-01&quot;), date(&quot;2006-08-02&quot;)))
6540};
6541</pre></div></div>
6542</li>
6543<li>
6544
6545<p>The expected result is:</p>
6546
6547<div>
6548<div>
6549<pre class="source">{ &quot;interval_starts&quot;: true, &quot;interval_started_by&quot;: true }
6550</pre></div></div>
6551</li>
6552</ul></div>
6553<div class="section">
6554<h3><a name="interval_ends.2C_interval_ended_by"></a>interval_ends, interval_ended_by</h3>
6555<ul>
6556
6557<li>
6558
6559<p>Syntax:</p>
6560
6561<div>
6562<div>
6563<pre class="source">interval_ends(interval1, interval2)
6564interval_ended_by(interval1, interval2)
6565</pre></div></div>
6566</li>
6567<li>
6568
6569<p>These two functions check whether one interval ends with the other interval.</p>
6570</li>
6571<li>Arguments:
6572<ul>
6573
6574<li><tt>interval1</tt>, <tt>interval2</tt>: two intervals to be compared</li>
6575</ul>
6576</li>
6577<li>Return Value:
6578<ul>
6579
6580<li>
6581
6582<p>a <tt>boolean</tt> value. Specifically, <tt>interval_ends(interval1, interval2)</tt> returns true if and only if</p>
6583<p>interval1.end = interval2.end AND interval1.start &gt;= interval2.start</p>
6584<p><tt>interval_ended_by(interval1, interval2)</tt> returns true if and only if</p>
6585<p>interval2.end = interval1.end AND interval2.start &gt;= interval1.start</p>
6586</li>
6587<li>
6588
6589<p><tt>missing</tt> if the argument is a <tt>missing</tt> value,</p>
6590</li>
6591<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6592<li>any other non-interval input value will cause a type error.</li>
6593</ul>
6594</li>
6595<li>
6596
6597<p>Examples:</p>
6598
6599<div>
6600<div>
6601<pre class="source">{
6602 &quot;interval_ends&quot;: interval_ends(interval(date(&quot;2000-01-01&quot;), date(&quot;2005-01-01&quot;)),
6603 interval(date(&quot;1998-01-01&quot;), date(&quot;2005-01-01&quot;))),
6604 &quot;interval_ended_by&quot;: interval_ended_by(interval(date(&quot;2006-08-01&quot;), date(&quot;2007-03-01&quot;)),
6605 interval(date(&quot;2006-09-10&quot;), date(&quot;2007-03-01&quot;)))
6606};
6607</pre></div></div>
6608</li>
6609<li>
6610
6611<p>The expected result is:</p>
6612
6613<div>
6614<div>
6615<pre class="source">{ &quot;interval_ends&quot;: true, &quot;interval_ended_by&quot;: true }
6616</pre></div></div>
6617</li>
6618</ul><!--
6619 ! Licensed to the Apache Software Foundation (ASF) under one
6620 ! or more contributor license agreements. See the NOTICE file
6621 ! distributed with this work for additional information
6622 ! regarding copyright ownership. The ASF licenses this file
6623 ! to you under the Apache License, Version 2.0 (the
6624 ! "License"); you may not use this file except in compliance
6625 ! with the License. You may obtain a copy of the License at
6626 !
6627 ! http://www.apache.org/licenses/LICENSE-2.0
6628 !
6629 ! Unless required by applicable law or agreed to in writing,
6630 ! software distributed under the License is distributed on an
6631 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
6632 ! KIND, either express or implied. See the License for the
6633 ! specific language governing permissions and limitations
6634 ! under the License.
6635 !-->
6636</div></div>
6637<div class="section">
6638<h2><a name="Object_Functions"></a><a name="ObjectFunctions" id="ObjectFunctions">Object Functions</a></h2>
6639<div class="section">
6640<h3><a name="get_object_fields"></a>get_object_fields</h3>
6641<ul>
6642
6643<li>
6644
6645<p>Syntax:</p>
6646
6647<div>
6648<div>
6649<pre class="source">get_object_fields(input_object)
6650</pre></div></div>
6651</li>
6652<li>
6653
6654<p>Access the object field names, type and open status for a given object.</p>
6655</li>
6656<li>Arguments:
6657<ul>
6658
6659<li><tt>input_object</tt> : a object value.</li>
6660</ul>
6661</li>
6662<li>Return Value:
6663<ul>
6664
6665<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>
6666<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
6667<li><tt>null</tt> if the argument is a <tt>null</tt> value,</li>
6668<li>any other non-object input value will cause a type error.</li>
6669</ul>
6670</li>
6671<li>
6672
6673<p>Example:</p>
6674
6675<div>
6676<div>
6677<pre class="source">get_object_fields(
6678 {
6679 &quot;id&quot;: 1,
6680 &quot;project&quot;: &quot;AsterixDB&quot;,
6681 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6682 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6683 }
6684 );
6685</pre></div></div>
6686</li>
6687<li>
6688
6689<p>The expected result is:</p>
6690
6691<div>
6692<div>
6693<pre class="source">[
6694 { &quot;field-name&quot;: &quot;id&quot;, &quot;field-type&quot;: &quot;INT64&quot;, &quot;is-open&quot;: false },
6695 { &quot;field-name&quot;: &quot;project&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6696 { &quot;field-name&quot;: &quot;address&quot;, &quot;field-type&quot;: &quot;RECORD&quot;, &quot;is-open&quot;: false,
6697 &quot;nested&quot;: [
6698 { &quot;field-name&quot;: &quot;city&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false },
6699 { &quot;field-name&quot;: &quot;state&quot;, &quot;field-type&quot;: &quot;STRING&quot;, &quot;is-open&quot;: false }
6700 ]
6701 },
6702 { &quot;field-name&quot;:
6703 &quot;related&quot;,
6704 &quot;field-type&quot;: &quot;ORDEREDLIST&quot;,
6705 &quot;is-open&quot;: false,
6706 &quot;list&quot;: [
6707 { &quot;field-type&quot;: &quot;STRING&quot; },
6708 { &quot;field-type&quot;: &quot;STRING&quot; },
6709 { &quot;field-type&quot;: &quot;STRING&quot; }
6710 ]
6711 }
6712]
6713</pre></div></div>
6714</li>
6715</ul>
6716<p>]</p></div>
6717<div class="section">
6718<h3><a name="get_object_field_value"></a>get_object_field_value</h3>
6719<ul>
6720
6721<li>
6722
6723<p>Syntax:</p>
6724
6725<div>
6726<div>
6727<pre class="source">get_object_field_value(input_object, string)
6728</pre></div></div>
6729</li>
6730<li>
6731
6732<p>Access the field name given in the <tt>string_expression</tt> from the <tt>object_expression</tt>.</p>
6733</li>
6734<li>Arguments:
6735<ul>
6736
6737<li><tt>input_object</tt> : a <tt>object</tt> value.</li>
6738<li><tt>string</tt> : a <tt>string</tt> representing the top level field name.</li>
6739</ul>
6740</li>
6741<li>Return Value:
6742<ul>
6743
6744<li>an <tt>any</tt> value saved in the designated field of the object,</li>
6745<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6746<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6747<li>a type error will be raised if:
6748<ul>
6749
6750<li>the first argument is any other non-object value,</li>
6751<li>or, the second argument is any other non-string value.</li>
6752</ul>
6753</li>
6754</ul>
6755</li>
6756<li>
6757
6758<p>Example:</p>
6759
6760<div>
6761<div>
6762<pre class="source">get_object_field_value({
6763 &quot;id&quot;: 1,
6764 &quot;project&quot;: &quot;AsterixDB&quot;,
6765 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
6766 &quot;related&quot;: [&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6767 },
6768 &quot;project&quot;
6769 );
6770</pre></div></div>
6771</li>
6772<li>
6773
6774<p>The expected result is:</p>
6775
6776<div>
6777<div>
6778<pre class="source">&quot;AsterixDB&quot;
6779</pre></div></div>
6780</li>
6781</ul></div>
6782<div class="section">
6783<h3><a name="object_remove_fields"></a>object_remove_fields</h3>
6784<ul>
6785
6786<li>
6787
6788<p>Syntax:</p>
6789
6790<div>
6791<div>
6792<pre class="source">object_remove_fields(input_object, field_names)
6793</pre></div></div>
6794</li>
6795<li>
6796
6797<p>Remove indicated fields from a object given a list of field names.</p>
6798</li>
6799<li>Arguments:
6800<ul>
6801
6802<li><tt>input_object</tt>: a object value.</li>
6803<li><tt>field_names</tt>: an array of strings and/or array of array of strings.</li>
6804</ul>
6805</li>
6806<li>
6807
6808<p>Return Value:</p>
6809<ul>
6810
6811<li>a new object value without the fields listed in the second argument,</li>
6812<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6813<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6814<li>a type error will be raised if:
6815<ul>
6816
6817<li>the first argument is any other non-object value,</li>
6818<li>or, the second argument is any other non-array value or recursively contains non-string items.</li>
6819</ul>
6820</li>
6821</ul>
6822</li>
6823<li>
6824
6825<p>Example:</p>
6826
6827<div>
6828<div>
6829<pre class="source">object_remove_fields(
6830 {
6831 &quot;id&quot;:1,
6832 &quot;project&quot;:&quot;AsterixDB&quot;,
6833 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6834 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6835 },
6836 [[&quot;address&quot;, &quot;city&quot;], &quot;related&quot;]
6837 );
6838</pre></div></div>
6839</li>
6840<li>
6841
6842<p>The expected result is:</p>
6843
6844<div>
6845<div>
6846<pre class="source">{
6847 &quot;id&quot;:1,
6848 &quot;project&quot;:&quot;AsterixDB&quot;,
6849 &quot;address&quot;:{ &quot;state&quot;: &quot;CA&quot; }
6850}
6851</pre></div></div>
6852</li>
6853</ul></div>
6854<div class="section">
6855<h3><a name="object_add_fields"></a>object_add_fields</h3>
6856<ul>
6857
6858<li>
6859
6860<p>Syntax:</p>
6861
6862<div>
6863<div>
6864<pre class="source">object_add_fields(input_object, fields)
6865</pre></div></div>
6866</li>
6867<li>
6868
6869<p>Add fields to a object given a list of field names.</p>
6870</li>
6871<li>Arguments:
6872<ul>
6873
6874<li><tt>input_object</tt> : a object value.</li>
6875<li><tt>fields</tt>: an array of field descriptor objects where each object has field_name and field_value.</li>
6876</ul>
6877</li>
6878<li>Return Value:
6879<ul>
6880
6881<li>a new object value with the new fields included,</li>
6882<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6883<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6884<li>a type error will be raised if:
6885<ul>
6886
6887<li>the first argument is any other non-object value,</li>
6888<li>the second argument is any other non-array value, or contains non-object items.</li>
6889</ul>
6890</li>
6891</ul>
6892</li>
6893<li>
6894
6895<p>Example:</p>
6896
6897<div>
6898<div>
6899<pre class="source">object_add_fields(
6900 {
6901 &quot;id&quot;:1,
6902 &quot;project&quot;:&quot;AsterixDB&quot;,
6903 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6904 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6905 },
6906 [{&quot;field-name&quot;:&quot;employment_location&quot;, &quot;field-value&quot;:create_point(30.0,70.0)}]
6907 );
6908</pre></div></div>
6909</li>
6910<li>
6911
6912<p>The expected result is:</p>
6913
6914<div>
6915<div>
6916<pre class="source">{
6917 &quot;id&quot;:1,
6918 &quot;project&quot;:&quot;AsterixDB&quot;,
6919 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6920 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6921 &quot;employment_location&quot;: point(&quot;30.0,70.0&quot;)
6922 }
6923</pre></div></div>
6924</li>
6925</ul></div>
6926<div class="section">
6927<h3><a name="object_merge"></a>object_merge</h3>
6928<ul>
6929
6930<li>
6931
6932<p>Syntax:</p>
6933
6934<div>
6935<div>
6936<pre class="source">object_merge(object1, object2)
6937</pre></div></div>
6938</li>
6939<li>
6940
6941<p>Merge two different objects into a new object.</p>
6942</li>
6943<li>Arguments:
6944<ul>
6945
6946<li><tt>object1</tt> : a object value.</li>
6947<li><tt>object2</tt> : a object value.</li>
6948</ul>
6949</li>
6950<li>Return Value:
6951<ul>
6952
6953<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>
6954<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
6955<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
6956<li>any other non-object input value will cause a type error.</li>
6957</ul>
6958</li>
6959<li>
6960
6961<p>Example:</p>
6962
6963<div>
6964<div>
6965<pre class="source">object_merge(
6966 {
6967 &quot;id&quot;:1,
6968 &quot;project&quot;:&quot;AsterixDB&quot;,
6969 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
6970 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
6971 },
6972 {
6973 &quot;user_id&quot;: 22,
6974 &quot;employer&quot;: &quot;UC Irvine&quot;,
6975 &quot;employment_type&quot;: &quot;visitor&quot;
6976 }
6977 );
6978</pre></div></div>
6979</li>
6980<li>
6981
6982<p>The expected result is:</p>
6983
6984<div>
6985<div>
6986<pre class="source">{
6987 &quot;employment_type&quot;: &quot;visitor&quot;,
6988 &quot;address&quot;: {
6989 &quot;city&quot;: &quot;Irvine&quot;,
6990 &quot;state&quot;: &quot;CA&quot;
6991 },
6992 &quot;related&quot;: [
6993 &quot;Hivestrix&quot;,
6994 &quot;Preglix&quot;,
6995 &quot;Apache VXQuery&quot;
6996 ],
6997 &quot;user_id&quot;: 22,
6998 &quot;project&quot;: &quot;AsterixDB&quot;,
6999 &quot;employer&quot;: &quot;UC Irvine&quot;,
7000 &quot;id&quot;: 1
7001}
7002</pre></div></div>
7003</li>
7004</ul></div>
7005<div class="section">
7006<h3><a name="object_length"></a>object_length</h3>
7007<ul>
7008
7009<li>
7010
7011<p>Syntax:</p>
7012
7013<div>
7014<div>
7015<pre class="source">object_length(input_object)
7016</pre></div></div>
7017</li>
7018<li>
7019
7020<p>Returns number of top-level fields in the given object</p>
7021</li>
7022<li>Arguments:
7023<ul>
7024
7025<li><tt>input_object</tt> : an object value.</li>
7026</ul>
7027</li>
7028<li>Return Value:
7029<ul>
7030
7031<li>an integer that represents the number of top-level fields in the given object,</li>
7032<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7033<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7034</ul>
7035</li>
7036<li>
7037
7038<p>Example:</p>
7039
7040<div>
7041<div>
7042<pre class="source">object_length(
7043 {
7044 &quot;id&quot;: 1,
7045 &quot;project&quot;: &quot;AsterixDB&quot;,
7046 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7047 }
7048 );
7049</pre></div></div>
7050</li>
7051<li>
7052
7053<p>The expected result is:</p>
7054
7055<div>
7056<div>
7057<pre class="source">3
7058</pre></div></div>
7059</li>
7060</ul></div>
7061<div class="section">
7062<h3><a name="object_names"></a>object_names</h3>
7063<ul>
7064
7065<li>
7066
7067<p>Syntax:</p>
7068
7069<div>
7070<div>
7071<pre class="source">object_names(input_object)
7072</pre></div></div>
7073</li>
7074<li>
7075
7076<p>Returns names of top-level fields in the given object</p>
7077</li>
7078<li>Arguments:
7079<ul>
7080
7081<li><tt>input_object</tt> : an object value.</li>
7082</ul>
7083</li>
7084<li>Return Value:
7085<ul>
7086
7087<li>an array with top-level field names of the given object,</li>
7088<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
7089<li><tt>null</tt> if the argument is a <tt>null</tt> value or any other non-object value</li>
7090</ul>
7091</li>
7092<li>
7093
7094<p>Example:</p>
7095
7096<div>
7097<div>
7098<pre class="source">object_names(
7099 {
7100 &quot;id&quot;: 1,
7101 &quot;project&quot;: &quot;AsterixDB&quot;,
7102 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7103 }
7104 );
7105</pre></div></div>
7106</li>
7107<li>
7108
7109<p>The expected result is:</p>
7110
7111<div>
7112<div>
7113<pre class="source">[ &quot;id&quot;, &quot;project&quot;, &quot;address&quot; ]
7114</pre></div></div>
7115</li>
7116</ul></div>
7117<div class="section">
7118<h3><a name="object_remove"></a>object_remove</h3>
7119<ul>
7120
7121<li>
7122
7123<p>Syntax:</p>
7124
7125<div>
7126<div>
7127<pre class="source">object_remove(input_object, field_name)
7128</pre></div></div>
7129</li>
7130<li>
7131
7132<p>Returns a new object that has the same fields as the input object except the field to be removed</p>
7133</li>
7134<li>Arguments:
7135<ul>
7136
7137<li><tt>input_object</tt> : an object value.</li>
7138<li><tt>field_name</tt> : a string field name.</li>
7139</ul>
7140</li>
7141<li>Return Value:
7142<ul>
7143
7144<li>A new object that has the same fields as <tt>input_object</tt> except the field <tt>field_name</tt>,</li>
7145<li><tt>missing</tt> if the argument <tt>input_object</tt> or <tt>field_name</tt> is missing,</li>
7146<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>
7147</ul>
7148</li>
7149<li>
7150
7151<p>Example:</p>
7152
7153<div>
7154<div>
7155<pre class="source">object_remove(
7156 {
7157 &quot;id&quot;: 1,
7158 &quot;project&quot;: &quot;AsterixDB&quot;,
7159 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7160 }
7161 , &quot;address&quot;
7162 );
7163</pre></div></div>
7164</li>
7165<li>
7166
7167<p>The expected result is:</p>
7168
7169<div>
7170<div>
7171<pre class="source">{
7172 &quot;id&quot;: 1,
7173 &quot;project&quot;: &quot;AsterixDB&quot;,
7174}
7175</pre></div></div>
7176</li>
7177</ul></div>
7178<div class="section">
7179<h3><a name="object_rename"></a>object_rename</h3>
7180<ul>
7181
7182<li>
7183
7184<p>Syntax:</p>
7185
7186<div>
7187<div>
7188<pre class="source">object_rename(input_object, old_field, new_field)
7189</pre></div></div>
7190</li>
7191<li>
7192
7193<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>
7194</li>
7195<li>Arguments:
7196<ul>
7197
7198<li><tt>input_object</tt> : an object value.</li>
7199<li><tt>old_field</tt> : a string representing the old (original) field name inside the object <tt>input_object</tt>.</li>
7200<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>
7201</ul>
7202</li>
7203<li>Return Value:
7204<ul>
7205
7206<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>
7207<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7208<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>
7209</ul>
7210</li>
7211<li>
7212
7213<p>Example:</p>
7214
7215<div>
7216<div>
7217<pre class="source">object_rename(
7218 {
7219 &quot;id&quot;: 1,
7220 &quot;project&quot;: &quot;AsterixDB&quot;,
7221 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7222 }
7223 , &quot;address&quot;
7224 , &quot;location&quot;
7225 );
7226</pre></div></div>
7227</li>
7228<li>
7229
7230<p>The expected result is:</p>
7231
7232<div>
7233<div>
7234<pre class="source">{
7235 &quot;id&quot;: 1,
7236 &quot;project&quot;: &quot;AsterixDB&quot;,
7237 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7238}
7239</pre></div></div>
7240</li>
7241</ul></div>
7242<div class="section">
7243<h3><a name="object_unwrap"></a>object_unwrap</h3>
7244<ul>
7245
7246<li>
7247
7248<p>Syntax:</p>
7249
7250<div>
7251<div>
7252<pre class="source">object_unwrap(input_object)
7253</pre></div></div>
7254</li>
7255<li>
7256
7257<p>Returns the value of the single name-value pair that appears in <tt>input_object</tt>.</p>
7258</li>
7259<li>Arguments:
7260<ul>
7261
7262<li><tt>input_object</tt> : an object value that consists of exactly one name-value pair.</li>
7263</ul>
7264</li>
7265<li>Return Value:
7266<ul>
7267
7268<li>The value of the single name-value pair that appears in <tt>input_object</tt>,</li>
7269<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7270<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>
7271</ul>
7272</li>
7273<li>
7274
7275<p>Example:</p>
7276
7277<div>
7278<div>
7279<pre class="source">object_unwrap(
7280 {
7281 &quot;id&quot;: 1
7282 }
7283 );
7284</pre></div></div>
7285</li>
7286<li>
7287
7288<p>The expected result is:</p>
7289
7290<div>
7291<div>
7292<pre class="source">{
7293 1
7294}
7295</pre></div></div>
7296</li>
7297</ul></div>
7298<div class="section">
7299<h3><a name="object_replace"></a>object_replace</h3>
7300<ul>
7301
7302<li>
7303
7304<p>Syntax:</p>
7305
7306<div>
7307<div>
7308<pre class="source">object_replace(input_object, old_value, new_value)
7309</pre></div></div>
7310</li>
7311<li>
7312
7313<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>
7314</li>
7315<li>Arguments:
7316<ul>
7317
7318<li><tt>input_object</tt> : an object value.</li>
7319<li><tt>old_value</tt> : a primitive type value to be replaced by <tt>new_value</tt>.</li>
7320<li><tt>new_value</tt> : a value to replace <tt>old_value</tt>.</li>
7321</ul>
7322</li>
7323<li>Return Value:
7324<ul>
7325
7326<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>
7327<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
7328<li><tt>null</tt> if <tt>input_object</tt> or <tt>old_value</tt> is null,</li>
7329<li>a type error will be raised if:
7330<ul>
7331
7332<li><tt>old_value</tt> is not a primitive type value.</li>
7333</ul>
7334</li>
7335</ul>
7336</li>
7337<li>
7338
7339<p>Example:</p>
7340
7341<div>
7342<div>
7343<pre class="source">object_replace(
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;AsterixDB&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_add"></a>object_add</h3>
7370<ul>
7371
7372<li>
7373
7374<p>Syntax:</p>
7375
7376<div>
7377<div>
7378<pre class="source">object_add(input_object, field_name, field_value)
7379</pre></div></div>
7380</li>
7381<li>
7382
7383<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>
7384</li>
7385<li>Arguments:
7386<ul>
7387
7388<li><tt>input_object</tt> : an object value.</li>
7389<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7390<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7391</ul>
7392</li>
7393<li>Return Value:
7394<ul>
7395
7396<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>
7397<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7398<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>
7399<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>
7400</ul>
7401</li>
7402<li>
7403
7404<p>Example:</p>
7405
7406<div>
7407<div>
7408<pre class="source">object_add(
7409 {
7410 &quot;id&quot;: 1,
7411 &quot;project&quot;: &quot;AsterixDB&quot;,
7412 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7413 }
7414 , &quot;company&quot;
7415 , &quot;Apache&quot;
7416 );
7417</pre></div></div>
7418</li>
7419<li>
7420
7421<p>The expected result is:</p>
7422
7423<div>
7424<div>
7425<pre class="source">{
7426 &quot;id&quot;: 1,
7427 &quot;project&quot;: &quot;AsterixDB&quot;,
7428 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;},
7429 &quot;company&quot;: &quot;Apache&quot;
7430}
7431</pre></div></div>
7432</li>
7433</ul></div>
7434<div class="section">
7435<h3><a name="object_put"></a>object_put</h3>
7436<ul>
7437
7438<li>
7439
7440<p>Syntax:</p>
7441
7442<div>
7443<div>
7444<pre class="source">object_put(input_object, field_name, field_value)
7445</pre></div></div>
7446</li>
7447<li>
7448
7449<p>Adds, modifies, or removes a field of an object.</p>
7450</li>
7451<li>Arguments:
7452<ul>
7453
7454<li><tt>input_object</tt> : an object value.</li>
7455<li><tt>field_name</tt> : a string representing a field name to be added.</li>
7456<li><tt>field_value</tt> : a value to be assigned to the new field <tt>field_name</tt>.</li>
7457</ul>
7458</li>
7459<li>Return Value:
7460<ul>
7461
7462<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>
7463<li><tt>missing</tt> if <tt>input_object</tt> or <tt>field_name</tt> is <tt>missing</tt>,</li>
7464<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>
7465</ul>
7466</li>
7467<li>
7468
7469<p>Example:</p>
7470
7471<div>
7472<div>
7473<pre class="source">object_put(
7474 {
7475 &quot;id&quot;: 1,
7476 &quot;project&quot;: &quot;AsterixDB&quot;,
7477 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7478 }
7479 , &quot;project&quot;
7480 , &quot;Apache AsterixDB&quot;
7481 );
7482</pre></div></div>
7483</li>
7484<li>
7485
7486<p>The expected result is:</p>
7487
7488<div>
7489<div>
7490<pre class="source">{
7491 &quot;id&quot;: 1,
7492 &quot;project&quot;: &quot;Apache AsterixDB&quot;,
7493 &quot;location&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7494}
7495</pre></div></div>
7496</li>
7497</ul></div>
7498<div class="section">
7499<h3><a name="object_values"></a>object_values</h3>
7500<ul>
7501
7502<li>
7503
7504<p>Syntax:</p>
7505
7506<div>
7507<div>
7508<pre class="source">object_values(input_object)
7509</pre></div></div>
7510</li>
7511<li>
7512
7513<p>Returns an array of the values of the fields in <tt>input_object</tt>.</p>
7514</li>
7515<li>Arguments:
7516<ul>
7517
7518<li><tt>input_object</tt> : an object value.</li>
7519</ul>
7520</li>
7521<li>Return Value:
7522<ul>
7523
7524<li>An array of the values of the fields in <tt>input_object</tt>,</li>
7525<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7526<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7527</ul>
7528</li>
7529<li>
7530
7531<p>Example:</p>
7532
7533<div>
7534<div>
7535<pre class="source">object_values(
7536 {
7537 &quot;id&quot;: 1,
7538 &quot;project&quot;: &quot;AsterixDB&quot;,
7539 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7540 }
7541 );
7542</pre></div></div>
7543</li>
7544<li>
7545
7546<p>The expected result is:</p>
7547
7548<div>
7549<div>
7550<pre class="source">[
7551 1,
7552 &quot;AsterixDB&quot;,
7553 {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7554]
7555</pre></div></div>
7556</li>
7557</ul></div>
7558<div class="section">
7559<h3><a name="object_pairs"></a>object_pairs</h3>
7560<ul>
7561
7562<li>
7563
7564<p>Syntax:</p>
7565
7566<div>
7567<div>
7568<pre class="source">object_pairs(input_object)
7569</pre></div></div>
7570</li>
7571<li>
7572
7573<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>
7574</li>
7575<li>
7576
7577<p>Arguments:</p>
7578<ul>
7579
7580<li><tt>input_object</tt> : an object value.</li>
7581</ul>
7582</li>
7583<li>Return Value:
7584<ul>
7585
7586<li>An array of the <tt>name</tt>/<tt>value</tt> pairs of the fields in <tt>input_object</tt>,</li>
7587<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7588<li><tt>null</tt> if <tt>input_object</tt> is null or any non-object value.</li>
7589</ul>
7590</li>
7591<li>
7592
7593<p>Example:</p>
7594
7595<div>
7596<div>
7597<pre class="source">object_pairs(
7598 {
7599 &quot;id&quot;: 1,
7600 &quot;project&quot;: &quot;AsterixDB&quot;,
7601 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7602 }
7603 );
7604</pre></div></div>
7605</li>
7606<li>
7607
7608<p>The expected result is:</p>
7609
7610<div>
7611<div>
7612<pre class="source">[
7613 { &quot;name&quot;: &quot;id&quot;, &quot;value&quot;: 1 },
7614 { &quot;name&quot;: &quot;project&quot;, &quot;value&quot;: &quot;AsterixDB&quot; },
7615 { &quot;name&quot;: &quot;address&quot;, &quot;value&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;} }
7616]
7617</pre></div></div>
7618</li>
7619</ul></div>
7620<div class="section">
7621<h3><a name="pairs"></a>pairs</h3>
7622<ul>
7623
7624<li>
7625
7626<p>Syntax:</p>
7627
7628<div>
7629<div>
7630<pre class="source">pairs(input_object)
7631</pre></div></div>
7632</li>
7633<li>
7634
7635<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>
7636</li>
7637<li>
7638
7639<p>Arguments:</p>
7640<ul>
7641
7642<li><tt>input_object</tt> : an object value (or an array or a multiset)</li>
7643</ul>
7644</li>
7645<li>Return Value:
7646<ul>
7647
7648<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>
7649<li><tt>missing</tt> if <tt>input_object</tt> is <tt>missing</tt>,</li>
7650<li><tt>null</tt> if <tt>input_object</tt> is null or a value of a primitive data type.</li>
7651</ul>
7652</li>
7653<li>
7654
7655<p>Example:</p>
7656
7657<div>
7658<div>
7659<pre class="source">pairs(
7660 {
7661 &quot;id&quot;: 1,
7662 &quot;project&quot;: &quot;AsterixDB&quot;,
7663 &quot;address&quot;: {&quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot;}
7664 }
7665 );
7666</pre></div></div>
7667</li>
7668<li>
7669
7670<p>The expected result is:</p>
7671
7672<div>
7673<div>
7674<pre class="source">[
7675 [ &quot;id&quot;, 1 ],
7676 [ &quot;project&quot;, &quot;AsterixDB&quot; ],
7677 [ &quot;address&quot;, { &quot;city&quot;: &quot;Irvine&quot;, &quot;state&quot;: &quot;CA&quot; } ],
7678 [ &quot;city&quot;, &quot;Irvine&quot; ],
7679 [ &quot;state&quot;, &quot;CA&quot; ]
7680]
7681</pre></div></div>
7682</li>
7683</ul><!--
7684 ! Licensed to the Apache Software Foundation (ASF) under one
7685 ! or more contributor license agreements. See the NOTICE file
7686 ! distributed with this work for additional information
7687 ! regarding copyright ownership. The ASF licenses this file
7688 ! to you under the Apache License, Version 2.0 (the
7689 ! "License"); you may not use this file except in compliance
7690 ! with the License. You may obtain a copy of the License at
7691 !
7692 ! http://www.apache.org/licenses/LICENSE-2.0
7693 !
7694 ! Unless required by applicable law or agreed to in writing,
7695 ! software distributed under the License is distributed on an
7696 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7697 ! KIND, either express or implied. See the License for the
7698 ! specific language governing permissions and limitations
7699 ! under the License.
7700 !-->
7701</div></div>
7702<div class="section">
7703<h2><a name="Aggregate_Functions_.28Array_Functions.29"></a><a name="AggregateFunctions" id="AggregateFunctions">Aggregate Functions (Array Functions) </a></h2>
7704<p>This section contains detailed descriptions of the built-in aggregate functions in the query language.</p>
7705<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>
7706<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>
7707<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>
7708<div class="section">
7709<h3><a name="array_count"></a>array_count</h3>
7710<ul>
7711
7712<li>
7713
7714<p>Syntax:</p>
7715
7716<div>
7717<div>
7718<pre class="source">array_count(collection)
7719</pre></div></div>
7720</li>
7721<li>
7722
7723<p>Gets the number of non-null and non-missing items in the given collection.</p>
7724</li>
7725<li>Arguments:
7726<ul>
7727
7728<li><tt>collection</tt> could be:
7729<ul>
7730
7731<li>an <tt>array</tt> or <tt>multiset</tt> to be counted,</li>
7732<li>or, a <tt>null</tt> value,</li>
7733<li>or, a <tt>missing</tt> value.</li>
7734</ul>
7735</li>
7736</ul>
7737</li>
7738<li>Return Value:
7739<ul>
7740
7741<li>a <tt>bigint</tt> value representing the number of non-null and non-missing items in the given collection,</li>
7742<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7743<li>any other non-array and non-multiset input value will cause an error.</li>
7744</ul>
7745</li>
7746<li>
7747
7748<p>Example:</p>
7749
7750<div>
7751<div>
7752<pre class="source">array_count( ['hello', 'world', 1, 2, 3, null, missing] );
7753</pre></div></div>
7754</li>
7755<li>
7756
7757<p>The expected result is:</p>
7758
7759<div>
7760<div>
7761<pre class="source">5
7762</pre></div></div>
7763</li>
7764</ul></div>
7765<div class="section">
7766<h3><a name="array_avg"></a>array_avg</h3>
7767<ul>
7768
7769<li>
7770
7771<p>Syntax:</p>
7772
7773<div>
7774<div>
7775<pre class="source">array_avg(num_collection)
7776</pre></div></div>
7777</li>
7778<li>
7779
7780<p>Gets the average value of the non-null and non-missing numeric items in the given collection.</p>
7781</li>
7782<li>Arguments:
7783<ul>
7784
7785<li><tt>num_collection</tt> could be:
7786<ul>
7787
7788<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7789<li>or, a <tt>null</tt> value,</li>
7790<li>or, a <tt>missing</tt> value.</li>
7791</ul>
7792</li>
7793</ul>
7794</li>
7795<li>Return Value:
7796<ul>
7797
7798<li>a <tt>double</tt> value representing the average of the non-null and non-missing numbers in the given collection,</li>
7799<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7800<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7801<li>any other non-array and non-multiset input value will cause a type error,</li>
7802<li>any other non-numeric value in the input collection will cause a type error.</li>
7803</ul>
7804</li>
7805<li>
7806
7807<p>Example:</p>
7808
7809<div>
7810<div>
7811<pre class="source">array_avg( [1.2, 2.3, 3.4, 0, null] );
7812</pre></div></div>
7813</li>
7814<li>
7815
7816<p>The expected result is:</p>
7817
7818<div>
7819<div>
7820<pre class="source">1.725
7821</pre></div></div>
7822</li>
7823</ul></div>
7824<div class="section">
7825<h3><a name="array_sum"></a>array_sum</h3>
7826<ul>
7827
7828<li>
7829
7830<p>Syntax:</p>
7831
7832<div>
7833<div>
7834<pre class="source">array_sum(num_collection)
7835</pre></div></div>
7836</li>
7837<li>
7838
7839<p>Gets the sum of non-null and non-missing items in the given collection.</p>
7840</li>
7841<li>Arguments:
7842<ul>
7843
7844<li><tt>num_collection</tt> could be:
7845<ul>
7846
7847<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
7848<li>or, a <tt>null</tt> value,</li>
7849<li>or, a <tt>missing</tt> value.</li>
7850</ul>
7851</li>
7852</ul>
7853</li>
7854<li>Return Value:
7855<ul>
7856
7857<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>
7858<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7859<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7860<li>any other non-array and non-multiset input value will cause a type error,</li>
7861<li>any other non-numeric value in the input collection will cause a type error.</li>
7862</ul>
7863</li>
7864<li>
7865
7866<p>Example:</p>
7867
7868<div>
7869<div>
7870<pre class="source">array_sum( [1.2, 2.3, 3.4, 0, null, missing] );
7871</pre></div></div>
7872</li>
7873<li>
7874
7875<p>The expected result is:</p>
7876
7877<div>
7878<div>
7879<pre class="source">6.9
7880</pre></div></div>
7881</li>
7882</ul></div>
7883<div class="section">
7884<h3><a name="array_min"></a>array_min</h3>
7885<ul>
7886
7887<li>
7888
7889<p>Syntax:</p>
7890
7891<div>
7892<div>
7893<pre class="source">array_min(num_collection)
7894</pre></div></div>
7895</li>
7896<li>
7897
7898<p>Gets the min value of non-null and non-missing comparable items in the given collection.</p>
7899</li>
7900<li>Arguments:
7901<ul>
7902
7903<li><tt>num_collection</tt> could be:
7904<ul>
7905
7906<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7907<li>or, a <tt>null</tt> value,</li>
7908<li>or, a <tt>missing</tt> value.</li>
7909</ul>
7910</li>
7911</ul>
7912</li>
7913<li>Return Value:
7914<ul>
7915
7916<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>
7917<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7918<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7919<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7920<li>any other non-array and non-multiset input value will cause a type error.</li>
7921</ul>
7922</li>
7923<li>
7924
7925<p>Example:</p>
7926
7927<div>
7928<div>
7929<pre class="source">array_min( [1.2, 2.3, 3.4, 0, null, missing] );
7930</pre></div></div>
7931</li>
7932<li>
7933
7934<p>The expected result is:</p>
7935
7936<div>
7937<div>
7938<pre class="source">0.0
7939</pre></div></div>
7940</li>
7941</ul></div>
7942<div class="section">
7943<h3><a name="array_max"></a>array_max</h3>
7944<ul>
7945
7946<li>
7947
7948<p>Syntax:</p>
7949
7950<div>
7951<div>
7952<pre class="source">array_max(num_collection)
7953</pre></div></div>
7954</li>
7955<li>
7956
7957<p>Gets the max value of the non-null and non-missing comparable items in the given collection.</p>
7958</li>
7959<li>Arguments:
7960<ul>
7961
7962<li><tt>num_collection</tt> could be:
7963<ul>
7964
7965<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
7966<li>or, a <tt>null</tt> value,</li>
7967<li>or, a <tt>missing</tt> value.</li>
7968</ul>
7969</li>
7970</ul>
7971</li>
7972<li>Return Value:
7973<ul>
7974
7975<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>
7976<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
7977<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
7978<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
7979<li>any other non-array and non-multiset input value will cause a type error.</li>
7980</ul>
7981</li>
7982<li>
7983
7984<p>Example:</p>
7985
7986<div>
7987<div>
7988<pre class="source">array_max( [1.2, 2.3, 3.4, 0, null, missing] );
7989</pre></div></div>
7990</li>
7991<li>
7992
7993<p>The expected result is:</p>
7994
7995<div>
7996<div>
7997<pre class="source">3.4
7998</pre></div></div>
7999</li>
8000</ul></div>
8001<div class="section">
8002<h3><a name="array_stddev_samp"></a>array_stddev_samp</h3>
8003<ul>
8004
8005<li>
8006
8007<p>Syntax:</p>
8008
8009<div>
8010<div>
8011<pre class="source">array_stddev_samp(num_collection)
8012</pre></div></div>
8013</li>
8014<li>
8015
8016<p>Gets the sample standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8017</li>
8018<li>Arguments:
8019<ul>
8020
8021<li><tt>num_collection</tt> could be:
8022<ul>
8023
8024<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8025<li>or, a <tt>null</tt> value,</li>
8026<li>or, a <tt>missing</tt> value.</li>
8027</ul>
8028</li>
8029</ul>
8030</li>
8031<li>Return Value:
8032<ul>
8033
8034<li>a <tt>double</tt> value representing the sample standard deviation of the non-null and non-missing numbers in the given collection,</li>
8035<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8036<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8037<li>any other non-array and non-multiset input value will cause a type error,</li>
8038<li>any other non-numeric value in the input collection will cause a type error.</li>
8039</ul>
8040</li>
8041<li>
8042
8043<p>Example:</p>
8044
8045<div>
8046<div>
8047<pre class="source">array_stddev_samp( [1.2, 2.3, 3.4, 0, null] );
8048</pre></div></div>
8049</li>
8050<li>
8051
8052<p>The expected result is:</p>
8053
8054<div>
8055<div>
8056<pre class="source">1.4591664287073858
8057</pre></div></div>
8058</li>
8059</ul></div>
8060<div class="section">
8061<h3><a name="array_stddev_pop"></a>array_stddev_pop</h3>
8062<ul>
8063
8064<li>
8065
8066<p>Syntax:</p>
8067
8068<div>
8069<div>
8070<pre class="source">array_stddev_pop(num_collection)
8071</pre></div></div>
8072</li>
8073<li>
8074
8075<p>Gets the population standard deviation value of the non-null and non-missing numeric items in the given collection.</p>
8076</li>
8077<li>Arguments:
8078<ul>
8079
8080<li><tt>num_collection</tt> could be:
8081<ul>
8082
8083<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8084<li>or, a <tt>null</tt> value,</li>
8085<li>or, a <tt>missing</tt> value.</li>
8086</ul>
8087</li>
8088</ul>
8089</li>
8090<li>Return Value:
8091<ul>
8092
8093<li>a <tt>double</tt> value representing the population standard deviation of the non-null and non-missing numbers in the given collection,</li>
8094<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8095<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8096<li>any other non-array and non-multiset input value will cause a type error,</li>
8097<li>any other non-numeric value in the input collection will cause a type error.</li>
8098</ul>
8099</li>
8100<li>
8101
8102<p>Example:</p>
8103
8104<div>
8105<div>
8106<pre class="source">array_stddev_pop( [1.2, 2.3, 3.4, 0, null] );
8107</pre></div></div>
8108</li>
8109<li>
8110
8111<p>The expected result is:</p>
8112
8113<div>
8114<div>
8115<pre class="source">1.2636751956100112
8116</pre></div></div>
8117</li>
8118</ul></div>
8119<div class="section">
8120<h3><a name="array_var_samp"></a>array_var_samp</h3>
8121<ul>
8122
8123<li>
8124
8125<p>Syntax:</p>
8126
8127<div>
8128<div>
8129<pre class="source">array_var_samp(num_collection)
8130</pre></div></div>
8131</li>
8132<li>
8133
8134<p>Gets the sample variance value of the non-null and non-missing numeric items in the given collection.</p>
8135</li>
8136<li>Arguments:
8137<ul>
8138
8139<li><tt>num_collection</tt> could be:
8140<ul>
8141
8142<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8143<li>or, a <tt>null</tt> value,</li>
8144<li>or, a <tt>missing</tt> value.</li>
8145</ul>
8146</li>
8147</ul>
8148</li>
8149<li>Return Value:
8150<ul>
8151
8152<li>a <tt>double</tt> value representing the sample variance of the non-null and non-missing numbers in the given collection,</li>
8153<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8154<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8155<li>any other non-array and non-multiset input value will cause a type error,</li>
8156<li>any other non-numeric value in the input collection will cause a type error.</li>
8157</ul>
8158</li>
8159<li>
8160
8161<p>Example:</p>
8162
8163<div>
8164<div>
8165<pre class="source">array_var_samp( [1.2, 2.3, 3.4, 0, null] );
8166</pre></div></div>
8167</li>
8168<li>
8169
8170<p>The expected result is:</p>
8171
8172<div>
8173<div>
8174<pre class="source">2.1291666666666664
8175</pre></div></div>
8176</li>
8177</ul></div>
8178<div class="section">
8179<h3><a name="array_var_pop"></a>array_var_pop</h3>
8180<ul>
8181
8182<li>
8183
8184<p>Syntax:</p>
8185
8186<div>
8187<div>
8188<pre class="source">array_var_pop(num_collection)
8189</pre></div></div>
8190</li>
8191<li>
8192
8193<p>Gets the population variance value of the non-null and non-missing numeric items in the given collection.</p>
8194</li>
8195<li>Arguments:
8196<ul>
8197
8198<li><tt>num_collection</tt> could be:
8199<ul>
8200
8201<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8202<li>or, a <tt>null</tt> value,</li>
8203<li>or, a <tt>missing</tt> value.</li>
8204</ul>
8205</li>
8206</ul>
8207</li>
8208<li>Return Value:
8209<ul>
8210
8211<li>a <tt>double</tt> value representing the population variance of the non-null and non-missing numbers in the given collection,</li>
8212<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8213<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8214<li>any other non-array and non-multiset input value will cause a type error,</li>
8215<li>any other non-numeric value in the input collection will cause a type error.</li>
8216</ul>
8217</li>
8218<li>
8219
8220<p>Example:</p>
8221
8222<div>
8223<div>
8224<pre class="source">array_var_pop( [1.2, 2.3, 3.4, 0, null] );
8225</pre></div></div>
8226</li>
8227<li>
8228
8229<p>The expected result is:</p>
8230
8231<div>
8232<div>
8233<pre class="source">1.5968749999999998
8234</pre></div></div>
8235</li>
8236</ul></div>
8237<div class="section">
8238<h3><a name="array_skewness"></a>array_skewness</h3>
8239<ul>
8240
8241<li>
8242
8243<p>Syntax:</p>
8244
8245<div>
8246<div>
8247<pre class="source">array_skewness(num_collection)
8248</pre></div></div>
8249</li>
8250<li>
8251
8252<p>Gets the skewness value of the non-null and non-missing numeric items in the given collection.</p>
8253</li>
8254<li>Arguments:
8255<ul>
8256
8257<li><tt>num_collection</tt> could be:
8258<ul>
8259
8260<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8261<li>or, a <tt>null</tt> value,</li>
8262<li>or, a <tt>missing</tt> value.</li>
8263</ul>
8264</li>
8265</ul>
8266</li>
8267<li>Return Value:
8268<ul>
8269
8270<li>a <tt>double</tt> value representing the skewness of the non-null and non-missing numbers in the given collection,</li>
8271<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8272<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8273<li>any other non-array and non-multiset input value will cause a type error,</li>
8274<li>any other non-numeric value in the input collection will cause a type error.</li>
8275</ul>
8276</li>
8277<li>
8278
8279<p>Example:</p>
8280
8281<div>
8282<div>
8283<pre class="source">array_skewness( [1.2, 2.3, 3.4, 0, null] );
8284</pre></div></div>
8285</li>
8286<li>
8287
8288<p>The expected result is:</p>
8289
8290<div>
8291<div>
8292<pre class="source">-0.04808451539164242
8293</pre></div></div>
8294</li>
8295</ul></div>
8296<div class="section">
8297<h3><a name="array_kurtosis"></a>array_kurtosis</h3>
8298<ul>
8299
8300<li>
8301
8302<p>Syntax:</p>
8303
8304<div>
8305<div>
8306<pre class="source">array_kurtosis(num_collection)
8307</pre></div></div>
8308</li>
8309<li>
8310
8311<p>Gets the kurtosis value from the normal distribution of the non-null and non-missing numeric items in the given collection.</p>
8312</li>
8313<li>Arguments:
8314<ul>
8315
8316<li><tt>num_collection</tt> could be:
8317<ul>
8318
8319<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8320<li>or, a <tt>null</tt> value,</li>
8321<li>or, a <tt>missing</tt> value.</li>
8322</ul>
8323</li>
8324</ul>
8325</li>
8326<li>Return Value:
8327<ul>
8328
8329<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>
8330<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8331<li><tt>null</tt> is returned if the given collection does not contain any non-null and non-missing items,</li>
8332<li>any other non-array and non-multiset input value will cause a type error,</li>
8333<li>any other non-numeric value in the input collection will cause a type error.</li>
8334</ul>
8335</li>
8336<li>
8337
8338<p>Example:</p>
8339
8340<div>
8341<div>
8342<pre class="source">array_kurtosis( [1.2, 2.3, 3.4, 0, null] );
8343</pre></div></div>
8344</li>
8345<li>
8346
8347<p>The expected result is:</p>
8348
8349<div>
8350<div>
8351<pre class="source">-1.342049701096427
8352</pre></div></div>
8353</li>
8354</ul></div>
8355<div class="section">
8356<h3><a name="strict_count"></a>strict_count</h3>
8357<ul>
8358
8359<li>
8360
8361<p>Syntax:</p>
8362
8363<div>
8364<div>
8365<pre class="source">strict_count(collection)
8366</pre></div></div>
8367</li>
8368<li>
8369
8370<p>Gets the number of items in the given collection.</p>
8371</li>
8372<li>Arguments:
8373<ul>
8374
8375<li><tt>collection</tt> could be:
8376<ul>
8377
8378<li>an <tt>array</tt> or <tt>multiset</tt> containing the items to be counted,</li>
8379<li>or a <tt>null</tt> value,</li>
8380<li>or a <tt>missing</tt> value.</li>
8381</ul>
8382</li>
8383</ul>
8384</li>
8385<li>Return Value:
8386<ul>
8387
8388<li>a <tt>bigint</tt> value representing the number of items in the given collection,</li>
8389<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>.</li>
8390</ul>
8391</li>
8392<li>
8393
8394<p>Example:</p>
8395
8396<div>
8397<div>
8398<pre class="source">strict_count( [1, 2, null, missing] );
8399</pre></div></div>
8400</li>
8401<li>
8402
8403<p>The expected result is:</p>
8404
8405<div>
8406<div>
8407<pre class="source">4
8408</pre></div></div>
8409</li>
8410</ul></div>
8411<div class="section">
8412<h3><a name="strict_avg"></a>strict_avg</h3>
8413<ul>
8414
8415<li>
8416
8417<p>Syntax:</p>
8418
8419<div>
8420<div>
8421<pre class="source">strict_avg(num_collection)
8422</pre></div></div>
8423</li>
8424<li>
8425
8426<p>Gets the average value of the numeric items in the given collection.</p>
8427</li>
8428<li>Arguments:
8429<ul>
8430
8431<li><tt>num_collection</tt> could be:
8432<ul>
8433
8434<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8435<li>or, a <tt>null</tt> value,</li>
8436<li>or, a <tt>missing</tt> value.</li>
8437</ul>
8438</li>
8439</ul>
8440</li>
8441<li>Return Value:
8442<ul>
8443
8444<li>a <tt>double</tt> value representing the average of the numbers in the given collection,</li>
8445<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8446<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8447<li>any other non-numeric value in the input collection will cause a type error.</li>
8448</ul>
8449</li>
8450<li>
8451
8452<p>Example:</p>
8453
8454<div>
8455<div>
8456<pre class="source">strict_avg( [100, 200, 300] );
8457</pre></div></div>
8458</li>
8459<li>
8460
8461<p>The expected result is:</p>
8462
8463<div>
8464<div>
8465<pre class="source">200.0
8466</pre></div></div>
8467</li>
8468</ul></div>
8469<div class="section">
8470<h3><a name="strict_sum"></a>strict_sum</h3>
8471<ul>
8472
8473<li>
8474
8475<p>Syntax:</p>
8476
8477<div>
8478<div>
8479<pre class="source">strict_sum(num_collection)
8480</pre></div></div>
8481</li>
8482<li>
8483
8484<p>Gets the sum of the items in the given collection.</p>
8485</li>
8486<li>Arguments:
8487<ul>
8488
8489<li><tt>num_collection</tt> could be:
8490<ul>
8491
8492<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8493<li>or, a <tt>null</tt> value,</li>
8494<li>or, a <tt>missing</tt> value.</li>
8495</ul>
8496</li>
8497</ul>
8498</li>
8499<li>Return Value:
8500<ul>
8501
8502<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>
8503<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8504<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8505<li>any other non-numeric value in the input collection will cause a type error.</li>
8506</ul>
8507</li>
8508<li>
8509
8510<p>Example:</p>
8511
8512<div>
8513<div>
8514<pre class="source">strict_sum( [100, 200, 300] );
8515</pre></div></div>
8516</li>
8517<li>
8518
8519<p>The expected result is:</p>
8520
8521<div>
8522<div>
8523<pre class="source">600
8524</pre></div></div>
8525</li>
8526</ul></div>
8527<div class="section">
8528<h3><a name="strict_min"></a>strict_min</h3>
8529<ul>
8530
8531<li>
8532
8533<p>Syntax:</p>
8534
8535<div>
8536<div>
8537<pre class="source">strict_min(num_collection)
8538</pre></div></div>
8539</li>
8540<li>
8541
8542<p>Gets the min value of comparable items in the given collection.</p>
8543</li>
8544<li>Arguments:
8545<ul>
8546
8547<li><tt>num_collection</tt> could be:
8548<ul>
8549
8550<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8551<li>or, a <tt>null</tt> value,</li>
8552<li>or, a <tt>missing</tt> value.</li>
8553</ul>
8554</li>
8555</ul>
8556</li>
8557<li>Return Value:
8558<ul>
8559
8560<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>
8561<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8562<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8563<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8564<li>any other non-array and non-multiset input value will cause a type error.</li>
8565</ul>
8566</li>
8567<li>
8568
8569<p>Example:</p>
8570
8571<div>
8572<div>
8573<pre class="source">strict_min( [10.2, 100, 5] );
8574</pre></div></div>
8575</li>
8576<li>
8577
8578<p>The expected result is:</p>
8579
8580<div>
8581<div>
8582<pre class="source">5.0
8583</pre></div></div>
8584</li>
8585</ul></div>
8586<div class="section">
8587<h3><a name="strict_max"></a>strict_max</h3>
8588<ul>
8589
8590<li>
8591
8592<p>Syntax:</p>
8593
8594<div>
8595<div>
8596<pre class="source">strict_max(num_collection)
8597</pre></div></div>
8598</li>
8599<li>
8600
8601<p>Gets the max value of numeric items in the given collection.</p>
8602</li>
8603<li>Arguments:
8604<ul>
8605
8606<li><tt>num_collection</tt> could be:
8607<ul>
8608
8609<li>an <tt>array</tt> or <tt>multiset</tt>,</li>
8610<li>or, a <tt>null</tt> value,</li>
8611<li>or, a <tt>missing</tt> value.</li>
8612</ul>
8613</li>
8614</ul>
8615</li>
8616<li>Return Value:
8617<ul>
8618
8619<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>
8620<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8621<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8622<li>multiple incomparable items in the input array or multiset will cause a type error,</li>
8623<li>any other non-array and non-multiset input value will cause a type error.</li>
8624</ul>
8625</li>
8626<li>
8627
8628<p>Example:</p>
8629
8630<div>
8631<div>
8632<pre class="source">strict_max( [10.2, 100, 5] );
8633</pre></div></div>
8634</li>
8635<li>
8636
8637<p>The expected result is:</p>
8638
8639<div>
8640<div>
8641<pre class="source">100.0
8642</pre></div></div>
8643</li>
8644</ul></div>
8645<div class="section">
8646<h3><a name="strict_stddev_samp"></a>strict_stddev_samp</h3>
8647<ul>
8648
8649<li>
8650
8651<p>Syntax:</p>
8652
8653<div>
8654<div>
8655<pre class="source">strict_stddev_samp(num_collection)
8656</pre></div></div>
8657</li>
8658<li>
8659
8660<p>Gets the sample standard deviation value of the numeric items in the given collection.</p>
8661</li>
8662<li>Arguments:
8663<ul>
8664
8665<li><tt>num_collection</tt> could be:
8666<ul>
8667
8668<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8669<li>or, a <tt>null</tt> value,</li>
8670<li>or, a <tt>missing</tt> value.</li>
8671</ul>
8672</li>
8673</ul>
8674</li>
8675<li>Return Value:
8676<ul>
8677
8678<li>a <tt>double</tt> value representing the sample standard deviation of the numbers in the given collection,</li>
8679<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8680<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8681<li>any other non-numeric value in the input collection will cause a type error.</li>
8682</ul>
8683</li>
8684<li>
8685
8686<p>Example:</p>
8687
8688<div>
8689<div>
8690<pre class="source">strict_stddev_samp( [100, 200, 300] );
8691</pre></div></div>
8692</li>
8693<li>
8694
8695<p>The expected result is:</p>
8696
8697<div>
8698<div>
8699<pre class="source">100.0
8700</pre></div></div>
8701</li>
8702</ul></div>
8703<div class="section">
8704<h3><a name="strict_stddev_pop"></a>strict_stddev_pop</h3>
8705<ul>
8706
8707<li>
8708
8709<p>Syntax:</p>
8710
8711<div>
8712<div>
8713<pre class="source">strict_stddev_pop(num_collection)
8714</pre></div></div>
8715</li>
8716<li>
8717
8718<p>Gets the population standard deviation value of the numeric items in the given collection.</p>
8719</li>
8720<li>Arguments:
8721<ul>
8722
8723<li><tt>num_collection</tt> could be:
8724<ul>
8725
8726<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8727<li>or, a <tt>null</tt> value,</li>
8728<li>or, a <tt>missing</tt> value.</li>
8729</ul>
8730</li>
8731</ul>
8732</li>
8733<li>Return Value:
8734<ul>
8735
8736<li>a <tt>double</tt> value representing the population standard deviation of the numbers in the given collection,</li>
8737<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8738<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8739<li>any other non-numeric value in the input collection will cause a type error.</li>
8740</ul>
8741</li>
8742<li>
8743
8744<p>Example:</p>
8745
8746<div>
8747<div>
8748<pre class="source">strict_stddev_pop( [100, 200, 300] );
8749</pre></div></div>
8750</li>
8751<li>
8752
8753<p>The expected result is:</p>
8754
8755<div>
8756<div>
8757<pre class="source">81.64965809277261
8758</pre></div></div>
8759</li>
8760</ul></div>
8761<div class="section">
8762<h3><a name="strict_var_samp"></a>strict_var_samp</h3>
8763<ul>
8764
8765<li>
8766
8767<p>Syntax:</p>
8768
8769<div>
8770<div>
8771<pre class="source">strict_var_samp(num_collection)
8772</pre></div></div>
8773</li>
8774<li>
8775
8776<p>Gets the sample variance value of the numeric items in the given collection.</p>
8777</li>
8778<li>Arguments:
8779<ul>
8780
8781<li><tt>num_collection</tt> could be:
8782<ul>
8783
8784<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8785<li>or, a <tt>null</tt> value,</li>
8786<li>or, a <tt>missing</tt> value.</li>
8787</ul>
8788</li>
8789</ul>
8790</li>
8791<li>Return Value:
8792<ul>
8793
8794<li>a <tt>double</tt> value representing the sample variance of the numbers in the given collection,</li>
8795<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8796<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8797<li>any other non-numeric value in the input collection will cause a type error.</li>
8798</ul>
8799</li>
8800<li>
8801
8802<p>Example:</p>
8803
8804<div>
8805<div>
8806<pre class="source">strict_var_samp( [100, 200, 300] );
8807</pre></div></div>
8808</li>
8809<li>
8810
8811<p>The expected result is:</p>
8812
8813<div>
8814<div>
8815<pre class="source">10000.0
8816</pre></div></div>
8817</li>
8818</ul></div>
8819<div class="section">
8820<h3><a name="strict_var_pop"></a>strict_var_pop</h3>
8821<ul>
8822
8823<li>
8824
8825<p>Syntax:</p>
8826
8827<div>
8828<div>
8829<pre class="source">strict_var_pop(num_collection)
8830</pre></div></div>
8831</li>
8832<li>
8833
8834<p>Gets the population variance value of the numeric items in the given collection.</p>
8835</li>
8836<li>Arguments:
8837<ul>
8838
8839<li><tt>num_collection</tt> could be:
8840<ul>
8841
8842<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8843<li>or, a <tt>null</tt> value,</li>
8844<li>or, a <tt>missing</tt> value.</li>
8845</ul>
8846</li>
8847</ul>
8848</li>
8849<li>Return Value:
8850<ul>
8851
8852<li>a <tt>double</tt> value representing the population variance of the numbers in the given collection,</li>
8853<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8854<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8855<li>any other non-numeric value in the input collection will cause a type error.</li>
8856</ul>
8857</li>
8858<li>
8859
8860<p>Example:</p>
8861
8862<div>
8863<div>
8864<pre class="source">strict_var_pop( [100, 200, 300] );
8865</pre></div></div>
8866</li>
8867<li>
8868
8869<p>The expected result is:</p>
8870
8871<div>
8872<div>
8873<pre class="source">6666.666666666667
8874</pre></div></div>
8875</li>
8876</ul></div>
8877<div class="section">
8878<h3><a name="strict_skewness"></a>strict_skewness</h3>
8879<ul>
8880
8881<li>
8882
8883<p>Syntax:</p>
8884
8885<div>
8886<div>
8887<pre class="source">strict_skewness(num_collection)
8888</pre></div></div>
8889</li>
8890<li>
8891
8892<p>Gets the skewness value of the numeric items in the given collection.</p>
8893</li>
8894<li>Arguments:
8895<ul>
8896
8897<li><tt>num_collection</tt> could be:
8898<ul>
8899
8900<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8901<li>or, a <tt>null</tt> value,</li>
8902<li>or, a <tt>missing</tt> value.</li>
8903</ul>
8904</li>
8905</ul>
8906</li>
8907<li>Return Value:
8908<ul>
8909
8910<li>a <tt>double</tt> value representing the skewness of the numbers in the given collection,</li>
8911<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8912<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8913<li>any other non-numeric value in the input collection 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">strict_skewness( [100, 200, 300] );
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">0.0
8932</pre></div></div>
8933</li>
8934</ul></div>
8935<div class="section">
8936<h3><a name="strict_kurtosis"></a>strict_kurtosis</h3>
8937<ul>
8938
8939<li>
8940
8941<p>Syntax:</p>
8942
8943<div>
8944<div>
8945<pre class="source">strict_kurtosis(num_collection)
8946</pre></div></div>
8947</li>
8948<li>
8949
8950<p>Gets the kurtosis value from the normal distribution of the numeric items in the given collection.</p>
8951</li>
8952<li>Arguments:
8953<ul>
8954
8955<li><tt>num_collection</tt> could be:
8956<ul>
8957
8958<li>an <tt>array</tt> or <tt>multiset</tt> containing numeric values, <tt>null</tt>s or <tt>missing</tt>s,</li>
8959<li>or, a <tt>null</tt> value,</li>
8960<li>or, a <tt>missing</tt> value.</li>
8961</ul>
8962</li>
8963</ul>
8964</li>
8965<li>Return Value:
8966<ul>
8967
8968<li>a <tt>double</tt> value representing the kurtosis from a normal distribution of the numbers in the given collection,</li>
8969<li><tt>null</tt> is returned if the input is <tt>null</tt> or <tt>missing</tt>,</li>
8970<li><tt>null</tt> is returned if there is a <tt>null</tt> or <tt>missing</tt> in the input collection,</li>
8971<li>any other non-numeric value in the input collection will cause a type error.</li>
8972</ul>
8973</li>
8974<li>
8975
8976<p>Example:</p>
8977
8978<div>
8979<div>
8980<pre class="source">strict_kurtosis( [100, 200, 300] );
8981</pre></div></div>
8982</li>
8983<li>
8984
8985<p>The expected result is:</p>
8986
8987<div>
8988<div>
8989<pre class="source">-1.5
8990</pre></div></div>
8991</li>
8992</ul><!--
8993 ! Licensed to the Apache Software Foundation (ASF) under one
8994 ! or more contributor license agreements. See the NOTICE file
8995 ! distributed with this work for additional information
8996 ! regarding copyright ownership. The ASF licenses this file
8997 ! to you under the Apache License, Version 2.0 (the
8998 ! "License"); you may not use this file except in compliance
8999 ! with the License. You may obtain a copy of the License at
9000 !
9001 ! http://www.apache.org/licenses/LICENSE-2.0
9002 !
9003 ! Unless required by applicable law or agreed to in writing,
9004 ! software distributed under the License is distributed on an
9005 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9006 ! KIND, either express or implied. See the License for the
9007 ! specific language governing permissions and limitations
9008 ! under the License.
9009 !-->
9010</div></div>
9011<div class="section">
9012<h2><a name="Comparison_Functions"></a><a name="ComparisonFunctions" id="ComparisonFunctions">Comparison Functions</a></h2>
9013<div class="section">
9014<h3><a name="greatest"></a>greatest</h3>
9015<ul>
9016
9017<li>
9018
9019<p>Syntax:</p>
9020
9021<div>
9022<div>
9023<pre class="source">greatest(numeric_value1, numeric_value2, ...)
9024</pre></div></div>
9025</li>
9026<li>
9027
9028<p>Computes the greatest value among arguments.</p>
9029</li>
9030<li>Arguments:
9031<ul>
9032
9033<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>
9034<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>
9035<li>&#x2026;.</li>
9036</ul>
9037</li>
9038<li>Return Value:
9039<ul>
9040
9041<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>
9042<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9043<li>any other non-numeric input value will cause a type error.</li>
9044</ul>
9045</li>
9046<li>
9047
9048<p>Example:</p>
9049
9050<div>
9051<div>
9052<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) };
9053</pre></div></div>
9054</li>
9055<li>
9056
9057<p>The expected result is:</p>
9058
9059<div>
9060<div>
9061<pre class="source">{ &quot;v1&quot;: 3, &quot;v2&quot;: 5000.0 }
9062</pre></div></div>
9063</li>
9064</ul></div>
9065<div class="section">
9066<h3><a name="least"></a>least</h3>
9067<ul>
9068
9069<li>
9070
9071<p>Syntax:</p>
9072
9073<div>
9074<div>
9075<pre class="source">least(numeric_value1, numeric_value2, ...)
9076</pre></div></div>
9077</li>
9078<li>
9079
9080<p>Computes the least value among arguments.</p>
9081</li>
9082<li>Arguments:
9083<ul>
9084
9085<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>
9086<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>
9087<li>&#x2026;.</li>
9088</ul>
9089</li>
9090<li>Return Value:
9091<ul>
9092
9093<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>
9094<li><tt>null</tt> if any argument is a <tt>missing</tt> value or <tt>null</tt> value,</li>
9095<li>any other non-numeric input value will cause a type error.</li>
9096</ul>
9097</li>
9098<li>
9099
9100<p>Example:</p>
9101
9102<div>
9103<div>
9104<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) };
9105</pre></div></div>
9106</li>
9107<li>
9108
9109<p>The expected result is:</p>
9110
9111<div>
9112<div>
9113<pre class="source">{ &quot;v1&quot;: 1, &quot;v2&quot;: -0.5 }
9114</pre></div></div>
9115</li>
9116</ul><!--
9117 ! Licensed to the Apache Software Foundation (ASF) under one
9118 ! or more contributor license agreements. See the NOTICE file
9119 ! distributed with this work for additional information
9120 ! regarding copyright ownership. The ASF licenses this file
9121 ! to you under the Apache License, Version 2.0 (the
9122 ! "License"); you may not use this file except in compliance
9123 ! with the License. You may obtain a copy of the License at
9124 !
9125 ! http://www.apache.org/licenses/LICENSE-2.0
9126 !
9127 ! Unless required by applicable law or agreed to in writing,
9128 ! software distributed under the License is distributed on an
9129 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9130 ! KIND, either express or implied. See the License for the
9131 ! specific language governing permissions and limitations
9132 ! under the License.
9133 !-->
9134</div></div>
9135<div class="section">
9136<h2><a name="Type_Functions"></a><a name="TypeFunctions" id="TypeFunctions">Type Functions</a></h2>
9137<div class="section">
9138<h3><a name="get_type"></a>get_type</h3>
9139<ul>
9140
9141<li>
9142
9143<p>Syntax:</p>
9144
9145<div>
9146<div>
9147<pre class="source">get_type(expr)
9148</pre></div></div>
9149</li>
9150<li>
9151
9152<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>
9153</li>
9154<li>Arguments:
9155<ul>
9156
9157<li><tt>expr</tt> : an expression (any type is allowed).</li>
9158</ul>
9159</li>
9160<li>
9161
9162<p>Example:</p>
9163
9164<div>
9165<div>
9166<pre class="source">{
9167 &quot;a&quot;: get_type(true),
9168 &quot;b&quot;: get_type(false),
9169 &quot;c&quot;: get_type(null),
9170 &quot;d&quot;: get_type(missing),
9171 &quot;e&quot;: get_type(&quot;d&quot;),
9172 &quot;f&quot;: gettype(4.0),
9173 &quot;g&quot;: gettype(5),
9174 &quot;h&quot;: gettype([&quot;1&quot;, 2]),
9175 &quot;i&quot;: gettype({&quot;a&quot;:1})
9176};
9177</pre></div></div>
9178</li>
9179<li>
9180
9181<p>The expected result is:</p>
9182
9183<div>
9184<div>
9185<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; }
9186</pre></div></div>
9187</li>
9188</ul>
9189<p>The function has an alias <tt>gettype</tt>.</p></div>
9190<div class="section">
9191<h3><a name="is_array"></a>is_array</h3>
9192<ul>
9193
9194<li>
9195
9196<p>Syntax:</p>
9197
9198<div>
9199<div>
9200<pre class="source">is_array(expr)
9201</pre></div></div>
9202</li>
9203<li>
9204
9205<p>Checks whether the given expression is evaluated to be an <tt>array</tt> value.</p>
9206</li>
9207<li>Arguments:
9208<ul>
9209
9210<li><tt>expr</tt> : an expression (any type is allowed).</li>
9211</ul>
9212</li>
9213<li>Return Value:
9214<ul>
9215
9216<li>a <tt>boolean</tt> on whether the argument is an <tt>array</tt> value or not,</li>
9217<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9218<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9219</ul>
9220</li>
9221<li>
9222
9223<p>Example:</p>
9224
9225<div>
9226<div>
9227<pre class="source">{
9228 &quot;a&quot;: is_array(true),
9229 &quot;b&quot;: is_array(false),
9230 &quot;c&quot;: isarray(null),
9231 &quot;d&quot;: isarray(missing),
9232 &quot;e&quot;: isarray(&quot;d&quot;),
9233 &quot;f&quot;: isarray(4.0),
9234 &quot;g&quot;: isarray(5),
9235 &quot;h&quot;: isarray([&quot;1&quot;, 2]),
9236 &quot;i&quot;: isarray({&quot;a&quot;:1})
9237};
9238</pre></div></div>
9239</li>
9240<li>
9241
9242<p>The expected result is:</p>
9243
9244<div>
9245<div>
9246<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 }
9247</pre></div></div>
9248</li>
9249</ul>
9250<p>The function has an alias <tt>isarray</tt>.</p></div>
9251<div class="section">
9252<h3><a name="is_multiset"></a>is_multiset</h3>
9253<ul>
9254
9255<li>
9256
9257<p>Syntax:</p>
9258
9259<div>
9260<div>
9261<pre class="source">is_multiset(expr)
9262</pre></div></div>
9263</li>
9264<li>
9265
9266<p>Checks whether the given expression is evaluated to be an <tt>multiset</tt> value.</p>
9267</li>
9268<li>Arguments:
9269<ul>
9270
9271<li><tt>expr</tt> : an expression (any type is allowed).</li>
9272</ul>
9273</li>
9274<li>Return Value:
9275<ul>
9276
9277<li>a <tt>boolean</tt> on whether the argument is an <tt>multiset</tt> value or not,</li>
9278<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9279<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9280</ul>
9281</li>
9282<li>
9283
9284<p>Example:</p>
9285
9286<div>
9287<div>
9288<pre class="source">{
9289 &quot;a&quot;: is_multiset(true),
9290 &quot;b&quot;: is_multiset(false),
9291 &quot;c&quot;: is_multiset(null),
9292 &quot;d&quot;: is_multiset(missing),
9293 &quot;e&quot;: is_multiset(&quot;d&quot;),
9294 &quot;f&quot;: ismultiset(4.0),
9295 &quot;g&quot;: ismultiset([&quot;1&quot;, 2]),
9296 &quot;h&quot;: ismultiset({&quot;a&quot;:1}),
9297 &quot;i&quot;: ismultiset({{&quot;hello&quot;, 9328, &quot;world&quot;, [1, 2, null]}})
9298};
9299</pre></div></div>
9300</li>
9301<li>
9302
9303<p>The expected result is:</p>
9304
9305<div>
9306<div>
9307<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 }
9308</pre></div></div>
9309</li>
9310</ul>
9311<p>The function has an alias <tt>ismultiset</tt>.</p></div>
9312<div class="section">
9313<h3><a name="is_atomic_.28is_atom.29"></a>is_atomic (is_atom)</h3>
9314<ul>
9315
9316<li>
9317
9318<p>Syntax:</p>
9319
9320<div>
9321<div>
9322<pre class="source">is_atomic(expr)
9323</pre></div></div>
9324</li>
9325<li>
9326
9327<p>Checks whether the given expression is evaluated to be a value of a <a href="../datamodel.html#PrimitiveTypes">primitive</a> type.</p>
9328</li>
9329<li>Arguments:
9330<ul>
9331
9332<li><tt>expr</tt> : an expression (any type is allowed).</li>
9333</ul>
9334</li>
9335<li>Return Value:
9336<ul>
9337
9338<li>a <tt>boolean</tt> on whether the argument is a primitive type or not,</li>
9339<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9340<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9341</ul>
9342</li>
9343<li>
9344
9345<p>Example:</p>
9346
9347<div>
9348<div>
9349<pre class="source">{
9350 &quot;a&quot;: is_atomic(true),
9351 &quot;b&quot;: is_atomic(false),
9352 &quot;c&quot;: isatomic(null),
9353 &quot;d&quot;: isatomic(missing),
9354 &quot;e&quot;: isatomic(&quot;d&quot;),
9355 &quot;f&quot;: isatom(4.0),
9356 &quot;g&quot;: isatom(5),
9357 &quot;h&quot;: isatom([&quot;1&quot;, 2]),
9358 &quot;i&quot;: isatom({&quot;a&quot;:1})
9359};
9360</pre></div></div>
9361</li>
9362<li>
9363
9364<p>The expected result is:</p>
9365
9366<div>
9367<div>
9368<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 }
9369</pre></div></div>
9370</li>
9371</ul>
9372<p>The function has three aliases: <tt>isatomic</tt>, <tt>is_atom</tt>, and <tt>isatom</tt>.</p></div>
9373<div class="section">
9374<h3><a name="is_boolean_.28is_bool.29"></a>is_boolean (is_bool)</h3>
9375<ul>
9376
9377<li>
9378
9379<p>Syntax:</p>
9380
9381<div>
9382<div>
9383<pre class="source">is_boolean(expr)
9384</pre></div></div>
9385</li>
9386<li>
9387
9388<p>Checks whether the given expression is evaluated to be a <tt>boolean</tt> value.</p>
9389</li>
9390<li>Arguments:
9391<ul>
9392
9393<li><tt>expr</tt> : an expression (any type is allowed).</li>
9394</ul>
9395</li>
9396<li>Return Value:
9397<ul>
9398
9399<li>a <tt>boolean</tt> on whether the argument is a <tt>boolean</tt> value or not,</li>
9400<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9401<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9402</ul>
9403</li>
9404<li>
9405
9406<p>Example:</p>
9407
9408<div>
9409<div>
9410<pre class="source">{
9411 &quot;a&quot;: isboolean(true),
9412 &quot;b&quot;: isboolean(false),
9413 &quot;c&quot;: is_boolean(null),
9414 &quot;d&quot;: is_boolean(missing),
9415 &quot;e&quot;: isbool(&quot;d&quot;),
9416 &quot;f&quot;: isbool(4.0),
9417 &quot;g&quot;: isbool(5),
9418 &quot;h&quot;: isbool([&quot;1&quot;, 2]),
9419 &quot;i&quot;: isbool({&quot;a&quot;:1})
9420};
9421</pre></div></div>
9422</li>
9423<li>
9424
9425<p>The expected result is:</p>
9426
9427<div>
9428<div>
9429<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 }
9430</pre></div></div>
9431</li>
9432</ul>
9433<p>The function has three aliases: <tt>isboolean</tt>, <tt>is_bool</tt>, and <tt>isbool</tt>.</p></div>
9434<div class="section">
9435<h3><a name="is_binary_.28is_bin.29"></a>is_binary (is_bin)</h3>
9436<ul>
9437
9438<li>
9439
9440<p>Syntax:</p>
9441
9442<div>
9443<div>
9444<pre class="source">is_binary(expr)
9445</pre></div></div>
9446</li>
9447<li>
9448
9449<p>Checks whether the given expression is evaluated to be a <tt>binary</tt> value.</p>
9450</li>
9451<li>Arguments:
9452<ul>
9453
9454<li><tt>expr</tt> : an expression (any type is allowed).</li>
9455</ul>
9456</li>
9457<li>Return Value:
9458<ul>
9459
9460<li>a <tt>boolean</tt> on whether the argument is a <tt>binary</tt> value or not,</li>
9461<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9462<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9463</ul>
9464</li>
9465<li>
9466
9467<p>Example:</p>
9468
9469<div>
9470<div>
9471<pre class="source">{
9472 &quot;a&quot;: is_binary(true),
9473 &quot;b&quot;: is_binary(false),
9474 &quot;c&quot;: isbinary(null),
9475 &quot;d&quot;: isbinary(missing),
9476 &quot;e&quot;: isbin(point(&quot;1,2&quot;)),
9477 &quot;f&quot;: isbin(hex(&quot;ABCDEF0123456789&quot;)),
9478 &quot;g&quot;: is_bin(sub_binary(hex(&quot;AABBCCDD&quot;), 4)),
9479 &quot;h&quot;: is_bin(2),
9480 &quot;i&quot;: is_bin({&quot;a&quot;:1})
9481};
9482</pre></div></div>
9483</li>
9484<li>
9485
9486<p>The expected result is:</p>
9487
9488<div>
9489<div>
9490<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 }
9491</pre></div></div>
9492</li>
9493</ul>
9494<p>The function has three aliases: <tt>isbinary</tt>, <tt>is_bin</tt>, and <tt>isbin</tt>.</p></div>
9495<div class="section">
9496<h3><a name="is_number_.28is_num.29"></a>is_number (is_num)</h3>
9497<ul>
9498
9499<li>
9500
9501<p>Syntax:</p>
9502
9503<div>
9504<div>
9505<pre class="source">is_number(expr)
9506</pre></div></div>
9507</li>
9508<li>
9509
9510<p>Checks whether the given expression is evaluated to be a numeric value.</p>
9511</li>
9512<li>Arguments:
9513<ul>
9514
9515<li><tt>expr</tt> : an expression (any type is allowed).</li>
9516</ul>
9517</li>
9518<li>Return Value:
9519<ul>
9520
9521<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>
9522<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9523<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9524</ul>
9525</li>
9526<li>
9527
9528<p>Example:</p>
9529
9530<div>
9531<div>
9532<pre class="source">{
9533 &quot;a&quot;: is_number(true),
9534 &quot;b&quot;: is_number(false),
9535 &quot;c&quot;: isnumber(null),
9536 &quot;d&quot;: isnumber(missing),
9537 &quot;e&quot;: isnumber(&quot;d&quot;),
9538 &quot;f&quot;: isnum(4.0),
9539 &quot;g&quot;: isnum(5),
9540 &quot;h&quot;: isnum([&quot;1&quot;, 2]),
9541 &quot;i&quot;: isnum({&quot;a&quot;:1})
9542};
9543</pre></div></div>
9544</li>
9545<li>
9546
9547<p>The expected result is:</p>
9548
9549<div>
9550<div>
9551<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 }
9552</pre></div></div>
9553</li>
9554</ul>
9555<p>The function has three aliases: <tt>isnumber</tt>, <tt>is_num</tt>, and <tt>isnum</tt>.</p></div>
9556<div class="section">
9557<h3><a name="is_point"></a>is_point</h3>
9558<ul>
9559
9560<li>
9561
9562<p>Syntax:</p>
9563
9564<div>
9565<div>
9566<pre class="source">is_point(expr)
9567</pre></div></div>
9568</li>
9569<li>
9570
9571<p>Checks whether the given expression is evaluated to be a <tt>point</tt> value.</p>
9572</li>
9573<li>Arguments:
9574<ul>
9575
9576<li><tt>expr</tt> : an expression (any type is allowed).</li>
9577</ul>
9578</li>
9579<li>Return Value:
9580<ul>
9581
9582<li>a <tt>boolean</tt> on whether the argument is a <tt>point</tt> value or not,</li>
9583<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9584<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9585</ul>
9586</li>
9587<li>
9588
9589<p>Example:</p>
9590
9591<div>
9592<div>
9593<pre class="source">{
9594 &quot;a&quot;: is_point(true),
9595 &quot;b&quot;: is_point(false),
9596 &quot;c&quot;: is_point(null),
9597 &quot;d&quot;: is_point(missing),
9598 &quot;e&quot;: is_point(point(&quot;1,2&quot;)),
9599 &quot;f&quot;: ispoint(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9600 &quot;g&quot;: ispoint(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9601 &quot;h&quot;: ispoint(circle(&quot;30.0,70.0 5.0&quot;)),
9602 &quot;i&quot;: ispoint(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9603 &quot;j&quot;: ispoint(3)
9604};
9605</pre></div></div>
9606</li>
9607<li>
9608
9609<p>The expected result is:</p>
9610
9611<div>
9612<div>
9613<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 }
9614</pre></div></div>
9615</li>
9616</ul>
9617<p>The function has an alias <tt>ispoint</tt>.</p></div>
9618<div class="section">
9619<h3><a name="is_line"></a>is_line</h3>
9620<ul>
9621
9622<li>
9623
9624<p>Syntax:</p>
9625
9626<div>
9627<div>
9628<pre class="source">is_line(expr)
9629</pre></div></div>
9630</li>
9631<li>
9632
9633<p>Checks whether the given expression is evaluated to be a <tt>line</tt> value.</p>
9634</li>
9635<li>Arguments:
9636<ul>
9637
9638<li><tt>expr</tt> : an expression (any type is allowed).</li>
9639</ul>
9640</li>
9641<li>Return Value:
9642<ul>
9643
9644<li>a <tt>boolean</tt> on whether the argument is a <tt>line</tt> value or not,</li>
9645<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9646<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9647</ul>
9648</li>
9649<li>
9650
9651<p>Example:</p>
9652
9653<div>
9654<div>
9655<pre class="source">{
9656 &quot;a&quot;: is_line(true),
9657 &quot;b&quot;: is_line(false),
9658 &quot;c&quot;: is_line(null),
9659 &quot;d&quot;: is_line(missing),
9660 &quot;e&quot;: is_line(point(&quot;1,2&quot;)),
9661 &quot;f&quot;: isline(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9662 &quot;g&quot;: isline(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9663 &quot;h&quot;: isline(circle(&quot;30.0,70.0 5.0&quot;)),
9664 &quot;i&quot;: isline(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9665 &quot;j&quot;: isline(3)
9666};
9667</pre></div></div>
9668</li>
9669<li>
9670
9671<p>The expected result is:</p>
9672
9673<div>
9674<div>
9675<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 }
9676</pre></div></div>
9677</li>
9678</ul>
9679<p>The function has an alias <tt>isline</tt>.</p></div>
9680<div class="section">
9681<h3><a name="is_rectangle"></a>is_rectangle</h3>
9682<ul>
9683
9684<li>
9685
9686<p>Syntax:</p>
9687
9688<div>
9689<div>
9690<pre class="source">is_rectangle(expr)
9691</pre></div></div>
9692</li>
9693<li>
9694
9695<p>Checks whether the given expression is evaluated to be a <tt>rectangle</tt> value.</p>
9696</li>
9697<li>Arguments:
9698<ul>
9699
9700<li><tt>expr</tt> : an expression (any type is allowed).</li>
9701</ul>
9702</li>
9703<li>Return Value:
9704<ul>
9705
9706<li>a <tt>boolean</tt> on whether the argument is a <tt>rectangle</tt> value or not,</li>
9707<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9708<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9709</ul>
9710</li>
9711<li>
9712
9713<p>Example:</p>
9714
9715<div>
9716<div>
9717<pre class="source">{
9718 &quot;a&quot;: is_rectangle(true),
9719 &quot;b&quot;: is_rectangle(false),
9720 &quot;c&quot;: is_rectangle(null),
9721 &quot;d&quot;: is_rectangle(missing),
9722 &quot;e&quot;: is_rectangle(point(&quot;1,2&quot;)),
9723 &quot;f&quot;: isrectangle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9724 &quot;g&quot;: isrectangle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9725 &quot;h&quot;: isrectangle(circle(&quot;30.0,70.0 5.0&quot;)),
9726 &quot;i&quot;: isrectangle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9727 &quot;j&quot;: isrectangle(3)
9728};
9729</pre></div></div>
9730</li>
9731<li>
9732
9733<p>The expected result is:</p>
9734
9735<div>
9736<div>
9737<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 }
9738</pre></div></div>
9739</li>
9740</ul>
9741<p>The function has an alias <tt>isrectangle</tt>.</p></div>
9742<div class="section">
9743<h3><a name="is_circle"></a>is_circle</h3>
9744<ul>
9745
9746<li>
9747
9748<p>Syntax:</p>
9749
9750<div>
9751<div>
9752<pre class="source">is_circle(expr)
9753</pre></div></div>
9754</li>
9755<li>
9756
9757<p>Checks whether the given expression is evaluated to be a <tt>circle</tt> value.</p>
9758</li>
9759<li>Arguments:
9760<ul>
9761
9762<li><tt>expr</tt> : an expression (any type is allowed).</li>
9763</ul>
9764</li>
9765<li>Return Value:
9766<ul>
9767
9768<li>a <tt>boolean</tt> on whether the argument is a <tt>circle</tt> value or not,</li>
9769<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9770<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9771</ul>
9772</li>
9773<li>
9774
9775<p>Example:</p>
9776
9777<div>
9778<div>
9779<pre class="source">{
9780 &quot;a&quot;: is_circle(true),
9781 &quot;b&quot;: is_circle(false),
9782 &quot;c&quot;: is_circle(null),
9783 &quot;d&quot;: is_circle(missing),
9784 &quot;e&quot;: is_circle(point(&quot;1,2&quot;)),
9785 &quot;f&quot;: iscircle(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9786 &quot;g&quot;: iscircle(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9787 &quot;h&quot;: iscircle(circle(&quot;30.0,70.0 5.0&quot;)),
9788 &quot;i&quot;: iscircle(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9789 &quot;j&quot;: iscircle(3)
9790};
9791</pre></div></div>
9792</li>
9793<li>
9794
9795<p>The expected result is:</p>
9796
9797<div>
9798<div>
9799<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 }
9800</pre></div></div>
9801</li>
9802</ul>
9803<p>The function has an alias <tt>iscircle</tt>.</p></div>
9804<div class="section">
9805<h3><a name="is_polygon"></a>is_polygon</h3>
9806<ul>
9807
9808<li>
9809
9810<p>Syntax:</p>
9811
9812<div>
9813<div>
9814<pre class="source">is_polygon(expr)
9815</pre></div></div>
9816</li>
9817<li>
9818
9819<p>Checks whether the given expression is evaluated to be a <tt>polygon</tt> value.</p>
9820</li>
9821<li>Arguments:
9822<ul>
9823
9824<li><tt>expr</tt> : an expression (any type is allowed).</li>
9825</ul>
9826</li>
9827<li>Return Value:
9828<ul>
9829
9830<li>a <tt>boolean</tt> on whether the argument is a <tt>polygon</tt> value or not,</li>
9831<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9832<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9833</ul>
9834</li>
9835<li>
9836
9837<p>Example:</p>
9838
9839<div>
9840<div>
9841<pre class="source">{
9842 &quot;a&quot;: is_polygon(true),
9843 &quot;b&quot;: is_polygon(false),
9844 &quot;c&quot;: is_polygon(null),
9845 &quot;d&quot;: is_polygon(missing),
9846 &quot;e&quot;: is_polygon(point(&quot;1,2&quot;)),
9847 &quot;f&quot;: ispolygon(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9848 &quot;g&quot;: ispolygon(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9849 &quot;h&quot;: ispolygon(circle(&quot;30.0,70.0 5.0&quot;)),
9850 &quot;i&quot;: ispolygon(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9851 &quot;j&quot;: ispolygon(3)
9852};
9853</pre></div></div>
9854</li>
9855<li>
9856
9857<p>The expected result is:</p>
9858
9859<div>
9860<div>
9861<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 }
9862</pre></div></div>
9863</li>
9864</ul>
9865<p>The function has an alias <tt>ispolygon</tt>.</p></div>
9866<div class="section">
9867<h3><a name="is_spatial"></a>is_spatial</h3>
9868<ul>
9869
9870<li>
9871
9872<p>Syntax:</p>
9873
9874<div>
9875<div>
9876<pre class="source">is_spatial(expr)
9877</pre></div></div>
9878</li>
9879<li>
9880
9881<p>Checks whether the given expression is evaluated to be a spatial value.</p>
9882</li>
9883<li>Arguments:
9884<ul>
9885
9886<li><tt>expr</tt> : an expression (any type is allowed).</li>
9887</ul>
9888</li>
9889<li>Return Value:
9890<ul>
9891
9892<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>
9893<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9894<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9895</ul>
9896</li>
9897<li>
9898
9899<p>Example:</p>
9900
9901<div>
9902<div>
9903<pre class="source">{
9904 &quot;a&quot;: is_spatial(true),
9905 &quot;b&quot;: is_spatial(false),
9906 &quot;c&quot;: is_spatial(null),
9907 &quot;d&quot;: is_spatial(missing),
9908 &quot;e&quot;: is_spatial(point(&quot;1,2&quot;)),
9909 &quot;f&quot;: isspatial(line(&quot;30.0,70.0 50.0,90.0&quot;)),
9910 &quot;g&quot;: isspatial(rectangle(&quot;30.0,70.0 50.0,90.0&quot;)),
9911 &quot;h&quot;: isspatial(circle(&quot;30.0,70.0 5.0&quot;)),
9912 &quot;i&quot;: isspatial(polygon(&quot;1.0,1.0 2.0,2.0 3.0,3.0 4.0,4.0&quot;)),
9913 &quot;j&quot;: isspatial(3)
9914};
9915</pre></div></div>
9916</li>
9917<li>
9918
9919<p>The expected result is:</p>
9920
9921<div>
9922<div>
9923<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 }
9924</pre></div></div>
9925</li>
9926</ul>
9927<p>The function has an alias <tt>isspatial</tt>.</p></div>
9928<div class="section">
9929<h3><a name="is_date"></a>is_date</h3>
9930<ul>
9931
9932<li>
9933
9934<p>Syntax:</p>
9935
9936<div>
9937<div>
9938<pre class="source">is_date(expr)
9939</pre></div></div>
9940</li>
9941<li>
9942
9943<p>Checks whether the given expression is evaluated to be a <tt>date</tt> value.</p>
9944</li>
9945<li>Arguments:
9946<ul>
9947
9948<li><tt>expr</tt> : an expression (any type is allowed).</li>
9949</ul>
9950</li>
9951<li>Return Value:
9952<ul>
9953
9954<li>a <tt>boolean</tt> on whether the argument is a <tt>date</tt> value or not,</li>
9955<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
9956<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
9957</ul>
9958</li>
9959<li>
9960
9961<p>Example:</p>
9962
9963<div>
9964<div>
9965<pre class="source">{
9966 &quot;a&quot;: is_date(true),
9967 &quot;b&quot;: is_date(false),
9968 &quot;c&quot;: is_date(null),
9969 &quot;d&quot;: is_date(missing),
9970 &quot;e&quot;: is_date(date(&quot;-19700101&quot;)),
9971 &quot;f&quot;: isdate(date(&quot;2013-01-01&quot;)),
9972 &quot;g&quot;: isdate(time(&quot;12:12:12.039Z&quot;)),
9973 &quot;h&quot;: isdate(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
9974 &quot;i&quot;: isdate(duration(&quot;P100Y12MT12M&quot;)),
9975 &quot;j&quot;: isdate(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
9976 &quot;k&quot;: isdate(3)
9977};
9978</pre></div></div>
9979</li>
9980<li>
9981
9982<p>The expected result is:</p>
9983
9984<div>
9985<div>
9986<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 }
9987</pre></div></div>
9988</li>
9989</ul>
9990<p>The function has an alias <tt>isdate</tt>.</p></div>
9991<div class="section">
9992<h3><a name="is_datetime_.28is_timestamp.29"></a>is_datetime (is_timestamp)</h3>
9993<ul>
9994
9995<li>
9996
9997<p>Syntax:</p>
9998
9999<div>
10000<div>
10001<pre class="source">is_datetime(expr)
10002</pre></div></div>
10003</li>
10004<li>
10005
10006<p>Checks whether the given expression is evaluated to be a <tt>datetime</tt> value.</p>
10007</li>
10008<li>Arguments:
10009<ul>
10010
10011<li><tt>expr</tt> : an expression (any type is allowed).</li>
10012</ul>
10013</li>
10014<li>Return Value:
10015<ul>
10016
10017<li>a <tt>boolean</tt> on whether the argument is a <tt>datetime</tt> value or not,</li>
10018<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10019<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10020</ul>
10021</li>
10022<li>
10023
10024<p>Example:</p>
10025
10026<div>
10027<div>
10028<pre class="source">{
10029 &quot;a&quot;: is_datetime(true),
10030 &quot;b&quot;: is_datetime(false),
10031 &quot;c&quot;: is_datetime(null),
10032 &quot;d&quot;: is_datetime(missing),
10033 &quot;e&quot;: is_datetime(datetime(&quot;2016-02-02T12:09:22.023Z&quot;)),
10034 &quot;f&quot;: isdatetime(datetime(&quot;2011-03-03T12:10:42.011Z&quot;)),
10035 &quot;g&quot;: isdatetime(time(&quot;12:12:12.039Z&quot;)),
10036 &quot;h&quot;: is_timestamp(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10037 &quot;i&quot;: is_timestamp(duration(&quot;P100Y12MT12M&quot;)),
10038 &quot;j&quot;: istimestamp(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10039 &quot;k&quot;: istimestamp(3)
10040};
10041</pre></div></div>
10042</li>
10043<li>
10044
10045<p>The expected result is:</p>
10046
10047<div>
10048<div>
10049<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 }
10050</pre></div></div>
10051</li>
10052</ul>
10053<p>The function has three aliases: <tt>isdatetime</tt>, <tt>is_timestamp</tt>, and <tt>istimestamp</tt>.</p></div>
10054<div class="section">
10055<h3><a name="is_time"></a>is_time</h3>
10056<ul>
10057
10058<li>
10059
10060<p>Syntax:</p>
10061
10062<div>
10063<div>
10064<pre class="source">is_time(expr)
10065</pre></div></div>
10066</li>
10067<li>
10068
10069<p>Checks whether the given expression is evaluated to be a <tt>time</tt> value.</p>
10070</li>
10071<li>Arguments:
10072<ul>
10073
10074<li><tt>expr</tt> : an expression (any type is allowed).</li>
10075</ul>
10076</li>
10077<li>Return Value:
10078<ul>
10079
10080<li>a <tt>boolean</tt> on whether the argument is a <tt>time</tt> value or not,</li>
10081<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10082<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10083</ul>
10084</li>
10085<li>
10086
10087<p>Example:</p>
10088
10089<div>
10090<div>
10091<pre class="source"> {
10092 &quot;a&quot;: is_time(true),
10093 &quot;b&quot;: is_time(false),
10094 &quot;c&quot;: is_time(null),
10095 &quot;d&quot;: is_time(missing),
10096 &quot;e&quot;: is_time(time(&quot;08:00:00.000Z&quot;)),
10097 &quot;f&quot;: istime(date(&quot;2013-01-01&quot;)),
10098 &quot;g&quot;: istime(time(&quot;12:12:12.039Z&quot;)),
10099 &quot;h&quot;: istime(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10100 &quot;i&quot;: istime(duration(&quot;P100Y12MT12M&quot;)),
10101 &quot;j&quot;: istime(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10102 &quot;k&quot;: istime(3)
10103};
10104</pre></div></div>
10105</li>
10106<li>
10107
10108<p>The expected result is:</p>
10109
10110<div>
10111<div>
10112<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 }
10113</pre></div></div>
10114</li>
10115</ul>
10116<p>The function has an alias <tt>istime</tt>.</p></div>
10117<div class="section">
10118<h3><a name="is_duration"></a>is_duration</h3>
10119<ul>
10120
10121<li>
10122
10123<p>Syntax:</p>
10124
10125<div>
10126<div>
10127<pre class="source">is_duration(expr)
10128</pre></div></div>
10129</li>
10130<li>
10131
10132<p>Checks whether the given expression is evaluated to be a duration value.</p>
10133</li>
10134<li>Arguments:
10135<ul>
10136
10137<li><tt>expr</tt> : an expression (any type is allowed).</li>
10138</ul>
10139</li>
10140<li>Return Value:
10141<ul>
10142
10143<li>a <tt>boolean</tt> on whether the argument is a <tt>duration/year_month_duration/day_time_duration</tt> value or not,</li>
10144<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10145<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10146</ul>
10147</li>
10148<li>
10149
10150<p>Example:</p>
10151
10152<div>
10153<div>
10154<pre class="source"> {
10155 &quot;a&quot;: is_duration(true),
10156 &quot;b&quot;: is_duration(false),
10157 &quot;c&quot;: is_duration(null),
10158 &quot;d&quot;: is_duration(missing),
10159 &quot;e&quot;: is_duration(duration(&quot;-PT20.943S&quot;)),
10160 &quot;f&quot;: isduration(date(&quot;2013-01-01&quot;)),
10161 &quot;g&quot;: isduration(time(&quot;12:12:12.039Z&quot;)),
10162 &quot;h&quot;: isduration(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10163 &quot;i&quot;: isduration(duration(&quot;P100Y12MT12M&quot;)),
10164 &quot;j&quot;: isduration(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10165 &quot;k&quot;: isduration(3)
10166};
10167</pre></div></div>
10168</li>
10169<li>
10170
10171<p>The expected result is:</p>
10172
10173<div>
10174<div>
10175<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 }
10176</pre></div></div>
10177</li>
10178</ul>
10179<p>The function has an alias <tt>isduration</tt>.</p></div>
10180<div class="section">
10181<h3><a name="is_interval"></a>is_interval</h3>
10182<ul>
10183
10184<li>
10185
10186<p>Syntax:</p>
10187
10188<div>
10189<div>
10190<pre class="source">is_interval(expr)
10191</pre></div></div>
10192</li>
10193<li>
10194
10195<p>Checks whether the given expression is evaluated to be a <tt>interval</tt> value.</p>
10196</li>
10197<li>Arguments:
10198<ul>
10199
10200<li><tt>expr</tt> : an expression (any type is allowed).</li>
10201</ul>
10202</li>
10203<li>Return Value:
10204<ul>
10205
10206<li>a <tt>boolean</tt> on whether the argument is a <tt>interval</tt> value or not,</li>
10207<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10208<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10209</ul>
10210</li>
10211<li>
10212
10213<p>Example:</p>
10214
10215<div>
10216<div>
10217<pre class="source"> {
10218 &quot;a&quot;: is_interval(true),
10219 &quot;b&quot;: is_interval(false),
10220 &quot;c&quot;: is_interval(null),
10221 &quot;d&quot;: is_interval(missing),
10222 &quot;e&quot;: is_interval(interval(datetime(&quot;2013-01-01T00:01:01.000Z&quot;), datetime(&quot;2013-05-05T13:39:01.049Z&quot;))),
10223 &quot;f&quot;: isinterval(date(&quot;2013-01-01&quot;)),
10224 &quot;g&quot;: isinterval(time(&quot;12:12:12.039Z&quot;)),
10225 &quot;h&quot;: isinterval(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10226 &quot;i&quot;: isinterval(duration(&quot;P100Y12MT12M&quot;)),
10227 &quot;j&quot;: isinterval(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10228 &quot;k&quot;: isinterval(3)
10229};
10230</pre></div></div>
10231</li>
10232<li>
10233
10234<p>The expected result is:</p>
10235
10236<div>
10237<div>
10238<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 }
10239</pre></div></div>
10240</li>
10241</ul>
10242<p>The function has an alias <tt>isinterval</tt>.</p></div>
10243<div class="section">
10244<h3><a name="is_temporal"></a>is_temporal</h3>
10245<ul>
10246
10247<li>
10248
10249<p>Syntax:</p>
10250
10251<div>
10252<div>
10253<pre class="source">is_temporal(expr)
10254</pre></div></div>
10255</li>
10256<li>
10257
10258<p>Checks whether the given expression is evaluated to be a temporal value.</p>
10259</li>
10260<li>Arguments:
10261<ul>
10262
10263<li><tt>expr</tt> : an expression (any type is allowed).</li>
10264</ul>
10265</li>
10266<li>Return Value:
10267<ul>
10268
10269<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>
10270<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10271<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10272</ul>
10273</li>
10274<li>
10275
10276<p>Example:</p>
10277
10278<div>
10279<div>
10280<pre class="source"> {
10281 &quot;a&quot;: is_temporal(true),
10282 &quot;b&quot;: is_temporal(false),
10283 &quot;c&quot;: is_temporal(null),
10284 &quot;d&quot;: is_temporal(missing),
10285 &quot;e&quot;: is_temporal(duration(&quot;-PT20.943S&quot;)),
10286 &quot;f&quot;: istemporal(date(&quot;2013-01-01&quot;)),
10287 &quot;g&quot;: istemporal(time(&quot;12:12:12.039Z&quot;)),
10288 &quot;h&quot;: istemporal(datetime(&quot;2013-01-01T12:12:12.039Z&quot;)),
10289 &quot;i&quot;: istemporal(duration(&quot;P100Y12MT12M&quot;)),
10290 &quot;j&quot;: istemporal(interval(date(&quot;2013-01-01&quot;), date(&quot;20130505&quot;))),
10291 &quot;k&quot;: istemporal(3)
10292};
10293</pre></div></div>
10294</li>
10295<li>
10296
10297<p>The expected result is:</p>
10298
10299<div>
10300<div>
10301<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 }
10302</pre></div></div>
10303</li>
10304</ul>
10305<p>The function has an alias <tt>istemporal</tt>.</p></div>
10306<div class="section">
10307<h3><a name="is_object_.28is_obj.29"></a>is_object (is_obj)</h3>
10308<ul>
10309
10310<li>
10311
10312<p>Syntax:</p>
10313
10314<div>
10315<div>
10316<pre class="source">is_object(expr)
10317</pre></div></div>
10318</li>
10319<li>
10320
10321<p>Checks whether the given expression is evaluated to be a <tt>object</tt> value.</p>
10322</li>
10323<li>Arguments:
10324<ul>
10325
10326<li><tt>expr</tt> : an expression (any type is allowed).</li>
10327</ul>
10328</li>
10329<li>Return Value:
10330<ul>
10331
10332<li>a <tt>boolean</tt> on whether the argument is a <tt>object</tt> value or not,</li>
10333<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10334<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10335</ul>
10336</li>
10337<li>
10338
10339<p>Example:</p>
10340
10341<div>
10342<div>
10343<pre class="source">{
10344 &quot;a&quot;: is_object(true),
10345 &quot;b&quot;: is_object(false),
10346 &quot;c&quot;: isobject(null),
10347 &quot;d&quot;: isobject(missing),
10348 &quot;e&quot;: isobj(&quot;d&quot;),
10349 &quot;f&quot;: isobj(4.0),
10350 &quot;g&quot;: isobj(5),
10351 &quot;h&quot;: isobj([&quot;1&quot;, 2]),
10352 &quot;i&quot;: isobj({&quot;a&quot;:1})
10353};
10354</pre></div></div>
10355</li>
10356<li>
10357
10358<p>The expected result is:</p>
10359<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>
10360</li>
10361</ul>
10362<p>The function has three aliases: <tt>isobject</tt>, <tt>is_obj</tt>, and <tt>isobj</tt>.</p></div>
10363<div class="section">
10364<h3><a name="is_string_.28is_str.29"></a>is_string (is_str)</h3>
10365<ul>
10366
10367<li>
10368
10369<p>Syntax:</p>
10370
10371<div>
10372<div>
10373<pre class="source">is_string(expr)
10374</pre></div></div>
10375</li>
10376<li>
10377
10378<p>Checks whether the given expression is evaluated to be a <tt>string</tt> value.</p>
10379</li>
10380<li>Arguments:
10381<ul>
10382
10383<li><tt>expr</tt> : an expression (any type is allowed).</li>
10384</ul>
10385</li>
10386<li>Return Value:
10387<ul>
10388
10389<li>a <tt>boolean</tt> on whether the argument is a <tt>string</tt> value or not,</li>
10390<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10391<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10392</ul>
10393</li>
10394<li>
10395
10396<p>Example:</p>
10397
10398<div>
10399<div>
10400<pre class="source">{
10401 &quot;a&quot;: is_string(true),
10402 &quot;b&quot;: isstring(false),
10403 &quot;c&quot;: isstring(null),
10404 &quot;d&quot;: isstr(missing),
10405 &quot;e&quot;: isstr(&quot;d&quot;),
10406 &quot;f&quot;: isstr(4.0),
10407 &quot;g&quot;: isstr(5),
10408 &quot;h&quot;: isstr([&quot;1&quot;, 2]),
10409 &quot;i&quot;: isstr({&quot;a&quot;:1})
10410};
10411</pre></div></div>
10412</li>
10413<li>
10414
10415<p>The expected result is:</p>
10416
10417<div>
10418<div>
10419<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 }
10420</pre></div></div>
10421</li>
10422</ul>
10423<p>The function has three aliases: <tt>isstring</tt>, <tt>is_str</tt>, and <tt>isstr</tt>.</p></div>
10424<div class="section">
10425<h3><a name="is_uuid"></a>is_uuid</h3>
10426<ul>
10427
10428<li>
10429
10430<p>Syntax:</p>
10431
10432<div>
10433<div>
10434<pre class="source">is_uuid(expr)
10435</pre></div></div>
10436</li>
10437<li>
10438
10439<p>Checks whether the given expression is evaluated to be a <tt>uuid</tt> value.</p>
10440</li>
10441<li>Arguments:
10442<ul>
10443
10444<li><tt>expr</tt> : an expression (any type is allowed).</li>
10445</ul>
10446</li>
10447<li>Return Value:
10448<ul>
10449
10450<li>a <tt>boolean</tt> on whether the argument is a <tt>uuid</tt> value or not,</li>
10451<li>a <tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
10452<li>a <tt>null</tt> if the argument is a <tt>null</tt> value.</li>
10453</ul>
10454</li>
10455<li>
10456
10457<p>Example:</p>
10458
10459<div>
10460<div>
10461<pre class="source"> {
10462 &quot;a&quot;: is_uuid(true),
10463 &quot;b&quot;: is_uuid(false),
10464 &quot;c&quot;: is_uuid(null),
10465 &quot;d&quot;: is_uuid(missing),
10466 &quot;e&quot;: isuuid(4.0),
10467 &quot;f&quot;: isuuid(date(&quot;2013-01-01&quot;)),
10468 &quot;g&quot;: isuuid(uuid(&quot;5c848e5c-6b6a-498f-8452-8847a2957421&quot;))
10469};
10470</pre></div></div>
10471</li>
10472<li>
10473
10474<p>The expected result is:</p>
10475
10476<div>
10477<div>
10478<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 }
10479</pre></div></div>
10480</li>
10481</ul>
10482<p>The function has an alias <tt>isuuid</tt>.</p></div>
10483<div class="section">
10484<h3><a name="is_null"></a>is_null</h3>
10485<ul>
10486
10487<li>
10488
10489<p>Syntax:</p>
10490
10491<div>
10492<div>
10493<pre class="source">is_null(expr)
10494</pre></div></div>
10495</li>
10496<li>
10497
10498<p>Checks whether the given expression is evaluated to be a <tt>null</tt> value.</p>
10499</li>
10500<li>Arguments:
10501<ul>
10502
10503<li><tt>expr</tt> : an expression (any type is allowed).</li>
10504</ul>
10505</li>
10506<li>Return Value:
10507<ul>
10508
10509<li>a <tt>boolean</tt> on whether the variable is a <tt>null</tt> or not,</li>
10510<li>a <tt>missing</tt> if the input is <tt>missing</tt>.</li>
10511</ul>
10512</li>
10513<li>
10514
10515<p>Example:</p>
10516
10517<div>
10518<div>
10519<pre class="source">{ &quot;v1&quot;: is_null(null), &quot;v2&quot;: is_null(1), &quot;v3&quot;: is_null(missing) };
10520</pre></div></div>
10521</li>
10522<li>
10523
10524<p>The expected result is:</p>
10525
10526<div>
10527<div>
10528<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false }
10529</pre></div></div>
10530</li>
10531</ul>
10532<p>The function has an alias <tt>isnull</tt>.</p></div>
10533<div class="section">
10534<h3><a name="is_missing"></a>is_missing</h3>
10535<ul>
10536
10537<li>
10538
10539<p>Syntax:</p>
10540
10541<div>
10542<div>
10543<pre class="source">is_missing(expr)
10544</pre></div></div>
10545</li>
10546<li>
10547
10548<p>Checks whether the given expression is evaluated to be a <tt>missing</tt> value.</p>
10549</li>
10550<li>Arguments:
10551<ul>
10552
10553<li><tt>expr</tt> : an expression (any type is allowed).</li>
10554</ul>
10555</li>
10556<li>Return Value:
10557<ul>
10558
10559<li>a <tt>boolean</tt> on whether the variable is a <tt>missing</tt> or not.</li>
10560</ul>
10561</li>
10562<li>
10563
10564<p>Example:</p>
10565
10566<div>
10567<div>
10568<pre class="source">{ &quot;v1&quot;: is_missing(null), &quot;v2&quot;: is_missing(1), &quot;v3&quot;: is_missing(missing) };
10569</pre></div></div>
10570</li>
10571<li>
10572
10573<p>The expected result is:</p>
10574
10575<div>
10576<div>
10577<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: false, &quot;v3&quot;: true }
10578</pre></div></div>
10579</li>
10580</ul>
10581<p>The function has an alias <tt>ismissing</tt>.</p></div>
10582<div class="section">
10583<h3><a name="is_unknown"></a>is_unknown</h3>
10584<ul>
10585
10586<li>
10587
10588<p>Syntax:</p>
10589
10590<div>
10591<div>
10592<pre class="source">is_unknown(expr)
10593</pre></div></div>
10594</li>
10595<li>
10596
10597<p>Checks whether the given variable is a <tt>null</tt> value or a <tt>missing</tt> value.</p>
10598</li>
10599<li>Arguments:
10600<ul>
10601
10602<li><tt>expr</tt> : an expression (any type is allowed).</li>
10603</ul>
10604</li>
10605<li>Return Value:
10606<ul>
10607
10608<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>
10609</ul>
10610</li>
10611<li>
10612
10613<p>Example:</p>
10614
10615<div>
10616<div>
10617<pre class="source">{ &quot;v1&quot;: is_unknown(null), &quot;v2&quot;: is_unknown(1), &quot;v3&quot;: is_unknown(missing) };
10618</pre></div></div>
10619</li>
10620<li>
10621
10622<p>The expected result is:</p>
10623
10624<div>
10625<div>
10626<pre class="source">{ &quot;v1&quot;: true, &quot;v2&quot;: false, &quot;v3&quot;: true }
10627</pre></div></div>
10628</li>
10629</ul>
10630<p>The function has an alias <tt>isunknown</tt>.</p></div>
10631<div class="section">
10632<h3><a name="to_array"></a>to_array</h3>
10633<ul>
10634
10635<li>
10636
10637<p>Syntax:</p>
10638
10639<div>
10640<div>
10641<pre class="source">to_array(expr)
10642</pre></div></div>
10643</li>
10644<li>
10645
10646<p>Converts input value to an <tt>array</tt> value</p>
10647</li>
10648<li>Arguments:
10649<ul>
10650
10651<li><tt>expr</tt> : an expression</li>
10652</ul>
10653</li>
10654<li>Return Value:
10655<ul>
10656
10657<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10658<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10659<li>if the argument is of <tt>array</tt> type then it is returned as is</li>
10660<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>
10661<li>otherwise an <tt>array</tt> containing the input expression as its single item is returned</li>
10662</ul>
10663</li>
10664<li>
10665
10666<p>Example:</p>
10667
10668<div>
10669<div>
10670<pre class="source">{
10671 &quot;v1&quot;: to_array(&quot;asterix&quot;),
10672 &quot;v2&quot;: to_array([&quot;asterix&quot;]),
10673};
10674</pre></div></div>
10675</li>
10676<li>
10677
10678<p>The expected result is:</p>
10679
10680<div>
10681<div>
10682<pre class="source">{ &quot;v1&quot;: [&quot;asterix&quot;], &quot;v2&quot;: [&quot;asterix&quot;] }
10683</pre></div></div>
10684</li>
10685</ul>
10686<p>The function has an alias <tt>toarray</tt>.</p></div>
10687<div class="section">
10688<h3><a name="to_atomic_.28to_atom.29"></a>to_atomic (to_atom)</h3>
10689<ul>
10690
10691<li>
10692
10693<p>Syntax:</p>
10694
10695<div>
10696<div>
10697<pre class="source">to_atomic(expr)
10698</pre></div></div>
10699</li>
10700<li>
10701
10702<p>Converts input value to a <a href="../datamodel.html#PrimitiveTypes">primitive</a> value</p>
10703</li>
10704<li>Arguments:
10705<ul>
10706
10707<li><tt>expr</tt> : an expression</li>
10708</ul>
10709</li>
10710<li>Return Value:
10711<ul>
10712
10713<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10714<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10715<li>if the argument is of primitive type then it is returned as is</li>
10716<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>
10717<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>
10718<li>otherwise <tt>null</tt> is returned</li>
10719</ul>
10720</li>
10721<li>
10722
10723<p>Example:</p>
10724
10725<div>
10726<div>
10727<pre class="source">{
10728 &quot;v1&quot;: to_atomic(&quot;asterix&quot;),
10729 &quot;v2&quot;: to_atomic([&quot;asterix&quot;]),
10730 &quot;v3&quot;: to_atomic([0, 1]),
10731 &quot;v4&quot;: to_atomic({&quot;value&quot;: &quot;asterix&quot;}),
10732 &quot;v5&quot;: to_number({&quot;x&quot;: 1, &quot;y&quot;: 2})
10733};
10734</pre></div></div>
10735</li>
10736<li>
10737
10738<p>The expected result is:</p>
10739
10740<div>
10741<div>
10742<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 }
10743</pre></div></div>
10744</li>
10745</ul>
10746<p>The function has three aliases: <tt>toatomic</tt>, <tt>to_atom</tt>, and <tt>toatom</tt>.</p></div>
10747<div class="section">
10748<h3><a name="to_boolean_.28to_bool.29"></a>to_boolean (to_bool)</h3>
10749<ul>
10750
10751<li>
10752
10753<p>Syntax:</p>
10754
10755<div>
10756<div>
10757<pre class="source">to_boolean(expr)
10758</pre></div></div>
10759</li>
10760<li>
10761
10762<p>Converts input value to a <tt>boolean</tt> value</p>
10763</li>
10764<li>Arguments:
10765<ul>
10766
10767<li><tt>expr</tt> : an expression</li>
10768</ul>
10769</li>
10770<li>Return Value:
10771<ul>
10772
10773<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10774<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10775<li>if the argument is of <tt>boolean</tt> type then it is returned as is</li>
10776<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>
10777<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>
10778<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>
10779<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>
10780<li>type error is raised for all other input types</li>
10781</ul>
10782</li>
10783<li>
10784
10785<p>Example:</p>
10786
10787<div>
10788<div>
10789<pre class="source">{
10790 &quot;v1&quot;: to_boolean(0),
10791 &quot;v2&quot;: to_boolean(1),
10792 &quot;v3&quot;: to_boolean(&quot;&quot;),
10793 &quot;v4&quot;: to_boolean(&quot;asterix&quot;)
10794};
10795</pre></div></div>
10796</li>
10797<li>
10798
10799<p>The expected result is:</p>
10800
10801<div>
10802<div>
10803<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: false, &quot;v4&quot;: true }
10804</pre></div></div>
10805</li>
10806</ul>
10807<p>The function has three aliases: <tt>toboolean</tt>, <tt>to_bool</tt>, and <tt>tobool</tt>.</p></div>
10808<div class="section">
10809<h3><a name="to_bigint"></a>to_bigint</h3>
10810<ul>
10811
10812<li>
10813
10814<p>Syntax:</p>
10815
10816<div>
10817<div>
10818<pre class="source">to_bigint(expr)
10819</pre></div></div>
10820</li>
10821<li>
10822
10823<p>Converts input value to an integer value</p>
10824</li>
10825<li>Arguments:
10826<ul>
10827
10828<li><tt>expr</tt> : an expression</li>
10829</ul>
10830</li>
10831<li>Return Value:
10832<ul>
10833
10834<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10835<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10836<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>
10837<li>if the argument is of numeric integer type then it is returned as the same value of <tt>bigint</tt> type</li>
10838<li>if the argument is of numeric <tt>float</tt>/<tt>double</tt> type then it is converted to <tt>bigint</tt> type</li>
10839<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>
10840<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10841<li>type error is raised for all other input types</li>
10842</ul>
10843</li>
10844<li>
10845
10846<p>Example:</p>
10847
10848<div>
10849<div>
10850<pre class="source">{
10851 &quot;v1&quot;: to_bigint(false),
10852 &quot;v2&quot;: to_bigint(true),
10853 &quot;v3&quot;: to_bigint(10),
10854 &quot;v4&quot;: to_bigint(float(&quot;1e100&quot;)),
10855 &quot;v5&quot;: to_bigint(double(&quot;1e1000&quot;)),
10856 &quot;v6&quot;: to_bigint(&quot;20&quot;)
10857};
10858</pre></div></div>
10859</li>
10860<li>
10861
10862<p>The expected result is:</p>
10863
10864<div>
10865<div>
10866<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 }
10867</pre></div></div>
10868</li>
10869</ul>
10870<p>The function has an alias <tt>tobigint</tt>.</p></div>
10871<div class="section">
10872<h3><a name="to_double"></a>to_double</h3>
10873<ul>
10874
10875<li>
10876
10877<p>Syntax:</p>
10878
10879<div>
10880<div>
10881<pre class="source">to_double(expr)
10882</pre></div></div>
10883</li>
10884<li>
10885
10886<p>Converts input value to a <tt>double</tt> value</p>
10887</li>
10888<li>Arguments:
10889<ul>
10890
10891<li><tt>expr</tt> : an expression</li>
10892</ul>
10893</li>
10894<li>Return Value:
10895<ul>
10896
10897<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10898<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10899<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>
10900<li>if the argument is of numeric type then it is returned as the value of <tt>double</tt> type</li>
10901<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>
10902<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10903<li>type error is raised for all other input types</li>
10904</ul>
10905</li>
10906<li>
10907
10908<p>Example:</p>
10909
10910<div>
10911<div>
10912<pre class="source">{
10913 &quot;v1&quot;: to_double(false),
10914 &quot;v2&quot;: to_double(true),
10915 &quot;v3&quot;: to_double(10),
10916 &quot;v4&quot;: to_double(11.5),
10917 &quot;v5&quot;: to_double(&quot;12.5&quot;)
10918};
10919</pre></div></div>
10920</li>
10921<li>
10922
10923<p>The expected result is:</p>
10924
10925<div>
10926<div>
10927<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 }
10928</pre></div></div>
10929</li>
10930</ul>
10931<p>The function has an alias <tt>todouble</tt>.</p></div>
10932<div class="section">
10933<h3><a name="to_number_.28to_num.29"></a>to_number (to_num)</h3>
10934<ul>
10935
10936<li>
10937
10938<p>Syntax:</p>
10939
10940<div>
10941<div>
10942<pre class="source">to_number(expr)
10943</pre></div></div>
10944</li>
10945<li>
10946
10947<p>Converts input value to a numeric value</p>
10948</li>
10949<li>Arguments:
10950<ul>
10951
10952<li><tt>expr</tt> : an expression</li>
10953</ul>
10954</li>
10955<li>Return Value:
10956<ul>
10957
10958<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
10959<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
10960<li>if the argument is of numeric type then it is returned as is</li>
10961<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>
10962<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>
10963<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
10964<li>type error is raised for all other input types</li>
10965</ul>
10966</li>
10967<li>
10968
10969<p>Example:</p>
10970
10971<div>
10972<div>
10973<pre class="source">{
10974 &quot;v1&quot;: to_number(false),
10975 &quot;v2&quot;: to_number(true),
10976 &quot;v3&quot;: to_number(10),
10977 &quot;v4&quot;: to_number(11.5),
10978 &quot;v5&quot;: to_number(&quot;12.5&quot;)
10979};
10980</pre></div></div>
10981</li>
10982<li>
10983
10984<p>The expected result is:</p>
10985
10986<div>
10987<div>
10988<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 }
10989</pre></div></div>
10990</li>
10991</ul>
10992<p>The function has three aliases: <tt>tonumber</tt>, <tt>to_num</tt>, and <tt>tonum</tt>.</p></div>
10993<div class="section">
10994<h3><a name="to_object_.28to_obj.29"></a>to_object (to_obj)</h3>
10995<ul>
10996
10997<li>
10998
10999<p>Syntax:</p>
11000
11001<div>
11002<div>
11003<pre class="source">to_object(expr)
11004</pre></div></div>
11005</li>
11006<li>
11007
11008<p>Converts input value to an <tt>object</tt> value</p>
11009</li>
11010<li>Arguments:
11011<ul>
11012
11013<li><tt>expr</tt> : an expression</li>
11014</ul>
11015</li>
11016<li>Return Value:
11017<ul>
11018
11019<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11020<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11021<li>if the argument is of <tt>object</tt> type then it is returned as is</li>
11022<li>otherwise an empty <tt>object</tt> is returned</li>
11023</ul>
11024</li>
11025<li>
11026
11027<p>Example:</p>
11028
11029<div>
11030<div>
11031<pre class="source">{
11032 &quot;v1&quot;: to_object({&quot;value&quot;: &quot;asterix&quot;}),
11033 &quot;v2&quot;: to_object(&quot;asterix&quot;)
11034};
11035</pre></div></div>
11036</li>
11037<li>
11038
11039<p>The expected result is:</p>
11040
11041<div>
11042<div>
11043<pre class="source">{ &quot;v1&quot;: {&quot;value&quot;: &quot;asterix&quot;}, &quot;v2&quot;: {} }
11044</pre></div></div>
11045</li>
11046</ul>
11047<p>The function has three aliases: <tt>toobject</tt>, <tt>to_obj</tt>, and <tt>toobj</tt>.</p></div>
11048<div class="section">
11049<h3><a name="to_string_.28to_str.29"></a>to_string (to_str)</h3>
11050<ul>
11051
11052<li>
11053
11054<p>Syntax:</p>
11055
11056<div>
11057<div>
11058<pre class="source">to_string(expr)
11059</pre></div></div>
11060</li>
11061<li>
11062
11063<p>Converts input value to a string value</p>
11064</li>
11065<li>Arguments:
11066<ul>
11067
11068<li><tt>expr</tt> : an expression</li>
11069</ul>
11070</li>
11071<li>Return Value:
11072<ul>
11073
11074<li>if the argument is <tt>missing</tt> then <tt>missing</tt> is returned</li>
11075<li>if the argument is <tt>null</tt> then <tt>null</tt> is returned</li>
11076<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>
11077<li>if the argument is of numeric type then its string representation is returned</li>
11078<li>if the argument is of <tt>string</tt> type then it is returned as is</li>
11079<li>if the argument is of <tt>array</tt>/<tt>multiset</tt>/<tt>object</tt> type then <tt>null</tt> is returned</li>
11080<li>type error is raised for all other input types</li>
11081</ul>
11082</li>
11083<li>
11084
11085<p>Example:</p>
11086
11087<div>
11088<div>
11089<pre class="source">{
11090 &quot;v1&quot;: to_string(false),
11091 &quot;v2&quot;: to_string(true),
11092 &quot;v3&quot;: to_string(10),
11093 &quot;v4&quot;: to_string(11.5),
11094 &quot;v5&quot;: to_string(&quot;asterix&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;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; }
11105</pre></div></div>
11106</li>
11107</ul>
11108<p>The function has three aliases: <tt>tostring</tt>, <tt>to_str</tt>, and <tt>tostr</tt>.</p><!--
11109 ! Licensed to the Apache Software Foundation (ASF) under one
11110 ! or more contributor license agreements. See the NOTICE file
11111 ! distributed with this work for additional information
11112 ! regarding copyright ownership. The ASF licenses this file
11113 ! to you under the Apache License, Version 2.0 (the
11114 ! "License"); you may not use this file except in compliance
11115 ! with the License. You may obtain a copy of the License at
11116 !
11117 ! http://www.apache.org/licenses/LICENSE-2.0
11118 !
11119 ! Unless required by applicable law or agreed to in writing,
11120 ! software distributed under the License is distributed on an
11121 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11122 ! KIND, either express or implied. See the License for the
11123 ! specific language governing permissions and limitations
11124 ! under the License.
11125 !-->
11126</div></div>
11127<div class="section">
11128<h2><a name="Conditional_Functions"></a><a name="ConditionalFunctions" id="ConditionalFunctions">Conditional Functions</a></h2>
11129<div class="section">
11130<h3><a name="if_null_.28ifnull.29"></a>if_null (ifnull)</h3>
11131<ul>
11132
11133<li>
11134
11135<p>Syntax:</p>
11136
11137<div>
11138<div>
11139<pre class="source">if_null(expression1, expression2, ... expressionN)
11140</pre></div></div>
11141</li>
11142<li>
11143
11144<p>Finds first argument which value is not <tt>null</tt> and returns that value</p>
11145</li>
11146<li>Arguments:
11147<ul>
11148
11149<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11150</ul>
11151</li>
11152<li>Return Value:
11153<ul>
11154
11155<li>a <tt>null</tt> if all arguments evaluate to <tt>null</tt> or no arguments specified</li>
11156<li>a value of the first non-<tt>null</tt> argument otherwise</li>
11157</ul>
11158</li>
11159<li>
11160
11161<p>Example:</p>
11162
11163<div>
11164<div>
11165<pre class="source">{
11166 &quot;a&quot;: if_null(),
11167 &quot;b&quot;: if_null(null),
11168 &quot;c&quot;: if_null(null, &quot;asterixdb&quot;),
11169 &quot;d&quot;: is_missing(if_null(missing))
11170};
11171</pre></div></div>
11172</li>
11173<li>
11174
11175<p>The expected result is:</p>
11176
11177<div>
11178<div>
11179<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: true }
11180</pre></div></div>
11181</li>
11182</ul>
11183<p>The function has an alias <tt>ifnull</tt>.</p></div>
11184<div class="section">
11185<h3><a name="if_missing_.28ifmissing.29"></a>if_missing (ifmissing)</h3>
11186<ul>
11187
11188<li>
11189
11190<p>Syntax:</p>
11191
11192<div>
11193<div>
11194<pre class="source">if_missing(expression1, expression2, ... expressionN)
11195</pre></div></div>
11196</li>
11197<li>
11198
11199<p>Finds first argument which value is not <tt>missing</tt> and returns that value</p>
11200</li>
11201<li>Arguments:
11202<ul>
11203
11204<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11205</ul>
11206</li>
11207<li>Return Value:
11208<ul>
11209
11210<li>a <tt>null</tt> if all arguments evaluate to <tt>missing</tt> or no arguments specified</li>
11211<li>a value of the first non-<tt>missing</tt> argument otherwise</li>
11212</ul>
11213</li>
11214<li>
11215
11216<p>Example:</p>
11217
11218<div>
11219<div>
11220<pre class="source">{
11221 &quot;a&quot;: if_missing(),
11222 &quot;b&quot;: if_missing(missing),
11223 &quot;c&quot;: if_missing(missing, &quot;asterixdb&quot;),
11224 &quot;d&quot;: if_missing(null, &quot;asterixdb&quot;)
11225};
11226</pre></div></div>
11227</li>
11228<li>
11229
11230<p>The expected result is:</p>
11231
11232<div>
11233<div>
11234<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot;, &quot;d&quot;: null }
11235</pre></div></div>
11236</li>
11237</ul>
11238<p>The function has an alias <tt>ifmissing</tt>.</p></div>
11239<div class="section">
11240<h3><a name="if_missing_or_null_.28ifmissingornull.2C_coalesce.29"></a>if_missing_or_null (ifmissingornull, coalesce)</h3>
11241<ul>
11242
11243<li>
11244
11245<p>Syntax:</p>
11246
11247<div>
11248<div>
11249<pre class="source">if_missing_or_null(expression1, expression2, ... expressionN)
11250</pre></div></div>
11251</li>
11252<li>
11253
11254<p>Finds first argument which value is not <tt>null</tt> or <tt>missing</tt> and returns that value</p>
11255</li>
11256<li>Arguments:
11257<ul>
11258
11259<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11260</ul>
11261</li>
11262<li>Return Value:
11263<ul>
11264
11265<li>a <tt>null</tt> if all arguments evaluate to either <tt>null</tt> or <tt>missing</tt>, or no arguments specified</li>
11266<li>a value of the first non-<tt>null</tt>, non-<tt>missing</tt> argument otherwise</li>
11267</ul>
11268</li>
11269<li>
11270
11271<p>Example:</p>
11272
11273<div>
11274<div>
11275<pre class="source">{
11276 &quot;a&quot;: if_missing_or_null(),
11277 &quot;b&quot;: if_missing_or_null(null, missing),
11278 &quot;c&quot;: if_missing_or_null(null, missing, &quot;asterixdb&quot;)
11279};
11280</pre></div></div>
11281</li>
11282<li>
11283
11284<p>The expected result is:</p>
11285
11286<div>
11287<div>
11288<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: null, &quot;c&quot;: &quot;asterixdb&quot; }
11289</pre></div></div>
11290</li>
11291</ul>
11292<p>The function has two aliases: <tt>ifmissingornull</tt> and <tt>coalesce</tt>.</p></div>
11293<div class="section">
11294<h3><a name="if_inf_.28ifinf.29"></a>if_inf (ifinf)</h3>
11295<ul>
11296
11297<li>
11298
11299<p>Syntax:</p>
11300
11301<div>
11302<div>
11303<pre class="source">if_inf(expression1, expression2, ... expressionN)
11304</pre></div></div>
11305</li>
11306<li>
11307
11308<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) number</p>
11309</li>
11310<li>Arguments:
11311<ul>
11312
11313<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11314</ul>
11315</li>
11316<li>Return Value:
11317<ul>
11318
11319<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-infinite number argument</li>
11320<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>
11321<li>the first non-infinite number argument otherwise</li>
11322</ul>
11323</li>
11324<li>
11325
11326<p>Example:</p>
11327
11328<div>
11329<div>
11330<pre class="source">{
11331 &quot;a&quot;: is_null(if_inf(null)),
11332 &quot;b&quot;: is_missing(if_inf(missing)),
11333 &quot;c&quot;: is_null(if_inf(double(&quot;INF&quot;))),
11334 &quot;d&quot;: if_inf(1, null, missing) ],
11335 &quot;e&quot;: is_null(if_inf(null, missing, 1)) ],
11336 &quot;f&quot;: is_missing(if_inf(missing, null, 1)) ],
11337 &quot;g&quot;: if_inf(float(&quot;INF&quot;), 1) ],
11338 &quot;h&quot;: to_string(if_inf(float(&quot;INF&quot;), double(&quot;NaN&quot;), 1)) ]
11339};
11340</pre></div></div>
11341</li>
11342<li>
11343
11344<p>The expected result is:</p>
11345
11346<div>
11347<div>
11348<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; }
11349</pre></div></div>
11350</li>
11351</ul>
11352<p>The function has an alias <tt>ifinf</tt>.</p></div>
11353<div class="section">
11354<h3><a name="if_nan_.28ifnan.29"></a>if_nan (ifnan)</h3>
11355<ul>
11356
11357<li>
11358
11359<p>Syntax:</p>
11360
11361<div>
11362<div>
11363<pre class="source">if_nan(expression1, expression2, ... expressionN)
11364</pre></div></div>
11365</li>
11366<li>
11367
11368<p>Finds first argument which is a non-<tt>NaN</tt> number</p>
11369</li>
11370<li>Arguments:
11371<ul>
11372
11373<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11374</ul>
11375</li>
11376<li>Return Value:
11377<ul>
11378
11379<li>a <tt>missing</tt> if <tt>missing</tt> argument was encountered before the first non-<tt>NaN</tt> number argument</li>
11380<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>
11381<li>the first non-<tt>NaN</tt> number argument otherwise</li>
11382</ul>
11383</li>
11384<li>
11385
11386<p>Example:</p>
11387
11388<div>
11389<div>
11390<pre class="source">{
11391 &quot;a&quot;: is_null(if_nan(null)),
11392 &quot;b&quot;: is_missing(if_nan(missing)),
11393 &quot;c&quot;: is_null(if_nan(double(&quot;NaN&quot;))),
11394 &quot;d&quot;: if_nan(1, null, missing) ],
11395 &quot;e&quot;: is_null(if_nan(null, missing, 1)) ],
11396 &quot;f&quot;: is_missing(if_nan(missing, null, 1)) ],
11397 &quot;g&quot;: if_nan(float(&quot;NaN&quot;), 1) ],
11398 &quot;h&quot;: to_string(if_nan(float(&quot;NaN&quot;), double(&quot;INF&quot;), 1)) ]
11399};
11400</pre></div></div>
11401</li>
11402<li>
11403
11404<p>The expected result is:</p>
11405
11406<div>
11407<div>
11408<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; }
11409</pre></div></div>
11410</li>
11411</ul>
11412<p>The function has an alias <tt>ifnan</tt>.</p></div>
11413<div class="section">
11414<h3><a name="if_nan_or_inf_.28ifnanorinf.29"></a>if_nan_or_inf (ifnanorinf)</h3>
11415<ul>
11416
11417<li>
11418
11419<p>Syntax:</p>
11420
11421<div>
11422<div>
11423<pre class="source">if_nan_or_inf(expression1, expression2, ... expressionN)
11424</pre></div></div>
11425</li>
11426<li>
11427
11428<p>Finds first argument which is a non-infinite (<tt>INF</tt> or<tt>-INF</tt>) and non-<tt>NaN</tt> number</p>
11429</li>
11430<li>Arguments:
11431<ul>
11432
11433<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11434</ul>
11435</li>
11436<li>Return Value:
11437<ul>
11438
11439<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>
11440<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>
11441<li>the first non-infinite and non-<tt>NaN</tt> number argument otherwise</li>
11442</ul>
11443</li>
11444<li>
11445
11446<p>Example:</p>
11447
11448<div>
11449<div>
11450<pre class="source">{
11451 &quot;a&quot;: is_null(if_nan_or_inf(null)),
11452 &quot;b&quot;: is_missing(if_nan_or_inf(missing)),
11453 &quot;c&quot;: is_null(if_nan_or_inf(double(&quot;NaN&quot;), double(&quot;INF&quot;))),
11454 &quot;d&quot;: if_nan_or_inf(1, null, missing) ],
11455 &quot;e&quot;: is_null(if_nan_or_inf(null, missing, 1)) ],
11456 &quot;f&quot;: is_missing(if_nan_or_inf(missing, null, 1)) ],
11457 &quot;g&quot;: if_nan_or_inf(float(&quot;NaN&quot;), float(&quot;INF&quot;), 1) ],
11458};
11459</pre></div></div>
11460</li>
11461<li>
11462
11463<p>The expected result is:</p>
11464
11465<div>
11466<div>
11467<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 }
11468</pre></div></div>
11469</li>
11470</ul>
11471<p>The function has an alias <tt>ifnanorinf</tt>.</p></div>
11472<div class="section">
11473<h3><a name="null_if_.28nullif.29"></a>null_if (nullif)</h3>
11474<ul>
11475
11476<li>
11477
11478<p>Syntax:</p>
11479
11480<div>
11481<div>
11482<pre class="source">null_if(expression1, expression2)
11483</pre></div></div>
11484</li>
11485<li>
11486
11487<p>Compares two arguments and returns <tt>null</tt> if they are equal, otherwise returns the first argument.</p>
11488</li>
11489<li>Arguments:
11490<ul>
11491
11492<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11493</ul>
11494</li>
11495<li>Return Value:
11496<ul>
11497
11498<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11499<li><tt>null</tt> if
11500<ul>
11501
11502<li>any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value, or</li>
11503<li><tt>argument1</tt> = <tt>argument2</tt></li>
11504</ul>
11505</li>
11506<li>a value of the first argument otherwise</li>
11507</ul>
11508</li>
11509<li>
11510
11511<p>Example:</p>
11512
11513<div>
11514<div>
11515<pre class="source">{
11516 &quot;a&quot;: null_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;),
11517 &quot;b&quot;: null_if(1, 2)
11518};
11519</pre></div></div>
11520</li>
11521<li>
11522
11523<p>The expected result is:</p>
11524
11525<div>
11526<div>
11527<pre class="source">{ &quot;a&quot;: null, &quot;b&quot;: 1 }
11528</pre></div></div>
11529</li>
11530</ul>
11531<p>The function has an alias <tt>nullif</tt>.</p></div>
11532<div class="section">
11533<h3><a name="missing_if_.28missingif.29"></a>missing_if (missingif)</h3>
11534<ul>
11535
11536<li>
11537
11538<p>Syntax:</p>
11539
11540<div>
11541<div>
11542<pre class="source">missing_if(expression1, expression2)
11543</pre></div></div>
11544</li>
11545<li>
11546
11547<p>Compares two arguments and returns <tt>missing</tt> if they are equal, otherwise returns the first argument.</p>
11548</li>
11549<li>Arguments:
11550<ul>
11551
11552<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11553</ul>
11554</li>
11555<li>Return Value:
11556<ul>
11557
11558<li><tt>missing</tt> if
11559<ul>
11560
11561<li>any argument is a <tt>missing</tt> value, or</li>
11562<li>no argument is a <tt>null</tt> value and <tt>argument1</tt> = <tt>argument2</tt></li>
11563</ul>
11564</li>
11565<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11566<li>a value of the first argument otherwise</li>
11567</ul>
11568</li>
11569<li>
11570
11571<p>Example:</p>
11572
11573<div>
11574<div>
11575<pre class="source">{
11576 &quot;a&quot;: missing_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)
11577 &quot;b&quot;: missing_if(1, 2),
11578};
11579</pre></div></div>
11580</li>
11581<li>
11582
11583<p>The expected result is:</p>
11584
11585<div>
11586<div>
11587<pre class="source">{ &quot;b&quot;: 1 }
11588</pre></div></div>
11589</li>
11590</ul>
11591<p>The function has an alias <tt>missingif</tt>.</p></div>
11592<div class="section">
11593<h3><a name="nan_if_.28nanif.29"></a>nan_if (nanif)</h3>
11594<ul>
11595
11596<li>
11597
11598<p>Syntax:</p>
11599
11600<div>
11601<div>
11602<pre class="source">nan_if(expression1, expression2)
11603</pre></div></div>
11604</li>
11605<li>
11606
11607<p>Compares two arguments and returns <tt>NaN</tt> value if they are equal, otherwise returns the first argument.</p>
11608</li>
11609<li>Arguments:
11610<ul>
11611
11612<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11613</ul>
11614</li>
11615<li>Return Value:
11616<ul>
11617
11618<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11619<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11620<li><tt>NaN</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11621<li>a value of the first argument otherwise</li>
11622</ul>
11623</li>
11624<li>
11625
11626<p>Example:</p>
11627
11628<div>
11629<div>
11630<pre class="source">{
11631 &quot;a&quot;: to_string(nan_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11632 &quot;b&quot;: nan_if(1, 2)
11633};
11634</pre></div></div>
11635</li>
11636<li>
11637
11638<p>The expected result is:</p>
11639
11640<div>
11641<div>
11642<pre class="source">{ &quot;a&quot;: &quot;NaN&quot;, &quot;b&quot;: 1 }
11643</pre></div></div>
11644</li>
11645</ul>
11646<p>The function has an alias <tt>nanif</tt>.</p></div>
11647<div class="section">
11648<h3><a name="posinf_if_.28posinfif.29"></a>posinf_if (posinfif)</h3>
11649<ul>
11650
11651<li>
11652
11653<p>Syntax:</p>
11654
11655<div>
11656<div>
11657<pre class="source">posinf_if(expression1, expression2)
11658</pre></div></div>
11659</li>
11660<li>
11661
11662<p>Compares two arguments and returns <tt>+INF</tt> value if they are equal, otherwise returns the first argument.</p>
11663</li>
11664<li>Arguments:
11665<ul>
11666
11667<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11668</ul>
11669</li>
11670<li>Return Value:
11671<ul>
11672
11673<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11674<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11675<li><tt>+INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11676<li>a value of the first argument otherwise</li>
11677</ul>
11678</li>
11679<li>
11680
11681<p>Example:</p>
11682
11683<div>
11684<div>
11685<pre class="source">{
11686 &quot;a&quot;: to_string(posinf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11687 &quot;b&quot;: posinf_if(1, 2)
11688};
11689</pre></div></div>
11690</li>
11691<li>
11692
11693<p>The expected result is:</p>
11694
11695<div>
11696<div>
11697<pre class="source">{ &quot;a&quot;: &quot;+INF&quot;, &quot;b&quot;: 1 }
11698</pre></div></div>
11699</li>
11700</ul>
11701<p>The function has an alias <tt>posinfif</tt>.</p></div>
11702<div class="section">
11703<h3><a name="neginf_if_.28neginfif.29"></a>neginf_if (neginfif)</h3>
11704<ul>
11705
11706<li>
11707
11708<p>Syntax:</p>
11709
11710<div>
11711<div>
11712<pre class="source">neginf_if(expression1, expression2)
11713</pre></div></div>
11714</li>
11715<li>
11716
11717<p>Compares two arguments and returns <tt>-INF</tt> value if they are equal, otherwise returns the first argument.</p>
11718</li>
11719<li>Arguments:
11720<ul>
11721
11722<li><tt>expressionI</tt> : an expression (any type is allowed).</li>
11723</ul>
11724</li>
11725<li>Return Value:
11726<ul>
11727
11728<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11729<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value</li>
11730<li><tt>-INF</tt> value of type <tt>double</tt> if <tt>argument1</tt> = <tt>argument2</tt></li>
11731<li>a value of the first argument otherwise</li>
11732</ul>
11733</li>
11734<li>
11735
11736<p>Example:</p>
11737
11738<div>
11739<div>
11740<pre class="source">{
11741 &quot;a&quot;: to_string(neginf_if(&quot;asterixdb&quot;, &quot;asterixdb&quot;)),
11742 &quot;b&quot;: neginf_if(1, 2)
11743};
11744</pre></div></div>
11745</li>
11746<li>
11747
11748<p>The expected result is:</p>
11749
11750<div>
11751<div>
11752<pre class="source">{ &quot;a&quot;: &quot;-INF&quot;, &quot;b&quot;: 1 }
11753</pre></div></div>
11754</li>
11755</ul>
11756<p>The function has an alias <tt>neginfif</tt>.</p><!--
11757 ! Licensed to the Apache Software Foundation (ASF) under one
11758 ! or more contributor license agreements. See the NOTICE file
11759 ! distributed with this work for additional information
11760 ! regarding copyright ownership. The ASF licenses this file
11761 ! to you under the Apache License, Version 2.0 (the
11762 ! "License"); you may not use this file except in compliance
11763 ! with the License. You may obtain a copy of the License at
11764 !
11765 ! http://www.apache.org/licenses/LICENSE-2.0
11766 !
11767 ! Unless required by applicable law or agreed to in writing,
11768 ! software distributed under the License is distributed on an
11769 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11770 ! KIND, either express or implied. See the License for the
11771 ! specific language governing permissions and limitations
11772 ! under the License.
11773 !-->
11774</div></div>
11775<div class="section">
11776<h2><a name="Miscellaneous_Functions"></a><a name="MiscFunctions" id="MiscFunctions">Miscellaneous Functions</a></h2>
11777<div class="section">
11778<h3><a name="uuid"></a>uuid</h3>
11779<ul>
11780
11781<li>
11782
11783<p>Syntax:</p>
11784
11785<div>
11786<div>
11787<pre class="source">uuid()
11788</pre></div></div>
11789</li>
11790<li>
11791
11792<p>Generates a <tt>uuid</tt>.</p>
11793</li>
11794<li>Arguments:
11795<ul>
11796
11797<li>none</li>
11798</ul>
11799</li>
11800<li>Return Value:
11801<ul>
11802
11803<li>a generated, random <tt>uuid</tt>.</li>
11804</ul>
11805</li>
11806</ul></div>
11807<div class="section">
11808<h3><a name="len"></a>len</h3>
11809<ul>
11810
11811<li>
11812
11813<p>Syntax:</p>
11814<p>len(array)</p>
11815</li>
11816<li>
11817
11818<p>Returns the length of the array array.</p>
11819</li>
11820<li>Arguments:
11821<ul>
11822
11823<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>
11824</ul>
11825</li>
11826<li>Return Value:
11827<ul>
11828
11829<li>an <tt>integer</tt> that represents the length of input array or the size of the input multiset,</li>
11830<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11831<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
11832</ul>
11833</li>
11834<li>
11835
11836<p>Example:</p>
11837
11838<div>
11839<div>
11840<pre class="source">len([&quot;Hello&quot;, &quot;World&quot;])
11841</pre></div></div>
11842</li>
11843<li>
11844
11845<p>The expected result is:</p>
11846
11847<div>
11848<div>
11849<pre class="source">2
11850</pre></div></div>
11851</li>
11852</ul></div>
11853<div class="section">
11854<h3><a name="not"></a>not</h3>
11855<ul>
11856
11857<li>
11858
11859<p>Syntax:</p>
11860
11861<div>
11862<div>
11863<pre class="source">not(expr)
11864</pre></div></div>
11865</li>
11866<li>
11867
11868<p>Inverts a <tt>boolean</tt> value</p>
11869</li>
11870<li>Arguments:
11871<ul>
11872
11873<li><tt>expr</tt> : an expression</li>
11874</ul>
11875</li>
11876<li>Return Value:
11877<ul>
11878
11879<li>a <tt>boolean</tt>, the inverse of <tt>expr</tt>,</li>
11880<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
11881<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value,</li>
11882<li>other non-boolean argument value will cause a type error.</li>
11883</ul>
11884</li>
11885<li>Example:
11886
11887<div>
11888<div>
11889<pre class="source">{ &quot;v1&quot;: `not`(true), &quot;v2&quot;: `not`(false), &quot;v3&quot;: `not`(null), &quot;v4&quot;: `not`(missing) };
11890</pre></div></div>
11891</li>
11892<li>
11893
11894<p>The expected result is:</p>
11895
11896<div>
11897<div>
11898<pre class="source">{ &quot;v1&quot;: false, &quot;v2&quot;: true, &quot;v3&quot;: null }
11899</pre></div></div>
11900</li>
11901</ul></div>
11902<div class="section">
11903<h3><a name="random"></a>random</h3>
11904<ul>
11905
11906<li>
11907
11908<p>Syntax:</p>
11909
11910<div>
11911<div>
11912<pre class="source">random( [seed_value] )
11913</pre></div></div>
11914</li>
11915<li>
11916
11917<p>Returns a random number, accepting an optional seed value</p>
11918</li>
11919<li>Arguments:
11920<ul>
11921
11922<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>
11923</ul>
11924</li>
11925<li>Return Value:
11926<ul>
11927
11928<li>A random number of type <tt>double</tt> between 0 and 1,</li>
11929<li><tt>missing</tt> if the argument is a <tt>missing</tt> value,</li>
11930<li><tt>null</tt> if the argument is a <tt>null</tt> value or a non-numeric value.</li>
11931</ul>
11932</li>
11933<li>
11934
11935<p>Example:</p>
11936
11937<div>
11938<div>
11939<pre class="source">{
11940 &quot;v1&quot;: random(),
11941 &quot;v2&quot;: random(unix_time_from_datetime_in_ms(current_datetime()))
11942};
11943</pre></div></div>
11944</li>
11945</ul></div>
11946<div class="section">
11947<h3><a name="range"></a>range</h3>
11948<ul>
11949
11950<li>
11951
11952<p>Syntax:</p>
11953
11954<div>
11955<div>
11956<pre class="source">range(start_numeric_value, end_numeric_value)
11957</pre></div></div>
11958</li>
11959<li>
11960
11961<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>
11962</li>
11963<li>Arguments:</li>
11964<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>
11965<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>
11966<li>Return Value:
11967<ul>
11968
11969<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>
11970</ul>
11971</li>
11972<li>Example:
11973
11974<div>
11975<div>
11976<pre class="source">range(0, 3);
11977</pre></div></div>
11978</li>
11979<li>
11980
11981<p>The expected result is:</p>
11982
11983<div>
11984<div>
11985<pre class="source">[ 0, 1, 2, 3 ]
11986</pre></div></div>
11987</li>
11988</ul></div>
11989<div class="section">
11990<h3><a name="switch_case"></a>switch_case</h3>
11991<ul>
11992
11993<li>
11994
11995<p>Syntax:</p>
11996
11997<div>
11998<div>
11999<pre class="source">switch_case(
12000 condition,
12001 case1, case1_result,
12002 case2, case2_result,
12003 ...,
12004 default, default_result
12005)
12006</pre></div></div>
12007</li>
12008<li>
12009
12010<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>
12011</li>
12012<li>Arguments:
12013<ul>
12014
12015<li><tt>condition</tt>: a variable (any type is allowed).</li>
12016<li><tt>caseI/default</tt>: a variable (any type is allowed).</li>
12017<li><tt>caseI/default_result</tt>: a variable (any type is allowed).</li>
12018</ul>
12019</li>
12020<li>Return Value:
12021<ul>
12022
12023<li><tt>caseI_result</tt> if <tt>condition</tt> matches <tt>caseI</tt>, otherwise <tt>default_result</tt>.</li>
12024</ul>
12025</li>
12026<li>Example 1:
12027
12028<div>
12029<div>
12030<pre class="source">switch_case(
12031 &quot;a&quot;,
12032 &quot;a&quot;, 0,
12033 &quot;x&quot;, 1,
12034 &quot;y&quot;, 2,
12035 &quot;z&quot;, 3
12036);
12037</pre></div></div>
12038</li>
12039<li>
12040
12041<p>The expected result is:</p>
12042
12043<div>
12044<div>
12045<pre class="source">0
12046</pre></div></div>
12047</li>
12048<li>
12049
12050<p>Example 2:</p>
12051
12052<div>
12053<div>
12054<pre class="source">switch_case(
12055 &quot;a&quot;,
12056 &quot;x&quot;, 1,
12057 &quot;y&quot;, 2,
12058 &quot;z&quot;, 3
12059);
12060</pre></div></div>
12061</li>
12062<li>
12063
12064<p>The expected result is:</p>
12065
12066<div>
12067<div>
12068<pre class="source">3
12069</pre></div></div>
12070</li>
12071</ul></div>
12072<div class="section">
12073<h3><a name="deep_equal"></a>deep_equal</h3>
12074<ul>
12075
12076<li>
12077
12078<p>Syntax:</p>
12079
12080<div>
12081<div>
12082<pre class="source">deep_equal(expr1, expr2)
12083</pre></div></div>
12084</li>
12085<li>
12086
12087<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>
12088</li>
12089<li>Arguments:
12090<ul>
12091
12092<li><tt>expr1</tt> : an expression,</li>
12093<li><tt>expr2</tt> : an expression.</li>
12094</ul>
12095</li>
12096<li>Return Value:
12097<ul>
12098
12099<li><tt>true</tt> or <tt>false</tt> depending on the data equality,</li>
12100<li><tt>missing</tt> if any argument is a <tt>missing</tt> value,</li>
12101<li><tt>null</tt> if any argument is a <tt>null</tt> value but no argument is a <tt>missing</tt> value.</li>
12102</ul>
12103</li>
12104<li>
12105
12106<p>Example:</p>
12107
12108<div>
12109<div>
12110<pre class="source">deep_equal(
12111 {
12112 &quot;id&quot;:1,
12113 &quot;project&quot;:&quot;AsterixDB&quot;,
12114 &quot;address&quot;:{&quot;city&quot;:&quot;Irvine&quot;, &quot;state&quot;:&quot;CA&quot;},
12115 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12116 },
12117 {
12118 &quot;id&quot;:1,
12119 &quot;project&quot;:&quot;AsterixDB&quot;,
12120 &quot;address&quot;:{&quot;city&quot;:&quot;San Diego&quot;, &quot;state&quot;:&quot;CA&quot;},
12121 &quot;related&quot;:[&quot;Hivestrix&quot;, &quot;Preglix&quot;, &quot;Apache VXQuery&quot;]
12122 }
12123);
12124</pre></div></div>
12125</li>
12126<li>
12127
12128<p>The expected result is:</p>
12129
12130<div>
12131<div>
12132<pre class="source">false
12133</pre></div></div>
12134</li>
12135</ul><!--
12136 ! Licensed to the Apache Software Foundation (ASF) under one
12137 ! or more contributor license agreements. See the NOTICE file
12138 ! distributed with this work for additional information
12139 ! regarding copyright ownership. The ASF licenses this file
12140 ! to you under the Apache License, Version 2.0 (the
12141 ! "License"); you may not use this file except in compliance
12142 ! with the License. You may obtain a copy of the License at
12143 !
12144 ! http://www.apache.org/licenses/LICENSE-2.0
12145 !
12146 ! Unless required by applicable law or agreed to in writing,
12147 ! software distributed under the License is distributed on an
12148 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12149 ! KIND, either express or implied. See the License for the
12150 ! specific language governing permissions and limitations
12151 ! under the License.
12152 !-->
12153</div></div>
12154<div class="section">
12155<h2><a name="Bitwise_Functions"></a><a name="BitwiseFunctions" id="BitwiseFunctions">Bitwise Functions</a></h2>
12156<p>All Bit/Binary functions can only operate on 64-bit signed integers.</p>
12157<p><b>Note:</b> All non-integer numbers and other data types result in null.</p>
12158<p><b>Note:</b> The query language uses two&#x2019;s complement representation.</p>
12159<p>When looking at the value in binary form, bit 1 is the Least Significant Bit (LSB) and bit 32 is the Most Significant Bit (MSB).</p>
12160<p>(MSB) Bit 32 &#x2192; <tt>0000 0000 0000 0000 0000 0000 0000 0000</tt> &#x2190; Bit 1 (LSB)</p>
12161<div class="section">
12162<h3><a name="bitand"></a>bitand</h3>
12163<ul>
12164
12165<li>
12166
12167<p>Syntax:</p>
12168
12169<div>
12170<div>
12171<pre class="source">BITAND(int_value1, int_value2, ... , int_valueN)
12172</pre></div></div>
12173</li>
12174<li>
12175
12176<p>Returns the result of a bitwise AND operation performed on all input integer values.</p>
12177<p>The bitwise AND operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If all bits are 1, then the corresponding result bit is set to 1; otherwise it is set to 0 (zero).</p>
12178</li>
12179<li>
12180
12181<p>Arguments:</p>
12182<ul>
12183
12184<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12185</ul>
12186</li>
12187<li>
12188
12189<p>Return Value:</p>
12190<ul>
12191
12192<li>An integer, representing the bitwise AND between all of the input integers.</li>
12193</ul>
12194</li>
12195<li>
12196
12197<p>Limitations:</p>
12198<ul>
12199
12200<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12201</ul>
12202</li>
12203<li>
12204
12205<p>Example 1:</p>
12206<p>Compare 3 (0011 in binary) and 6 (0110 in binary).</p>
12207
12208<div>
12209<div>
12210<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6) };
12211</pre></div></div>
12212</li>
12213<li>
12214
12215<p>The expected result is:</p>
12216
12217<div>
12218<div>
12219<pre class="source">{ &quot;BitAND&quot;: 2 }
12220</pre></div></div>
12221
12222<p>This results in 2 (0010 in binary) because only bit 2 is set in both 3 (00<b>1</b>1) and 6 (01<b>1</b>0).</p>
12223</li>
12224<li>
12225
12226<p>Example 2:</p>
12227<p>Compare 4.5 and 3 (0011 in binary).</p>
12228
12229<div>
12230<div>
12231<pre class="source">{ &quot;BitAND&quot;: BITAND(4.5,3) };
12232</pre></div></div>
12233</li>
12234<li>
12235
12236<p>The expected result is:</p>
12237
12238<div>
12239<div>
12240<pre class="source">{ &quot;BitAND&quot;: null }
12241</pre></div></div>
12242
12243<p>The result is null because 4.5 is not an integer.</p>
12244</li>
12245<li>
12246
12247<p>Example 3:</p>
12248<p>Compare 4.0 (0100 in binary) and 3 (0011 in binary).</p>
12249
12250<div>
12251<div>
12252<pre class="source">{ &quot;BitAND&quot;: BITAND(4.0,3) };
12253</pre></div></div>
12254</li>
12255<li>
12256
12257<p>The expected result is:</p>
12258
12259<div>
12260<div>
12261<pre class="source">{ &quot;BitAND&quot;: 0 }
12262</pre></div></div>
12263
12264<p>This results in 0 (zero) because 4.0 (0100) and 3 (0011) do not share any bits that are both 1.</p>
12265</li>
12266<li>
12267
12268<p>Example 4:</p>
12269<p>Compare 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12270
12271<div>
12272<div>
12273<pre class="source">{ &quot;BitAND&quot;: BITAND(3,6,15) };
12274</pre></div></div>
12275</li>
12276<li>
12277
12278<p>The expected result is:</p>
12279
12280<div>
12281<div>
12282<pre class="source">{ &quot;BitAND&quot;: 2 }
12283</pre></div></div>
12284
12285<p>This results in 2 (0010 in binary) because only the 2nd bit from the right is 1 in all three numbers.</p>
12286</li>
12287</ul></div>
12288<div class="section">
12289<h3><a name="bitclear"></a>bitclear</h3>
12290<ul>
12291
12292<li>
12293
12294<p>Syntax:</p>
12295
12296<div>
12297<div>
12298<pre class="source">BITCLEAR(int_value, positions)
12299</pre></div></div>
12300</li>
12301<li>
12302
12303<p>Returns the result after clearing the specified bit, or array of bits in <tt>int_value</tt> using the given <tt>positions</tt>.</p>
12304<p><b>Note:</b> Specifying a negative or zero bit position makes the function return a null.</p>
12305</li>
12306<li>
12307
12308<p>Arguments:</p>
12309<ul>
12310
12311<li>
12312
12313<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to clear.</p>
12314</li>
12315<li>
12316
12317<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be cleared.</p>
12318</li>
12319</ul>
12320</li>
12321<li>
12322
12323<p>Return Value:</p>
12324<ul>
12325
12326<li>An integer, representing the result after clearing the bit or bits specified.</li>
12327</ul>
12328</li>
12329<li>
12330
12331<p>Limitations:</p>
12332<ul>
12333
12334<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12335</ul>
12336</li>
12337<li>
12338
12339<p>Example 1:</p>
12340<p>Clear bit 1 from 6 (0110 in binary).</p>
12341
12342<div>
12343<div>
12344<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,1) };
12345</pre></div></div>
12346</li>
12347<li>
12348
12349<p>The expected result is:</p>
12350
12351<div>
12352<div>
12353<pre class="source">{ &quot;BitCLEAR&quot;: 6 }
12354</pre></div></div>
12355
12356<p>This results in 6 (011<b>0</b> in binary) because bit 1 was already zero.</p>
12357</li>
12358<li>
12359
12360<p>Example 2:</p>
12361<p>Clear bits 1 and 2 from 6 (01<b>10</b> in binary).</p>
12362
12363<div>
12364<div>
12365<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(6,[1,2]) };
12366</pre></div></div>
12367</li>
12368<li>
12369
12370<p>The expected result is:</p>
12371
12372<div>
12373<div>
12374<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12375</pre></div></div>
12376
12377<p>This results in 4 (01<b>0</b>0 in binary) because bit 2 changed to zero.</p>
12378</li>
12379<li>
12380
12381<p>Example 3:</p>
12382<p>Clear bits 1, 2, 4, and 5 from 31 (0<b>11</b>1<b>11</b> in binary).</p>
12383
12384<div>
12385<div>
12386<pre class="source">{ &quot;BitCLEAR&quot;: BITCLEAR(31,[1,2,4,5]) };
12387</pre></div></div>
12388</li>
12389<li>
12390
12391<p>The expected result is:</p>
12392
12393<div>
12394<div>
12395<pre class="source">{ &quot;BitCLEAR&quot;: 4 }
12396</pre></div></div>
12397
12398<p>This results in 4 (0<b>00</b>1<b>00</b>) because bits 1, 2, 4, and 5 changed to zero.</p>
12399</li>
12400</ul></div>
12401<div class="section">
12402<h3><a name="bitnot"></a>bitnot</h3>
12403<ul>
12404
12405<li>
12406
12407<p>Syntax:</p>
12408
12409<div>
12410<div>
12411<pre class="source">BITNOT(int_value)
12412</pre></div></div>
12413</li>
12414<li>
12415
12416<p>Returns the results of a bitwise logical NOT operation performed on an integer value.</p>
12417<p>The bitwise logical NOT operation reverses the bits in the value. For each value bit that is 1, the corresponding result bit will be set to 0 (zero); and for each value bit that is 0 (zero), the corresponding result bit will be set to 1.</p>
12418<p><b>Note:</b> All bits of the integer will be altered by this operation.</p>
12419</li>
12420<li>
12421
12422<p>Arguments:</p>
12423<ul>
12424
12425<li><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bits to reverse.</li>
12426</ul>
12427</li>
12428<li>
12429
12430<p>Return Value:</p>
12431<ul>
12432
12433<li>An integer, representing the result after performing the logical NOT operation.</li>
12434</ul>
12435</li>
12436<li>
12437
12438<p>Limitations:</p>
12439<ul>
12440
12441<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12442</ul>
12443</li>
12444<li>
12445
12446<p>Example 1:</p>
12447<p>Perform the NOT operation on 3 (0000 0000 0000 0000 0000 0000 0000 0011 in binary).</p>
12448
12449<div>
12450<div>
12451<pre class="source">{ &quot;BitNOT&quot;: BITNOT(3) };
12452</pre></div></div>
12453</li>
12454<li>
12455
12456<p>The expected result is:</p>
12457
12458<div>
12459<div>
12460<pre class="source">{ &quot;BitNOT&quot;: -4 }
12461</pre></div></div>
12462
12463<p>This results in -4 (<b>1111 1111 1111 1111 1111 1111 1111 1100</b> in binary) because all bits changed.</p>
12464</li>
12465</ul></div>
12466<div class="section">
12467<h3><a name="bitor"></a>bitor</h3>
12468<ul>
12469
12470<li>
12471
12472<p>Syntax:</p>
12473
12474<div>
12475<div>
12476<pre class="source">BITOR(int_value1, int_value2, ... , int_valueN)
12477</pre></div></div>
12478</li>
12479<li>
12480
12481<p>Returns the result of a bitwise inclusive OR operation performed on all input integer values.</p>
12482<p>The bitwise inclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of every other <tt>int_value</tt>. If any bit is 1, the corresponding result bit is set to 1; otherwise, it is set to 0 (zero).</p>
12483</li>
12484<li>
12485
12486<p>Arguments:</p>
12487<ul>
12488
12489<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
12490</ul>
12491</li>
12492<li>
12493
12494<p>Return Value:</p>
12495<ul>
12496
12497<li>An integer, representing the bitwise OR between all of the input integers.</li>
12498</ul>
12499</li>
12500<li>
12501
12502<p>Limitations:</p>
12503<ul>
12504
12505<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12506</ul>
12507</li>
12508<li>
12509
12510<p>Example 1:</p>
12511<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary).</p>
12512
12513<div>
12514<div>
12515<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6) };
12516</pre></div></div>
12517</li>
12518<li>
12519
12520<p>The expected result is:</p>
12521
12522<div>
12523<div>
12524<pre class="source">{ &quot;BitOR&quot;: 7 }
12525</pre></div></div>
12526
12527<p>This results in 7 (0<b>111</b> in binary) because at least 1 bit of each (00<b>11</b> and 0<b>11</b>0) is 1 in bits 1, 2, and 3.</p>
12528</li>
12529<li>
12530
12531<p>Example 2:</p>
12532<p>Perform OR on 3 (0011 in binary) and -4 (1000 0000 0000 &#x2026; 0000 1100 in binary).</p>
12533
12534<div>
12535<div>
12536<pre class="source">{ &quot;BitOR&quot;: BITOR(3,-4) };
12537</pre></div></div>
12538</li>
12539<li>
12540
12541<p>The expected result is:</p>
12542
12543<div>
12544<div>
12545<pre class="source">{ &quot;BitOR&quot;: -1 }
12546</pre></div></div>
12547
12548<p>This results in -1 (<b>1111 1111 1111 &#x2026; 1111 1111</b> in binary) because the two 1 bits in 3 fill in the two 0 bits in -4 to turn on all the bits.</p>
12549</li>
12550<li>
12551
12552<p>Example 3:</p>
12553<p>Perform OR on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
12554
12555<div>
12556<div>
12557<pre class="source">{ &quot;BitOR&quot;: BITOR(3,6,15) };
12558</pre></div></div>
12559</li>
12560<li>
12561
12562<p>The expected result is:</p>
12563
12564<div>
12565<div>
12566<pre class="source">{ &quot;BitOR&quot;: 15 }
12567</pre></div></div>
12568
12569<p>This results in 15 (1111 in binary) because there is at least one 1 in each of the four rightmost bits.</p>
12570</li>
12571</ul></div>
12572<div class="section">
12573<h3><a name="bitset"></a>bitset</h3>
12574<ul>
12575
12576<li>
12577
12578<p>Syntax:</p>
12579
12580<div>
12581<div>
12582<pre class="source">BITSET(int_value, positions)
12583</pre></div></div>
12584</li>
12585<li>
12586
12587<p>Returns the result after setting the specified bit <tt>position</tt>, or array of bit positions, to 1 in the given <tt>int_value</tt>.</p>
12588<p><b>Note:</b> Specifying a negative or zero position makes the function return a null.</p>
12589</li>
12590<li>
12591
12592<p>Arguments:</p>
12593<ul>
12594
12595<li>
12596
12597<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to set.</p>
12598</li>
12599<li>
12600
12601<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be set.</p>
12602</li>
12603</ul>
12604</li>
12605<li>
12606
12607<p>Return Value:</p>
12608<ul>
12609
12610<li>An integer, representing the result after setting the bit or bits specified. If the bit is already set, then it stays set.</li>
12611</ul>
12612</li>
12613<li>
12614
12615<p>Limitations:</p>
12616<ul>
12617
12618<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12619</ul>
12620</li>
12621<li>
12622
12623<p>Example 1:</p>
12624<p>Set bit 1 in the value 6 (011<b>0</b> in binary).</p>
12625
12626<div>
12627<div>
12628<pre class="source">{ &quot;BitSET&quot;: BITSET(6,1) };
12629</pre></div></div>
12630</li>
12631<li>
12632
12633<p>The expected result is:</p>
12634
12635<div>
12636<div>
12637<pre class="source">{ &quot;BitSET&quot;: 7 }
12638</pre></div></div>
12639
12640<p>This results in 7 (011<b>1</b> in binary) because bit 1 changed to 1.</p>
12641</li>
12642<li>
12643
12644<p>Example 2:</p>
12645<p>Set bits 1 and 2 in the value 6 (01<b>10</b> in binary).</p>
12646
12647<div>
12648<div>
12649<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,2]) };
12650</pre></div></div>
12651</li>
12652<li>
12653
12654<p>The expected result is:</p>
12655
12656<div>
12657<div>
12658<pre class="source">{ &quot;BitSET&quot;: 7 }
12659</pre></div></div>
12660
12661<p>This also results in 7 (01<b>11</b> in binary) because bit 1 changed while bit 2 remained the same.</p>
12662</li>
12663<li>
12664
12665<p>Example 3:</p>
12666<p>Set bits 1 and 4 in the value 6 (<b>0</b>11<b>0</b> in binary).</p>
12667
12668<div>
12669<div>
12670<pre class="source">{ &quot;BitSET&quot;: BITSET(6,[1,4]) };
12671</pre></div></div>
12672</li>
12673<li>
12674
12675<p>The expected result is:</p>
12676
12677<div>
12678<div>
12679<pre class="source">{ &quot;BitSET&quot;: 15 }
12680</pre></div></div>
12681
12682<p>This results in 15 (<b>1</b>11<b>1</b> in binary) because bit 1 and 4 changed to ones.</p>
12683</li>
12684</ul></div>
12685<div class="section">
12686<h3><a name="bitshift"></a>bitshift</h3>
12687<ul>
12688
12689<li>
12690
12691<p>Syntax:</p>
12692
12693<div>
12694<div>
12695<pre class="source">BITSHIFT(int_value, shift_amount[, rotate])
12696</pre></div></div>
12697</li>
12698<li>
12699
12700<p>Returns the result of a bit shift operation performed on the integer value <tt>int_value</tt>. The <tt>shift_amount</tt> supports left and right shifts. These are logical shifts. The third parameter <tt>rotate</tt> supports circular shift. This is similar to the BitROTATE function in Oracle.</p>
12701</li>
12702<li>
12703
12704<p>Arguments:</p>
12705<ul>
12706
12707<li>
12708
12709<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to shift.</p>
12710</li>
12711<li>
12712
12713<p><tt>shift_amount</tt>: An integer, or any valid expression which evaluates to an integer, that contains the number of bits to shift.</p>
12714<ul>
12715
12716<li>
12717
12718<p>A positive (+) number means this is a LEFT shift.</p>
12719</li>
12720<li>
12721
12722<p>A negative (-) number means this is a RIGHT shift.</p>
12723</li>
12724</ul>
12725</li>
12726<li>
12727
12728<p><tt>rotate</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean, where:</p>
12729<ul>
12730
12731<li>
12732
12733<p>FALSE means this is a LOGICAL shift, where bits shifted off the end of a value are considered lost.</p>
12734</li>
12735<li>
12736
12737<p>TRUE means this is a CIRCULAR shift (shift-and-rotate operation), where bits shifted off the end of a value are rotated back onto the value at the <i>other</i> end. In other words, the bits rotate in what might be thought of as a circular pattern; therefore, these bits are not lost.</p>
12738</li>
12739</ul>
12740<p>If omitted, the default is FALSE.</p>
12741</li>
12742</ul>
12743<p>For comparison, see the below table.</p>
12744<table border="0" class="table table-striped">
12745<thead>
12746
12747<tr class="a">
12748<th> Input </th>
12749<th> Shift </th>
12750<th> Result of Logical Shift (Rotate FALSE) </th>
12751<th> Result of Circular Shift (Rotate TRUE) </th></tr>
12752</thead><tbody>
12753
12754<tr class="b">
12755<td> 6 (0000 0110) </td>
12756<td> 4 </td>
12757<td> 96 (0110 0000) </td>
12758<td> 96 (0110 0000) </td></tr>
12759<tr class="a">
12760<td> 6 (0000 0110) </td>
12761<td> 3 </td>
12762<td> 48 (0011 0000) </td>
12763<td> 48 (0011 0000) </td></tr>
12764<tr class="b">
12765<td> 6 (0000 0110) </td>
12766<td> 2 </td>
12767<td> 24 (0001 1000) </td>
12768<td> 24 (0001 1000) </td></tr>
12769<tr class="a">
12770<td> 6 (0000 0110) </td>
12771<td> 1 </td>
12772<td> 12 (0000 1100) </td>
12773<td> 12 (0000 1100) </td></tr>
12774<tr class="b">
12775<td> <b>6 (0000 0110)</b> </td>
12776<td> <b>0</b> </td>
12777<td> <b>6 (0000 0110)</b> </td>
12778<td> <b>6 (0000 0110)</b> </td></tr>
12779<tr class="a">
12780<td> 6 (0000 0110) </td>
12781<td> -1 </td>
12782<td> 3 (0000 0011) </td>
12783<td> 3 (0000 0011) </td></tr>
12784<tr class="b">
12785<td> 6 (0000 0110) </td>
12786<td> -2 </td>
12787<td> 1 (0000 0001) </td>
12788<td> -9223372036854775807 (1000 0000 &#x2026; 0000 0001) </td></tr>
12789<tr class="a">
12790<td> 6 (0000 0110) </td>
12791<td> -3 </td>
12792<td> 0 (0000 0000) </td>
12793<td> -4611686018427387904 (1100 0000 &#x2026; 0000 0000) </td></tr>
12794<tr class="b">
12795<td> 6 (0000 0110) </td>
12796<td> -4 </td>
12797<td> 0 (0000 0000) </td>
12798<td> 6917529027641081856 (0110 0000 &#x2026; 0000 0000) </td></tr>
12799</tbody>
12800</table>
12801</li>
12802<li>
12803
12804<p>Return Value:</p>
12805<ul>
12806
12807<li>An integer, representing the result of either a logical or circular shift of the given integer.</li>
12808</ul>
12809</li>
12810<li>
12811
12812<p>Limitations:</p>
12813<ul>
12814
12815<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12816</ul>
12817</li>
12818<li>
12819
12820<p>Example 1:</p>
12821<p>Logical left shift of the number 6 (0110 in binary) by one bit.</p>
12822
12823<div>
12824<div>
12825<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,1,FALSE) };
12826</pre></div></div>
12827</li>
12828<li>
12829
12830<p>The expected result is:</p>
12831
12832<div>
12833<div>
12834<pre class="source">{ &quot;BitSHIFT&quot;: 12 }
12835</pre></div></div>
12836
12837<p>This results in 12 (1100 in binary) because the 1-bits moved from positions 2 and 3 to positions 3 and 4.</p>
12838</li>
12839<li>
12840
12841<p>Example 2:</p>
12842<p>Logical right shift of the number 6 (0110 in binary) by two bits.</p>
12843
12844<div>
12845<div>
12846<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2) };
12847</pre></div></div>
12848</li>
12849<li>
12850
12851<p>The expected result is:</p>
12852
12853<div>
12854<div>
12855<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12856</pre></div></div>
12857
12858<p>This results in 1 (0001 in binary) because the 1-bit in position 3 moved to position 1 and the 1-bit in position 2 was dropped.</p>
12859</li>
12860<li>
12861
12862<p>Example 2b:</p>
12863<p>Circular right shift of the number 6 (0110 in binary) by two bits.</p>
12864
12865<div>
12866<div>
12867<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(6,-2,TRUE) };
12868</pre></div></div>
12869</li>
12870<li>
12871
12872<p>The expected result is:</p>
12873
12874<div>
12875<div>
12876<pre class="source">{ &quot;BitSHIFT&quot;: -9223372036854775807 }
12877</pre></div></div>
12878
12879<p>This results in -9223372036854775807 (1100 0000 0000 0000 0000 0000 0000 0000 in binary) because the two 1-bits wrapped right, around to the Most Significant Digit position and changed the integer&#x2019;s sign to negative.</p>
12880</li>
12881<li>
12882
12883<p>Example 3:</p>
12884<p>Circular left shift of the number 524288 (1000 0000 0000 0000 0000 in binary) by 45 bits.</p>
12885
12886<div>
12887<div>
12888<pre class="source">{ &quot;BitSHIFT&quot;: BITSHIFT(524288,45,TRUE) };
12889</pre></div></div>
12890</li>
12891<li>
12892
12893<p>The expected result is:</p>
12894
12895<div>
12896<div>
12897<pre class="source">{ &quot;BitSHIFT&quot;: 1 }
12898</pre></div></div>
12899
12900<p>This results in 1 because the 1-bit wrapped left, around to the Least Significant Digit position.</p>
12901</li>
12902</ul></div>
12903<div class="section">
12904<h3><a name="bittest"></a>bittest</h3>
12905<ul>
12906
12907<li>
12908
12909<p>Syntax:</p>
12910
12911<div>
12912<div>
12913<pre class="source">BITTEST(int_value, positions [, all_set])
12914</pre></div></div>
12915</li>
12916<li>
12917
12918<p>Returns TRUE if the specified bit, or bits, is a 1; otherwise, returns FALSE if the specified bit, or bits, is a 0 (zero).</p>
12919<p><b>Note:</b> Specifying a negative or zero bit position will result in null being returned.</p>
12920</li>
12921<li>
12922
12923<p>Arguments:</p>
12924<ul>
12925
12926<li>
12927
12928<p><tt>int_value</tt>: An integer, or any valid expression which evaluates to an integer, that contains the target bit or bits to test.</p>
12929</li>
12930<li>
12931
12932<p><tt>positions</tt>: An integer or an array of integers specifying the position or positions to be tested.</p>
12933</li>
12934<li>
12935
12936<p><tt>all_set</tt>: (Optional) A boolean, or any valid expression which evaluates to a boolean.</p>
12937<ul>
12938
12939<li>
12940
12941<p>When <tt>all_set</tt> is FALSE, then it returns TRUE even if one bit in one of the positions is set.</p>
12942</li>
12943<li>
12944
12945<p>When <tt>all_set</tt> is TRUE, then it returns TRUE only if all input positions are set.</p>
12946</li>
12947</ul>
12948<p>If omitted, the default is FALSE.</p>
12949</li>
12950</ul>
12951</li>
12952<li>
12953
12954<p>Return Value:</p>
12955<ul>
12956
12957<li>A boolean, that follows the below table:
12958<table border="0" class="table table-striped">
12959<thead>
12960
12961<tr class="a">
12962<th> <tt>int_value</tt> </th>
12963<th> <tt>all_set</tt> </th>
12964<th> Return Value </th></tr>
12965</thead><tbody>
12966
12967<tr class="b">
12968<td> <i>all</i> specified bits are TRUE </td>
12969<td> FALSE </td>
12970<td> TRUE </td></tr>
12971<tr class="a">
12972<td> <i>all</i> specified bits are TRUE </td>
12973<td> TRUE </td>
12974<td> TRUE </td></tr>
12975<tr class="b">
12976<td> <i>some</i> specified bits are TRUE </td>
12977<td> FALSE </td>
12978<td> TRUE </td></tr>
12979<tr class="a">
12980<td> <i>some</i> specified bits are TRUE </td>
12981<td> TRUE </td>
12982<td> FALSE </td></tr>
12983</tbody>
12984</table>
12985</li>
12986</ul>
12987</li>
12988<li>
12989
12990<p>Limitations:</p>
12991<ul>
12992
12993<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
12994</ul>
12995</li>
12996<li>
12997
12998<p>Example 1:</p>
12999<p>In the number 6 (0110 in binary), is bit 1 set?</p>
13000
13001<div>
13002<div>
13003<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,1) };
13004</pre></div></div>
13005</li>
13006<li>
13007
13008<p>The expected result is:</p>
13009
13010<div>
13011<div>
13012<pre class="source">{ &quot;IsBitSET&quot;: false }
13013</pre></div></div>
13014
13015<p>This returns FALSE because bit 1 of 6 (011<b>0</b> in binary) is not set to 1.</p>
13016</li>
13017<li>
13018
13019<p>Example 2:</p>
13020<p>In the number 1, is either bit 1 or bit 2 set?</p>
13021
13022<div>
13023<div>
13024<pre class="source">{ &quot;BitTEST&quot;: BITTEST(1,[1,2],FALSE) };
13025</pre></div></div>
13026</li>
13027<li>
13028
13029<p>The expected result is:</p>
13030
13031<div>
13032<div>
13033<pre class="source">{ &quot;BitTEST&quot;: true }
13034</pre></div></div>
13035
13036<p>This returns TRUE because bit 1 of the number 1 (000<b>1</b> in binary) is set to 1.</p>
13037</li>
13038<li>
13039
13040<p>Example 3:</p>
13041<p>In the number 6 (0110 in binary), are both bits 2 and 3 set?</p>
13042
13043<div>
13044<div>
13045<pre class="source">{ &quot;IsBitSET&quot;: ISBITSET(6,[2,3],TRUE) };
13046</pre></div></div>
13047</li>
13048<li>
13049
13050<p>The expected result is:</p>
13051
13052<div>
13053<div>
13054<pre class="source">{ &quot;IsBitSET&quot;: true }
13055</pre></div></div>
13056
13057<p>This returns TRUE because both bits 2 and 3 in the number 6 (0<b>11</b>0 in binary) are set to 1.</p>
13058</li>
13059<li>
13060
13061<p>Example 4:</p>
13062<p>In the number 6 (0110 in binary), are all the bits in positions 1 through 3 set?</p>
13063
13064<div>
13065<div>
13066<pre class="source">{ &quot;BitTEST&quot;: BITTEST(6,[1,3],TRUE) };
13067</pre></div></div>
13068</li>
13069<li>
13070
13071<p>The expected result is:</p>
13072
13073<div>
13074<div>
13075<pre class="source">{ &quot;BitTEST&quot;: false }
13076</pre></div></div>
13077
13078<p>This returns FALSE because bit 1 in the number 6 (011<b>0</b> in binary) is set to 0 (zero).</p>
13079</li>
13080</ul>
13081<p>The function has an alias <tt>isbitset</tt>.</p></div>
13082<div class="section">
13083<h3><a name="bitxor"></a>bitxor</h3>
13084<ul>
13085
13086<li>
13087
13088<p>Syntax:</p>
13089
13090<div>
13091<div>
13092<pre class="source">BITXOR(int_value1, int_value2, ... , int_valueN)
13093</pre></div></div>
13094</li>
13095<li>
13096
13097<p>Returns the result of a bitwise Exclusive OR operation performed on two or more integer values.</p>
13098<p>The bitwise Exclusive OR operation compares each bit of <tt>int_value1</tt> to the corresponding bit of <tt>int_value2</tt>.</p>
13099<p>If there are more than two input values, the first two are compared; then their result is compared to the next input value; and so on.</p>
13100<p>When the compared bits do not match, the result bit is 1; otherwise, the compared bits do match, and the result bit is 0 (zero), as summarized:</p>
13101<table border="0" class="table table-striped">
13102<thead>
13103
13104<tr class="a">
13105<th> Bit 1 </th>
13106<th> Bit 2 </th>
13107<th> XOR Result Bit </th></tr>
13108</thead><tbody>
13109
13110<tr class="b">
13111<td> 0 </td>
13112<td> 0 </td>
13113<td> 0 </td></tr>
13114<tr class="a">
13115<td> 0 </td>
13116<td> 1 </td>
13117<td> 1 </td></tr>
13118<tr class="b">
13119<td> 1 </td>
13120<td> 0 </td>
13121<td> 1 </td></tr>
13122<tr class="a">
13123<td> 1 </td>
13124<td> 1 </td>
13125<td> 0 </td></tr>
13126</tbody>
13127</table>
13128</li>
13129<li>
13130
13131<p>Arguments:</p>
13132<ul>
13133
13134<li><tt>int_valueI</tt>: Integers, or any valid expressions which evaluate to integers, that are used to compare.</li>
13135</ul>
13136</li>
13137<li>
13138
13139<p>Return Value:</p>
13140<ul>
13141
13142<li>An integer, representing the bitwise XOR between the input integers.</li>
13143</ul>
13144</li>
13145<li>
13146
13147<p>Limitations:</p>
13148<ul>
13149
13150<li>Input values must be integers (such as 1 or 1.0) and cannot contain decimals (such as 1.2).</li>
13151</ul>
13152</li>
13153<li>
13154
13155<p>Example 1:</p>
13156<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary).</p>
13157
13158<div>
13159<div>
13160<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6) };
13161</pre></div></div>
13162</li>
13163<li>
13164
13165<p>The expected result is:</p>
13166
13167<div>
13168<div>
13169<pre class="source">{ &quot;BitXOR&quot;: 5 }
13170</pre></div></div>
13171
13172<p>This returns 5 (0101 in binary) because the 1st bit pair and 3rd bit pair are different (resulting in 1) while the 2nd bit pair and 4th bit pair are the same (resulting in 0):</p>
13173
13174<div>
13175<div>
13176<pre class="source">0011 (3)
131770110 (6)
13178====
131790101 (5)
13180</pre></div></div>
13181</li>
13182<li>
13183
13184<p>Example 2:</p>
13185<p>Perform the XOR operation on 3 (0011 in binary) and 6 (0110 in binary) and 15 (1111 in binary).</p>
13186
13187<div>
13188<div>
13189<pre class="source">{ &quot;BitXOR&quot;: BITXOR(3,6,15) };
13190</pre></div></div>
13191</li>
13192<li>
13193
13194<p>The expected result is:</p>
13195
13196<div>
13197<div>
13198<pre class="source">{ &quot;BitXOR&quot;: 10 }
13199</pre></div></div>
13200
13201<p>This returns 10 (1010 in binary) because 3 XOR 6 equals 5 (0101 in binary), and then 5 XOR 15 equals 10 (1010 in binary).</p>
13202</li>
13203</ul><!--
13204 ! Licensed to the Apache Software Foundation (ASF) under one
13205 ! or more contributor license agreements. See the NOTICE file
13206 ! distributed with this work for additional information
13207 ! regarding copyright ownership. The ASF licenses this file
13208 ! to you under the Apache License, Version 2.0 (the
13209 ! "License"); you may not use this file except in compliance
13210 ! with the License. You may obtain a copy of the License at
13211 !
13212 ! http://www.apache.org/licenses/LICENSE-2.0
13213 !
13214 ! Unless required by applicable law or agreed to in writing,
13215 ! software distributed under the License is distributed on an
13216 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13217 ! KIND, either express or implied. See the License for the
13218 ! specific language governing permissions and limitations
13219 ! under the License.
13220 !-->
13221</div></div>
13222<div class="section">
13223<h2><a name="Window_Functions"></a><a name="WindowFunctions" id="WindowFunctions">Window Functions</a></h2>
13224<p>Window functions are used to compute an aggregate or cumulative value, based on a portion of the tuples selected by a query. For each input tuple, a movable window of tuples is defined. The window determines the tuples to be used by the window function.</p>
13225<p>The tuples are not grouped into a single output tuple &#x2014; each tuple remains separate in the query output.</p>
13226<p>All window functions must be used with an OVER clause. Refer to <a href="manual.html#Over_clauses">Window Queries</a> for details.</p>
13227<p>Window functions cannot appear in the FROM clause clause or LIMIT clause.</p>
13228<div class="section">
13229<h3><a name="cume_dist"></a>cume_dist</h3>
13230<ul>
13231
13232<li>
13233
13234<p>Syntax:</p>
13235
13236<div>
13237<div>
13238<pre class="source">CUME_DIST() OVER ([window-partition-clause] [window-order-clause])
13239</pre></div></div>
13240</li>
13241<li>
13242
13243<p>Returns the percentile rank of the current tuple as part of the cumulative distribution &#x2013; that is, the number of tuples ranked lower than or equal to the current tuple, including the current tuple, divided by the total number of tuples in the window partition.</p>
13244<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (1.0) for each tuple.</p>
13245</li>
13246<li>
13247
13248<p>Arguments:</p>
13249<ul>
13250
13251<li>None.</li>
13252</ul>
13253</li>
13254<li>
13255
13256<p>Clauses:</p>
13257<ul>
13258
13259<li>
13260
13261<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13262</li>
13263<li>
13264
13265<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13266</li>
13267</ul>
13268</li>
13269<li>
13270
13271<p>Return Value:</p>
13272<ul>
13273
13274<li>A number greater than 0 and less than or equal to 1. The higher the value, the higher the ranking.</li>
13275</ul>
13276</li>
13277<li>
13278
13279<p>Example:</p>
13280<p>For each author, find the cumulative distribution of all messages in order of message ID.</p>
13281
13282<div>
13283<div>
13284<pre class="source">SELECT m.messageId, m.authorId, CUME_DIST() OVER (
13285 PARTITION BY m.authorId
13286 ORDER BY m.messageId
13287) AS `rank`
13288FROM GleambookMessages AS m;
13289</pre></div></div>
13290</li>
13291<li>
13292
13293<p>The expected result is:</p>
13294
13295<div>
13296<div>
13297<pre class="source">[
13298 {
13299 &quot;rank&quot;: 0.2,
13300 &quot;messageId&quot;: 2,
13301 &quot;authorId&quot;: 1
13302 },
13303 {
13304 &quot;rank&quot;: 0.4,
13305 &quot;messageId&quot;: 4,
13306 &quot;authorId&quot;: 1
13307 },
13308 {
13309 &quot;rank&quot;: 0.6,
13310 &quot;messageId&quot;: 8,
13311 &quot;authorId&quot;: 1
13312 },
13313 {
13314 &quot;rank&quot;: 0.8,
13315 &quot;messageId&quot;: 10,
13316 &quot;authorId&quot;: 1
13317 },
13318 {
13319 &quot;rank&quot;: 1,
13320 &quot;messageId&quot;: 11,
13321 &quot;authorId&quot;: 1
13322 },
13323 {
13324 &quot;rank&quot;: 0.5,
13325 &quot;messageId&quot;: 3,
13326 &quot;authorId&quot;: 2
13327 },
13328 {
13329 &quot;rank&quot;: 1,
13330 &quot;messageId&quot;: 6,
13331 &quot;authorId&quot;: 2
13332 }
13333]
13334</pre></div></div>
13335</li>
13336</ul></div>
13337<div class="section">
13338<h3><a name="dense_rank"></a>dense_rank</h3>
13339<ul>
13340
13341<li>
13342
13343<p>Syntax:</p>
13344
13345<div>
13346<div>
13347<pre class="source">DENSE_RANK() OVER ([window-partition-clause] [window-order-clause])
13348</pre></div></div>
13349</li>
13350<li>
13351
13352<p>Returns the dense rank of the current tuple &#x2013; that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
13353<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
13354<p>For this function, when any tuples have the same rank, the rank of the next tuple will be consecutive, so there will not be a gap in the sequence of returned values. For example, if there are three tuples ranked 2, the next dense rank is 3.</p>
13355</li>
13356<li>
13357
13358<p>Arguments:</p>
13359<ul>
13360
13361<li>None.</li>
13362</ul>
13363</li>
13364<li>
13365
13366<p>Clauses:</p>
13367<ul>
13368
13369<li>
13370
13371<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13372</li>
13373<li>
13374
13375<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13376</li>
13377</ul>
13378</li>
13379<li>
13380
13381<p>Return Value:</p>
13382<ul>
13383
13384<li>An integer, greater than or equal to 1.</li>
13385</ul>
13386</li>
13387<li>
13388
13389<p>Example:</p>
13390<p>For each author, find the dense rank of all messages in order of location.</p>
13391
13392<div>
13393<div>
13394<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
13395DENSE_RANK() OVER (
13396 PARTITION BY m.authorId
13397 ORDER BY m.senderLocation[1]
13398) AS `rank`
13399FROM GleambookMessages AS m;
13400</pre></div></div>
13401</li>
13402<li>
13403
13404<p>The expected result is:</p>
13405
13406<div>
13407<div>
13408<pre class="source">[
13409 {
13410 &quot;rank&quot;: 1,
13411 &quot;authorId&quot;: 1,
13412 &quot;messageId&quot;: 10,
13413 &quot;longitude&quot;: 70.01
13414 },
13415 {
13416 &quot;rank&quot;: 2,
13417 &quot;authorId&quot;: 1,
13418 &quot;messageId&quot;: 11,
13419 &quot;longitude&quot;: 77.49
13420 },
13421 {
13422 &quot;rank&quot;: 3,
13423 &quot;authorId&quot;: 1,
13424 &quot;messageId&quot;: 2,
13425 &quot;longitude&quot;: 80.87
13426 },
13427 {
13428 &quot;rank&quot;: 3,
13429 &quot;authorId&quot;: 1,
13430 &quot;messageId&quot;: 8,
13431 &quot;longitude&quot;: 80.87
13432 },
13433 {
13434 &quot;rank&quot;: 4,
13435 &quot;authorId&quot;: 1,
13436 &quot;messageId&quot;: 4,
13437 &quot;longitude&quot;: 97.04
13438 },
13439 {
13440 &quot;rank&quot;: 1,
13441 &quot;authorId&quot;: 2,
13442 &quot;messageId&quot;: 6,
13443 &quot;longitude&quot;: 75.56
13444 },
13445 {
13446 &quot;rank&quot;: 2,
13447 &quot;authorId&quot;: 2,
13448 &quot;messageId&quot;: 3,
13449 &quot;longitude&quot;: 81.01
13450 }
13451]
13452</pre></div></div>
13453</li>
13454</ul></div>
13455<div class="section">
13456<h3><a name="first_value"></a>first_value</h3>
13457<ul>
13458
13459<li>
13460
13461<p>Syntax:</p>
13462
13463<div>
13464<div>
13465<pre class="source">FIRST_VALUE(expr) [nulls-treatment] OVER (window-definition)
13466</pre></div></div>
13467</li>
13468<li>
13469
13470<p>Returns the requested value from the first tuple in the current window frame, where the window frame is specified by the window definition.</p>
13471</li>
13472<li>
13473
13474<p>Arguments:</p>
13475<ul>
13476
13477<li><tt>expr</tt>: The value that you want to return from the first tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
13478</ul>
13479</li>
13480<li>
13481
13482<p>Modifiers:</p>
13483<ul>
13484
13485<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the first value in the window frame.
13486<ul>
13487
13488<li>
13489
13490<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the first tuple. In this case, the function returns the first non-NULL, non-MISSING value.</p>
13491</li>
13492<li>
13493
13494<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the first tuple.</p>
13495</li>
13496</ul>
13497<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13498</li>
13499</ul>
13500</li>
13501<li>
13502
13503<p>Clauses:</p>
13504<ul>
13505
13506<li>
13507
13508<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13509</li>
13510<li>
13511
13512<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13513</li>
13514<li>
13515
13516<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13517</li>
13518</ul>
13519</li>
13520<li>
13521
13522<p>Return Value:</p>
13523<ul>
13524
13525<li>
13526
13527<p>The specified value from the first tuple. The order of the tuples is determined by the window order clause.</p>
13528</li>
13529<li>
13530
13531<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
13532</li>
13533<li>
13534
13535<p>In the following cases, this function may return unpredictable results.</p>
13536<ul>
13537
13538<li>
13539
13540<p>If the window order clause is omitted.</p>
13541</li>
13542<li>
13543
13544<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13545</li>
13546</ul>
13547</li>
13548<li>
13549
13550<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
13551</li>
13552<li>
13553
13554<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression.</p>
13555</li>
13556</ul>
13557</li>
13558<li>
13559
13560<p>Example:</p>
13561<p>For each author, show the length of each message, including the length of the shortest message from that author.</p>
13562
13563<div>
13564<div>
13565<pre class="source">SELECT m.authorId, m.messageId,
13566LENGTH(m.message) AS message_length,
13567FIRST_VALUE(LENGTH(m.message)) OVER (
13568 PARTITION BY m.authorId
13569 ORDER BY LENGTH(m.message)
13570) AS shortest_message
13571FROM GleambookMessages AS m;
13572</pre></div></div>
13573</li>
13574<li>
13575
13576<p>The expected result is:</p>
13577
13578<div>
13579<div>
13580<pre class="source">[
13581 {
13582 &quot;message_length&quot;: 31,
13583 &quot;shortest_message&quot;: 31,
13584 &quot;authorId&quot;: 1,
13585 &quot;messageId&quot;: 8
13586 },
13587 {
13588 &quot;message_length&quot;: 39,
13589 &quot;shortest_message&quot;: 31,
13590 &quot;authorId&quot;: 1,
13591 &quot;messageId&quot;: 11
13592 },
13593 {
13594 &quot;message_length&quot;: 44,
13595 &quot;shortest_message&quot;: 31,
13596 &quot;authorId&quot;: 1,
13597 &quot;messageId&quot;: 4
13598 },
13599 {
13600 &quot;message_length&quot;: 45,
13601 &quot;shortest_message&quot;: 31,
13602 &quot;authorId&quot;: 1,
13603 &quot;messageId&quot;: 2
13604 },
13605 {
13606 &quot;message_length&quot;: 51,
13607 &quot;shortest_message&quot;: 31,
13608 &quot;authorId&quot;: 1,
13609 &quot;messageId&quot;: 10
13610 },
13611 {
13612 &quot;message_length&quot;: 35,
13613 &quot;shortest_message&quot;: 35,
13614 &quot;authorId&quot;: 2,
13615 &quot;messageId&quot;: 3
13616 },
13617 {
13618 &quot;message_length&quot;: 44,
13619 &quot;shortest_message&quot;: 35,
13620 &quot;authorId&quot;: 2,
13621 &quot;messageId&quot;: 6
13622 }
13623]
13624</pre></div></div>
13625</li>
13626</ul></div>
13627<div class="section">
13628<h3><a name="lag"></a>lag</h3>
13629<ul>
13630
13631<li>
13632
13633<p>Syntax:</p>
13634
13635<div>
13636<div>
13637<pre class="source">LAG(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
13638</pre></div></div>
13639</li>
13640<li>
13641
13642<p>Returns the value from a tuple at a given offset prior to the current tuple position.</p>
13643<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
13644</li>
13645<li>
13646
13647<p>Arguments:</p>
13648<ul>
13649
13650<li>
13651
13652<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
13653</li>
13654<li>
13655
13656<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
13657</li>
13658<li>
13659
13660<p><tt>default</tt>: (Optional) The value to return when the offset goes out of partition scope. If omitted, the default is NULL.</p>
13661</li>
13662</ul>
13663</li>
13664<li>
13665
13666<p>Modifiers:</p>
13667<ul>
13668
13669<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
13670<ul>
13671
13672<li>
13673
13674<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
13675</li>
13676<li>
13677
13678<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
13679</li>
13680</ul>
13681<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13682</li>
13683</ul>
13684</li>
13685<li>
13686
13687<p>Clauses:</p>
13688<ul>
13689
13690<li>
13691
13692<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13693</li>
13694<li>
13695
13696<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13697</li>
13698</ul>
13699</li>
13700<li>
13701
13702<p>Return Value:</p>
13703<ul>
13704
13705<li>
13706
13707<p>The specified value from the offset tuple.</p>
13708</li>
13709<li>
13710
13711<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
13712</li>
13713</ul>
13714</li>
13715<li>
13716
13717<p>Example:</p>
13718<p>For each author, show the length of each message, including the length of the next-shortest message.</p>
13719
13720<div>
13721<div>
13722<pre class="source">SELECT m.authorId, m.messageId,
13723LENGTH(m.message) AS message_length,
13724LAG(LENGTH(m.message), 1, &quot;No shorter message&quot;) OVER (
13725 PARTITION BY m.authorId
13726 ORDER BY LENGTH(m.message)
13727) AS next_shortest_message
13728FROM GleambookMessages AS m;
13729</pre></div></div>
13730</li>
13731<li>
13732
13733<p>The expected result is:</p>
13734
13735<div>
13736<div>
13737<pre class="source">[
13738 {
13739 &quot;message_length&quot;: 31,
13740 &quot;authorId&quot;: 1,
13741 &quot;messageId&quot;: 8,
13742 &quot;next_shortest_message&quot;: &quot;No shorter message&quot;
13743 },
13744 {
13745 &quot;message_length&quot;: 39,
13746 &quot;authorId&quot;: 1,
13747 &quot;messageId&quot;: 11,
13748 &quot;next_shortest_message&quot;: 31
13749 },
13750 {
13751 &quot;message_length&quot;: 44,
13752 &quot;authorId&quot;: 1,
13753 &quot;messageId&quot;: 4,
13754 &quot;next_shortest_message&quot;: 39
13755 },
13756 {
13757 &quot;message_length&quot;: 45,
13758 &quot;authorId&quot;: 1,
13759 &quot;messageId&quot;: 2,
13760 &quot;next_shortest_message&quot;: 44
13761 },
13762 {
13763 &quot;message_length&quot;: 51,
13764 &quot;authorId&quot;: 1,
13765 &quot;messageId&quot;: 10,
13766 &quot;next_shortest_message&quot;: 45
13767 },
13768 {
13769 &quot;message_length&quot;: 35,
13770 &quot;authorId&quot;: 2,
13771 &quot;messageId&quot;: 3,
13772 &quot;next_shortest_message&quot;: &quot;No shorter message&quot;
13773 },
13774 {
13775 &quot;message_length&quot;: 44,
13776 &quot;authorId&quot;: 2,
13777 &quot;messageId&quot;: 6,
13778 &quot;next_shortest_message&quot;: 35
13779 }
13780]
13781</pre></div></div>
13782</li>
13783</ul></div>
13784<div class="section">
13785<h3><a name="last_value"></a>last_value</h3>
13786<ul>
13787
13788<li>
13789
13790<p>Syntax:</p>
13791
13792<div>
13793<div>
13794<pre class="source">LAST_VALUE(expr) [nulls-treatment] OVER (window-definition)
13795</pre></div></div>
13796</li>
13797<li>
13798
13799<p>Returns the requested value from the last tuple in the current window frame, where the window frame is specified by the window definition.</p>
13800</li>
13801<li>
13802
13803<p>Arguments:</p>
13804<ul>
13805
13806<li><tt>expr</tt>: The value that you want to return from the last tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
13807</ul>
13808</li>
13809<li>
13810
13811<p>Modifiers:</p>
13812<ul>
13813
13814<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the last tuple in the window frame.
13815<ul>
13816
13817<li>
13818
13819<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the last tuple. In this case, the function returns the last non-NULL, non-MISSING value.</p>
13820</li>
13821<li>
13822
13823<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the last tuple.</p>
13824</li>
13825</ul>
13826<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
13827</li>
13828</ul>
13829</li>
13830<li>
13831
13832<p>Clauses:</p>
13833<ul>
13834
13835<li>
13836
13837<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
13838</li>
13839<li>
13840
13841<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
13842</li>
13843<li>
13844
13845<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
13846</li>
13847</ul>
13848</li>
13849<li>
13850
13851<p>Return Value:</p>
13852<ul>
13853
13854<li>
13855
13856<p>The specified value from the last tuple. The order of the tuples is determined by the window order clause.</p>
13857</li>
13858<li>
13859
13860<p>NULL, if the frame was empty or if all values were NULL or MISSING and the <tt>IGNORE NULLS</tt> modifier was specified.</p>
13861</li>
13862<li>
13863
13864<p>In the following cases, this function may return unpredictable results.</p>
13865<ul>
13866
13867<li>
13868
13869<p>If the window order clause is omitted.</p>
13870</li>
13871<li>
13872
13873<p>If the window frame clause is omitted.</p>
13874</li>
13875<li>
13876
13877<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
13878</li>
13879</ul>
13880</li>
13881<li>
13882
13883<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
13884</li>
13885<li>
13886
13887<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the last value of the input expression.</p>
13888</li>
13889</ul>
13890</li>
13891<li>
13892
13893<p>Example:</p>
13894<p>For each author, show the length of each message, including the length of the longest message from that author.</p>
13895
13896<div>
13897<div>
13898<pre class="source">SELECT m.authorId, m.messageId,
13899LENGTH(m.message) AS message_length,
13900LAST_VALUE(LENGTH(m.message)) OVER (
13901 PARTITION BY m.authorId
13902 ORDER BY LENGTH(m.message)
13903 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
13904) AS longest_message
13905FROM GleambookMessages AS m;
13906</pre></div></div>
13907</li>
13908<li>
13909
13910<p>The expected result is:</p>
13911
13912<div>
13913<div>
13914<pre class="source">[
13915 {
13916 &quot;message_length&quot;: 31,
13917 &quot;longest_message&quot;: 51,
13918 &quot;authorId&quot;: 1,
13919 &quot;messageId&quot;: 8
13920 },
13921 {
13922 &quot;message_length&quot;: 39,
13923 &quot;longest_message&quot;: 51,
13924 &quot;authorId&quot;: 1,
13925 &quot;messageId&quot;: 11
13926 },
13927 {
13928 &quot;message_length&quot;: 44,
13929 &quot;longest_message&quot;: 51,
13930 &quot;authorId&quot;: 1,
13931 &quot;messageId&quot;: 4
13932 },
13933 {
13934 &quot;message_length&quot;: 45,
13935 &quot;longest_message&quot;: 51,
13936 &quot;authorId&quot;: 1,
13937 &quot;messageId&quot;: 2
13938 },
13939 {
13940 &quot;message_length&quot;: 51,
13941 &quot;longest_message&quot;: 51,
13942 &quot;authorId&quot;: 1,
13943 &quot;messageId&quot;: 10
13944 },
13945 {
13946 &quot;message_length&quot;: 35,
13947 &quot;longest_message&quot;: 44,
13948 &quot;authorId&quot;: 2,
13949 &quot;messageId&quot;: 3
13950 },
13951 {
13952 &quot;message_length&quot;: 44,
13953 &quot;longest_message&quot;: 44,
13954 &quot;authorId&quot;: 2,
13955 &quot;messageId&quot;: 6
13956 }
13957]
13958</pre></div></div>
13959
13960<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that the longest message would always be the same as the current message.</p>
13961</li>
13962</ul></div>
13963<div class="section">
13964<h3><a name="lead"></a>lead</h3>
13965<ul>
13966
13967<li>
13968
13969<p>Syntax:</p>
13970
13971<div>
13972<div>
13973<pre class="source">LEAD(expr[, offset[, default]]) [nulls-treatment] OVER ([window-partition-clause] [window-order-clause])
13974</pre></div></div>
13975</li>
13976<li>
13977
13978<p>Returns the value from a tuple at a given offset ahead of the current tuple position.</p>
13979<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
13980</li>
13981<li>
13982
13983<p>Arguments:</p>
13984<ul>
13985
13986<li>
13987
13988<p><tt>expr</tt>: The value that you want to return from the offset tuple. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
13989</li>
13990<li>
13991
13992<p><tt>offset</tt>: (Optional) A positive integer. If omitted, the default is 1.</p>
13993</li>
13994<li>
13995
13996<p><tt>default</tt>: (Optional) The value to return when the offset goes out of window partition scope. If omitted, the default is NULL.</p>
13997</li>
13998</ul>
13999</li>
14000<li>
14001
14002<p>Modifiers:</p>
14003<ul>
14004
14005<li><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window partition.
14006<ul>
14007
14008<li>
14009
14010<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
14011</li>
14012<li>
14013
14014<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
14015</li>
14016</ul>
14017<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
14018</li>
14019</ul>
14020</li>
14021<li>
14022
14023<p>Clauses:</p>
14024<ul>
14025
14026<li>
14027
14028<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14029</li>
14030<li>
14031
14032<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14033</li>
14034</ul>
14035</li>
14036<li>
14037
14038<p>Return Value:</p>
14039<ul>
14040
14041<li>
14042
14043<p>The specified value from the offset tuple.</p>
14044</li>
14045<li>
14046
14047<p>If the offset tuple is out of partition scope, it returns the default value, or NULL if no default is specified.</p>
14048</li>
14049</ul>
14050</li>
14051<li>
14052
14053<p>Example:</p>
14054<p>For each author, show the length of each message, including the length of the next-longest message.</p>
14055
14056<div>
14057<div>
14058<pre class="source">SELECT m.authorId, m.messageId,
14059LENGTH(m.message) AS message_length,
14060LEAD(LENGTH(m.message), 1, &quot;No longer message&quot;) OVER (
14061 PARTITION BY m.authorId
14062 ORDER BY LENGTH(m.message)
14063) AS next_longest_message
14064FROM GleambookMessages AS m;
14065</pre></div></div>
14066</li>
14067<li>
14068
14069<p>The expected result is:</p>
14070
14071<div>
14072<div>
14073<pre class="source">[
14074 {
14075 &quot;message_length&quot;: 31,
14076 &quot;authorId&quot;: 1,
14077 &quot;messageId&quot;: 8,
14078 &quot;next_longest_message&quot;: 39
14079 },
14080 {
14081 &quot;message_length&quot;: 39,
14082 &quot;authorId&quot;: 1,
14083 &quot;messageId&quot;: 11,
14084 &quot;next_longest_message&quot;: 44
14085 },
14086 {
14087 &quot;message_length&quot;: 44,
14088 &quot;authorId&quot;: 1,
14089 &quot;messageId&quot;: 4,
14090 &quot;next_longest_message&quot;: 45
14091 },
14092 {
14093 &quot;message_length&quot;: 45,
14094 &quot;authorId&quot;: 1,
14095 &quot;messageId&quot;: 2,
14096 &quot;next_longest_message&quot;: 51
14097 },
14098 {
14099 &quot;message_length&quot;: 51,
14100 &quot;authorId&quot;: 1,
14101 &quot;messageId&quot;: 10,
14102 &quot;next_longest_message&quot;: &quot;No longer message&quot;
14103 },
14104 {
14105 &quot;message_length&quot;: 35,
14106 &quot;authorId&quot;: 2,
14107 &quot;messageId&quot;: 3,
14108 &quot;next_longest_message&quot;: 44
14109 },
14110 {
14111 &quot;message_length&quot;: 44,
14112 &quot;authorId&quot;: 2,
14113 &quot;messageId&quot;: 6,
14114 &quot;next_longest_message&quot;: &quot;No longer message&quot;
14115 }
14116]
14117</pre></div></div>
14118</li>
14119</ul></div>
14120<div class="section">
14121<h3><a name="nth_value"></a>nth_value</h3>
14122<ul>
14123
14124<li>
14125
14126<p>Syntax:</p>
14127
14128<div>
14129<div>
14130<pre class="source">NTH_VALUE(expr, offset) [nthval-from] [nulls-treatment] OVER (window-definition)
14131</pre></div></div>
14132</li>
14133<li>
14134
14135<p>Returns the requested value from a tuple in the current window frame, where the window frame is specified by the window definition.</p>
14136</li>
14137<li>
14138
14139<p>Arguments:</p>
14140<ul>
14141
14142<li>
14143
14144<p><tt>expr</tt>: The value that you want to return from the offset tuple in the window frame. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></p>
14145</li>
14146<li>
14147
14148<p><tt>offset</tt>: The number of the offset tuple within the window frame, counting from 1.</p>
14149</li>
14150</ul>
14151</li>
14152<li>
14153
14154<p>Modifiers:</p>
14155<ul>
14156
14157<li>
14158
14159<p><a href="manual.html#Nth_val_from">Nth Val From</a>: (Optional) Determines where the function starts counting the offset.</p>
14160<ul>
14161
14162<li>
14163
14164<p><tt>FROM FIRST</tt>: Counting starts at the first tuple in the window frame. In this case, an offset of 1 is the first tuple in the window frame, 2 is the second tuple, and so on.</p>
14165</li>
14166<li>
14167
14168<p><tt>FROM LAST</tt>: Counting starts at the last tuple in the window frame. In this case, an offset of 1 is the last tuple in the window frame, 2 is the second-to-last tuple, and so on.</p>
14169</li>
14170</ul>
14171<p>The order of the tuples is determined by the window order clause. If this modifier is omitted, the default is <tt>FROM FIRST</tt>.</p>
14172</li>
14173<li>
14174
14175<p><a href="manual.html#Nulls_treatment">Nulls Treatment</a>: (Optional) Determines how NULL or MISSING values are treated when finding the offset tuple in the window frame.</p>
14176<ul>
14177
14178<li>
14179
14180<p><tt>IGNORE NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are ignored when finding the offset tuple.</p>
14181</li>
14182<li>
14183
14184<p><tt>RESPECT NULLS</tt>: If the values for any tuples evaluate to NULL or MISSING, those tuples are included when finding the offset tuple.</p>
14185</li>
14186</ul>
14187<p>If this modifier is omitted, the default is <tt>RESPECT NULLS</tt>.</p>
14188</li>
14189</ul>
14190</li>
14191<li>
14192
14193<p>Clauses:</p>
14194<ul>
14195
14196<li>
14197
14198<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14199</li>
14200<li>
14201
14202<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14203</li>
14204<li>
14205
14206<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14207</li>
14208</ul>
14209</li>
14210<li>
14211
14212<p>Return Value:</p>
14213<ul>
14214
14215<li>
14216
14217<p>The specified value from the offset tuple.</p>
14218</li>
14219<li>
14220
14221<p>In the following cases, this function may return unpredictable results.</p>
14222<ul>
14223
14224<li>
14225
14226<p>If the window order clause is omitted.</p>
14227</li>
14228<li>
14229
14230<p>If the window frame is defined by <tt>ROWS</tt>, and there are tied tuples in the window frame.</p>
14231</li>
14232</ul>
14233</li>
14234<li>
14235
14236<p>To make the function return deterministic results, add a window order clause, or add further ordering terms to the window order clause so that no tuples are tied.</p>
14237</li>
14238<li>
14239
14240<p>If the window frame is defined by <tt>RANGE</tt> or <tt>GROUPS</tt>, and there are tied tuples in the window frame, the function returns the first value of the input expression when counting <tt>FROM FIRST</tt>, or the last value of the input expression when counting <tt>FROM LAST</tt>.</p>
14241</li>
14242</ul>
14243</li>
14244<li>
14245
14246<p>Example 1:</p>
14247<p>For each author, show the length of each message, including the length of the second shortest message from that author.</p>
14248
14249<div>
14250<div>
14251<pre class="source">SELECT m.authorId, m.messageId,
14252LENGTH(m.message) AS message_length,
14253NTH_VALUE(LENGTH(m.message), 2) FROM FIRST OVER (
14254 PARTITION BY m.authorId
14255 ORDER BY LENGTH(m.message)
14256 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14257) AS shortest_message_but_1
14258FROM GleambookMessages AS m;
14259</pre></div></div>
14260</li>
14261<li>
14262
14263<p>The expected result is:</p>
14264
14265<div>
14266<div>
14267<pre class="source">[
14268 {
14269 &quot;message_length&quot;: 31,
14270 &quot;shortest_message_but_1&quot;: 39,
14271 &quot;authorId&quot;: 1,
14272 &quot;messageId&quot;: 8
14273 },
14274 {
14275 &quot;message_length&quot;: 39,
14276 &quot;shortest_message_but_1&quot;: 39,
14277 &quot;authorId&quot;: 1,
14278 &quot;messageId&quot;: 11 // &#x278b;
14279 },
14280 {
14281 &quot;message_length&quot;: 44,
14282 &quot;shortest_message_but_1&quot;: 39,
14283 &quot;authorId&quot;: 1,
14284 &quot;messageId&quot;: 4
14285 },
14286 {
14287 &quot;message_length&quot;: 45,
14288 &quot;shortest_message_but_1&quot;: 39,
14289 &quot;authorId&quot;: 1,
14290 &quot;messageId&quot;: 2
14291 },
14292 {
14293 &quot;message_length&quot;: 51,
14294 &quot;shortest_message_but_1&quot;: 39,
14295 &quot;authorId&quot;: 1,
14296 &quot;messageId&quot;: 10
14297 },
14298 {
14299 &quot;message_length&quot;: 35,
14300 &quot;shortest_message_but_1&quot;: 44,
14301 &quot;authorId&quot;: 2,
14302 &quot;messageId&quot;: 3
14303 },
14304 {
14305 &quot;message_length&quot;: 44,
14306 &quot;shortest_message_but_1&quot;: 44,
14307 &quot;authorId&quot;: 2,
14308 &quot;messageId&quot;: 6 // &#x278b;
14309 }
14310]
14311</pre></div></div>
14312
14313<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean that for the shortest message, the function would be unable to find the route with the second shortest message.</p>
14314<p>&#x2781; The second shortest message from this author.</p>
14315</li>
14316<li>
14317
14318<p>Example 2:</p>
14319<p>For each author, show the length of each message, including the length of the second longest message from that author.</p>
14320
14321<div>
14322<div>
14323<pre class="source">SELECT m.authorId, m.messageId,
14324LENGTH(m.message) AS message_length,
14325NTH_VALUE(LENGTH(m.message), 2) FROM LAST OVER (
14326 PARTITION BY m.authorId
14327 ORDER BY LENGTH(m.message)
14328 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING -- &#x278a;
14329) AS longest_message_but_1
14330FROM GleambookMessages AS m;
14331</pre></div></div>
14332</li>
14333<li>
14334
14335<p>The expected result is:</p>
14336
14337<div>
14338<div>
14339<pre class="source">[
14340 {
14341 &quot;message_length&quot;: 31,
14342 &quot;longest_message_but_1&quot;: 45,
14343 &quot;authorId&quot;: 1,
14344 &quot;messageId&quot;: 8
14345 },
14346 {
14347 &quot;message_length&quot;: 39,
14348 &quot;longest_message_but_1&quot;: 45,
14349 &quot;authorId&quot;: 1,
14350 &quot;messageId&quot;: 11
14351 },
14352 {
14353 &quot;message_length&quot;: 44,
14354 &quot;longest_message_but_1&quot;: 45,
14355 &quot;authorId&quot;: 1,
14356 &quot;messageId&quot;: 4
14357 },
14358 {
14359 &quot;message_length&quot;: 45,
14360 &quot;longest_message_but_1&quot;: 45,
14361 &quot;authorId&quot;: 1,
14362 &quot;messageId&quot;: 2 // &#x278b;
14363 },
14364 {
14365 &quot;message_length&quot;: 51,
14366 &quot;longest_message_but_1&quot;: 45,
14367 &quot;authorId&quot;: 1,
14368 &quot;messageId&quot;: 10
14369 },
14370 {
14371 &quot;message_length&quot;: 35,
14372 &quot;longest_message_but_1&quot;: 35,
14373 &quot;authorId&quot;: 2,
14374 &quot;messageId&quot;: 3 // &#x278b;
14375 },
14376 {
14377 &quot;message_length&quot;: 44,
14378 &quot;longest_message_but_1&quot;: 35,
14379 &quot;authorId&quot;: 2,
14380 &quot;messageId&quot;: 6
14381 }
14382]
14383</pre></div></div>
14384
14385<p>&#x2780; This clause specifies that the window frame should extend to the end of the window partition. Without this clause, the end point of the window frame would always be the current tuple. This would mean the function would be unable to find the second longest message for shorter messages.</p>
14386<p>&#x2781; The second longest message from this author.</p>
14387</li>
14388</ul></div>
14389<div class="section">
14390<h3><a name="ntile"></a>ntile</h3>
14391<ul>
14392
14393<li>
14394
14395<p>Syntax:</p>
14396
14397<div>
14398<div>
14399<pre class="source">NTILE(num_tiles) OVER ([window-partition-clause] [window-order-clause])
14400</pre></div></div>
14401</li>
14402<li>
14403
14404<p>Divides the window partition into the specified number of tiles, and allocates each tuple in the window partition to a tile, so that as far as possible each tile has an equal number of tuples. When the set of tuples is not equally divisible by the number of tiles, the function puts more tuples into the lower-numbered tiles. For each tuple, the function returns the number of the tile into which that tuple was placed.</p>
14405<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted then the tuples are processed in an undefined order.</p>
14406</li>
14407<li>
14408
14409<p>Arguments:</p>
14410<ul>
14411
14412<li><tt>num_tiles</tt>: The number of tiles into which you want to divide the window partition. This argument can be an expression and must evaluate to a number. If the number is not an integer, it will be truncated.</li>
14413</ul>
14414</li>
14415<li>
14416
14417<p>Clauses:</p>
14418<ul>
14419
14420<li>
14421
14422<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14423</li>
14424<li>
14425
14426<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14427</li>
14428</ul>
14429</li>
14430<li>
14431
14432<p>Return Value:</p>
14433<ul>
14434
14435<li>An value greater than or equal to 1 and less than or equal to the number of tiles.</li>
14436</ul>
14437</li>
14438<li>
14439
14440<p>Example:</p>
14441<p>Allocate each message to one of three tiles by length and message ID.</p>
14442
14443<div>
14444<div>
14445<pre class="source">SELECT m.messageId, LENGTH(m.message) AS `length`,
14446NTILE(3) OVER (
14447 ORDER BY LENGTH(m.message), m.messageId
14448) AS `ntile`
14449FROM GleambookMessages AS m;
14450</pre></div></div>
14451</li>
14452<li>
14453
14454<p>The expected result is:</p>
14455
14456<div>
14457<div>
14458<pre class="source">[
14459 {
14460 &quot;length&quot;: 31,
14461 &quot;ntile&quot;: 1,
14462 &quot;messageId&quot;: 8
14463 },
14464 {
14465 &quot;length&quot;: 35,
14466 &quot;ntile&quot;: 1,
14467 &quot;messageId&quot;: 3
14468 },
14469 {
14470 &quot;length&quot;: 39,
14471 &quot;ntile&quot;: 1,
14472 &quot;messageId&quot;: 11
14473 },
14474 {
14475 &quot;length&quot;: 44,
14476 &quot;ntile&quot;: 2,
14477 &quot;messageId&quot;: 4
14478 },
14479 {
14480 &quot;length&quot;: 44,
14481 &quot;ntile&quot;: 2,
14482 &quot;messageId&quot;: 6
14483 },
14484 {
14485 &quot;length&quot;: 45,
14486 &quot;ntile&quot;: 3,
14487 &quot;messageId&quot;: 2
14488 },
14489 {
14490 &quot;length&quot;: 51,
14491 &quot;ntile&quot;: 3,
14492 &quot;messageId&quot;: 10
14493 }
14494]
14495</pre></div></div>
14496</li>
14497</ul></div>
14498<div class="section">
14499<h3><a name="percent_rank"></a>percent_rank</h3>
14500<ul>
14501
14502<li>
14503
14504<p>Syntax:</p>
14505
14506<div>
14507<div>
14508<pre class="source">PERCENT_RANK() OVER ([window-partition-clause] [window-order-clause])
14509</pre></div></div>
14510</li>
14511<li>
14512
14513<p>Returns the percentile rank of the current tuple &#x2013; that is, the rank of the tuples minus one, divided by the total number of tuples in the window partition minus one.</p>
14514<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the function returns the same result (0) for each tuple.</p>
14515</li>
14516<li>
14517
14518<p>Arguments:</p>
14519<ul>
14520
14521<li>None.</li>
14522</ul>
14523</li>
14524<li>
14525
14526<p>Clauses:</p>
14527<ul>
14528
14529<li>
14530
14531<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14532</li>
14533<li>
14534
14535<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14536</li>
14537</ul>
14538</li>
14539<li>
14540
14541<p>Return Value:</p>
14542<ul>
14543
14544<li>A number between 0 and 1. The higher the value, the higher the ranking.</li>
14545</ul>
14546</li>
14547<li>
14548
14549<p>Example:</p>
14550<p>For each author, find the percentile rank of all messages in order of message ID.</p>
14551
14552<div>
14553<div>
14554<pre class="source">SELECT m.messageId, m.authorId, PERCENT_RANK() OVER (
14555 PARTITION BY m.authorId
14556 ORDER BY m.messageId
14557) AS `rank`
14558FROM GleambookMessages AS m;
14559</pre></div></div>
14560</li>
14561<li>
14562
14563<p>The expected result is:</p>
14564
14565<div>
14566<div>
14567<pre class="source">[
14568 {
14569 &quot;rank&quot;: 0,
14570 &quot;messageId&quot;: 2,
14571 &quot;authorId&quot;: 1
14572 },
14573 {
14574 &quot;rank&quot;: 0.25,
14575 &quot;messageId&quot;: 4,
14576 &quot;authorId&quot;: 1
14577 },
14578 {
14579 &quot;rank&quot;: 0.5,
14580 &quot;messageId&quot;: 8,
14581 &quot;authorId&quot;: 1
14582 },
14583 {
14584 &quot;rank&quot;: 0.75,
14585 &quot;messageId&quot;: 10,
14586 &quot;authorId&quot;: 1
14587 },
14588 {
14589 &quot;rank&quot;: 1,
14590 &quot;messageId&quot;: 11,
14591 &quot;authorId&quot;: 1
14592 },
14593 {
14594 &quot;rank&quot;: 0,
14595 &quot;messageId&quot;: 3,
14596 &quot;authorId&quot;: 2
14597 },
14598 {
14599 &quot;rank&quot;: 1,
14600 &quot;messageId&quot;: 6,
14601 &quot;authorId&quot;: 2
14602 }
14603]
14604</pre></div></div>
14605</li>
14606</ul></div>
14607<div class="section">
14608<h3><a name="rank"></a>rank</h3>
14609<ul>
14610
14611<li>
14612
14613<p>Syntax:</p>
14614
14615<div>
14616<div>
14617<pre class="source">RANK() OVER ([window-partition-clause] [window-order-clause])
14618</pre></div></div>
14619</li>
14620<li>
14621
14622<p>Returns the rank of the current tuple &#x2013; that is, the number of distinct tuples preceding this tuple in the current window partition, plus one.</p>
14623<p>The tuples are ordered by the window order clause. If any tuples are tied, they will have the same rank. If the window order clause is omitted, the function returns the same result (1) for each tuple.</p>
14624<p>When any tuples have the same rank, the rank of the next tuple will include all preceding tuples, so there may be a gap in the sequence of returned values. For example, if there are three tuples ranked 2, the next rank is 5.</p>
14625<p>To avoid gaps in the returned values, use the DENSE_RANK() function instead.</p>
14626</li>
14627<li>
14628
14629<p>Arguments:</p>
14630<ul>
14631
14632<li>None.</li>
14633</ul>
14634</li>
14635<li>
14636
14637<p>Clauses:</p>
14638<ul>
14639
14640<li>
14641
14642<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14643</li>
14644<li>
14645
14646<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14647</li>
14648</ul>
14649</li>
14650<li>
14651
14652<p>Return Value:</p>
14653<ul>
14654
14655<li>An integer, greater than or equal to 1.</li>
14656</ul>
14657</li>
14658<li>
14659
14660<p>Example:</p>
14661<p>For each author, find the rank of all messages in order of location.</p>
14662
14663<div>
14664<div>
14665<pre class="source">SELECT m.authorId, m.messageId, m.senderLocation[1] as longitude,
14666RANK() OVER (
14667 PARTITION BY m.authorId
14668 ORDER BY m.senderLocation[1]
14669) AS `rank`
14670FROM GleambookMessages AS m;
14671</pre></div></div>
14672</li>
14673<li>
14674
14675<p>The expected result is:</p>
14676
14677<div>
14678<div>
14679<pre class="source">[
14680 {
14681 &quot;rank&quot;: 1,
14682 &quot;authorId&quot;: 1,
14683 &quot;messageId&quot;: 10,
14684 &quot;longitude&quot;: 70.01
14685 },
14686 {
14687 &quot;rank&quot;: 2,
14688 &quot;authorId&quot;: 1,
14689 &quot;messageId&quot;: 11,
14690 &quot;longitude&quot;: 77.49
14691 },
14692 {
14693 &quot;rank&quot;: 3,
14694 &quot;authorId&quot;: 1,
14695 &quot;messageId&quot;: 2,
14696 &quot;longitude&quot;: 80.87
14697 },
14698 {
14699 &quot;rank&quot;: 3,
14700 &quot;authorId&quot;: 1,
14701 &quot;messageId&quot;: 8,
14702 &quot;longitude&quot;: 80.87
14703 },
14704 {
14705 &quot;rank&quot;: 5,
14706 &quot;authorId&quot;: 1,
14707 &quot;messageId&quot;: 4,
14708 &quot;longitude&quot;: 97.04
14709 },
14710 {
14711 &quot;rank&quot;: 1,
14712 &quot;authorId&quot;: 2,
14713 &quot;messageId&quot;: 6,
14714 &quot;longitude&quot;: 75.56
14715 },
14716 {
14717 &quot;rank&quot;: 2,
14718 &quot;authorId&quot;: 2,
14719 &quot;messageId&quot;: 3,
14720 &quot;longitude&quot;: 81.01
14721 }
14722]
14723</pre></div></div>
14724</li>
14725</ul></div>
14726<div class="section">
14727<h3><a name="ratio_to_report"></a>ratio_to_report</h3>
14728<ul>
14729
14730<li>
14731
14732<p>Syntax:</p>
14733
14734<div>
14735<div>
14736<pre class="source">RATIO_TO_REPORT(expr) OVER (window-definition)
14737</pre></div></div>
14738</li>
14739<li>
14740
14741<p>Returns the fractional ratio of the specified value for each tuple to the sum of values for all tuples in the window frame.</p>
14742</li>
14743<li>
14744
14745<p>Arguments:</p>
14746<ul>
14747
14748<li><tt>expr</tt>: The value for which you want to calculate the fractional ratio. <sup>[</sup><a href="#fn_1"><sup>1</sup></a><sup>]</sup></li>
14749</ul>
14750</li>
14751<li>
14752
14753<p>Clauses:</p>
14754<ul>
14755
14756<li>
14757
14758<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14759</li>
14760<li>
14761
14762<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14763</li>
14764<li>
14765
14766<p>(Optional) <a href="manual.html#Window_frame_clause">Window Frame Clause</a>.</p>
14767</li>
14768</ul>
14769</li>
14770<li>
14771
14772<p>Return Value:</p>
14773<ul>
14774
14775<li>
14776
14777<p>A number between 0 and 1, representing the fractional ratio of the value for the current tuple to the sum of values for all tuples in the current window frame. The sum of returned values for all tuples in the current window frame is 1.</p>
14778</li>
14779<li>
14780
14781<p>If the input expression does not evaluate to a number, or the sum of values for all tuples is zero, it returns NULL.</p>
14782</li>
14783</ul>
14784</li>
14785<li>
14786
14787<p>Example:</p>
14788<p>For each author, calculate the length of each message as a fraction of the total length of all messages.</p>
14789
14790<div>
14791<div>
14792<pre class="source">SELECT m.messageId, m.authorId,
14793RATIO_TO_REPORT(LENGTH(m.message)) OVER (
14794 PARTITION BY m.authorId
14795) AS length_ratio
14796FROM GleambookMessages AS m;
14797</pre></div></div>
14798</li>
14799<li>
14800
14801<p>The expected result is:</p>
14802
14803<div>
14804<div>
14805<pre class="source">[
14806 {
14807 &quot;length_ratio&quot;: 0.21428571428571427,
14808 &quot;messageId&quot;: 2,
14809 &quot;authorId&quot;: 1
14810 },
14811 {
14812 &quot;length_ratio&quot;: 0.20952380952380953,
14813 &quot;messageId&quot;: 4,
14814 &quot;authorId&quot;: 1
14815 },
14816 {
14817 &quot;length_ratio&quot;: 0.14761904761904762,
14818 &quot;messageId&quot;: 8,
14819 &quot;authorId&quot;: 1
14820 },
14821 {
14822 &quot;length_ratio&quot;: 0.24285714285714285,
14823 &quot;messageId&quot;: 10,
14824 &quot;authorId&quot;: 1
14825 },
14826 {
14827 &quot;length_ratio&quot;: 0.18571428571428572,
14828 &quot;messageId&quot;: 11,
14829 &quot;authorId&quot;: 1
14830 },
14831 {
14832 &quot;length_ratio&quot;: 0.4430379746835443,
14833 &quot;messageId&quot;: 3,
14834 &quot;authorId&quot;: 2
14835 },
14836 {
14837 &quot;length_ratio&quot;: 0.5569620253164557,
14838 &quot;messageId&quot;: 6,
14839 &quot;authorId&quot;: 2
14840 }
14841]
14842</pre></div></div>
14843</li>
14844</ul></div>
14845<div class="section">
14846<h3><a name="row_number"></a>row_number</h3>
14847<ul>
14848
14849<li>
14850
14851<p>Syntax:</p>
14852
14853<div>
14854<div>
14855<pre class="source">ROW_NUMBER() OVER ([window-partition-clause] [window-order-clause])
14856</pre></div></div>
14857</li>
14858<li>
14859
14860<p>Returns a unique row number for every tuple in every window partition. In each window partition, the row numbering starts at 1.</p>
14861<p>The window order clause determines the sort order of the tuples. If the window order clause is omitted, the return values may be unpredictable.</p>
14862</li>
14863<li>
14864
14865<p>Arguments:</p>
14866<ul>
14867
14868<li>None.</li>
14869</ul>
14870</li>
14871<li>
14872
14873<p>Clauses:</p>
14874<ul>
14875
14876<li>
14877
14878<p>(Optional) <a href="manual.html#Window_partition_clause">Window Partition Clause</a>.</p>
14879</li>
14880<li>
14881
14882<p>(Optional) <a href="manual.html#Window_order_clause">Window Order Clause</a>.</p>
14883</li>
14884</ul>
14885</li>
14886<li>
14887
14888<p>Return Value:</p>
14889<ul>
14890
14891<li>An integer, greater than or equal to 1.</li>
14892</ul>
14893</li>
14894<li>
14895
14896<p>Example:</p>
14897<p>For each author, number all messages in order of length.</p>
14898
14899<div>
14900<div>
14901<pre class="source">SELECT m.messageId, m.authorId,
14902ROW_NUMBER() OVER (
14903 PARTITION BY m.authorId
14904 ORDER BY LENGTH(m.message)
14905) AS `row`
14906FROM GleambookMessages AS m;
14907</pre></div></div>
14908</li>
14909<li>
14910
14911<p>The expected result is:</p>
14912
14913<div>
14914<div>
14915<pre class="source">[
14916 {
14917 &quot;row&quot;: 1,
14918 &quot;messageId&quot;: 8,
14919 &quot;authorId&quot;: 1
14920 },
14921 {
14922 &quot;row&quot;: 2,
14923 &quot;messageId&quot;: 11,
14924 &quot;authorId&quot;: 1
14925 },
14926 {
14927 &quot;row&quot;: 3,
14928 &quot;messageId&quot;: 4,
14929 &quot;authorId&quot;: 1
14930 },
14931 {
14932 &quot;row&quot;: 4,
14933 &quot;messageId&quot;: 2,
14934 &quot;authorId&quot;: 1
14935 },
14936 {
14937 &quot;row&quot;: 5,
14938 &quot;messageId&quot;: 10,
14939 &quot;authorId&quot;: 1
14940 },
14941 {
14942 &quot;row&quot;: 1,
14943 &quot;messageId&quot;: 3,
14944 &quot;authorId&quot;: 2
14945 },
14946 {
14947 &quot;row&quot;: 2,
14948 &quot;messageId&quot;: 6,
14949 &quot;authorId&quot;: 2
14950 }
14951]
14952</pre></div></div>
14953</li>
14954</ul><hr />
14955<p><a name="fn_1" id="fn_1">1</a>. If the query contains the GROUP BY clause or any <a href="#AggregateFunctions">aggregate functions</a>, this expression must only depend on GROUP BY expressions or aggregate functions.</p></div></div>
14956 </div>
14957 </div>
14958 </div>
14959 <hr/>
14960 <footer>
14961 <div class="container-fluid">
14962 <div class="row-fluid">
14963<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
14964 feather logo, and the Apache AsterixDB project logo are either
14965 registered trademarks or trademarks of The Apache Software
14966 Foundation in the United States and other countries.
14967 All other marks mentioned may be trademarks or registered
14968 trademarks of their respective owners.
14969 </div>
14970 </div>
14971 </div>
14972 </footer>
14973 </body>
14974</html>